Image caption The Kennedys pose for a campaign photo at their home on Cape Cod, Massachusetts

Fifty years since he was elected US president, there is still an aura around John F Kennedy's White House, yet arguably the dirtier side of modern politics has its roots in his rise to power.

Get the picture right, and your history will take care of itself. Jack Kennedy always got the picture right. Even now, it is hardly possible to glimpse the gleaming white smile, the sunlit hair and the perfect First Family without a lump in the throat.

JFK became the icon of democratic optimism, the man who inspired half the world. Cut down in his prime, he never grew old enough to betray, disillusion or bore his legion of admirers.

Who is President Josiah Bartlett of The West Wing but the liberal fantasy of a mature Kennedy - pin-sharp, hard as nails and bright with idealism?

So it comes as a shock to properly study Kennedy the campaigner. The story of how a rich, preppy party boy from Massachusetts managed to raise a roar for underdog America loud enough to carry him to the White House is gripping. But uplifting it certainly isn't.

Yes, it's a tale of soaring and risk-taking rhetoric, partly fashioned by the late lamented Ted Sorensen, and of a candidate with remarkable energy.

It is also, however, a tale of big money, smears, bribes, wire-pulling and bottomless cynicism. If you are asking what has gone so wrong with modern politics, Kennedy's 1960 election campaign is a good place to start.

And in that campaign, West Virginia, the impoverished and sidelined state where Kennedy polished off his main Democratic rival Hubert Humphrey, is better still.

Image caption John F Kennedy's parents, Joe and Rose visit the First Couple at the White House

West Virginia is still the wooded, hilly, coal-mining-ravaged place of small towns, military volunteers and neighbourliness it was when the rivals clashed there.

On the one side came Kennedy with his private plane, a present from Daddy, and huge amounts of money for campaign commercials.

He came with promises about more money for the state but above all he was selling an image - the naval war hero, the glamorous wife, the kids, the homespun family with their little sailing boats.

Earlier politicians have had a "back-story" - log-cabins, Welsh cottages, you name it - but Kennedy was the first to sell his lifestyle.

Kennedy's father Joe, the former (and unfriendly) ambassador to Britain, had made his fortune in steel, movies, whisky, stocks and property.

With an obsession about building his family into a great political dynasty, he had squared many of the key newspaper owners for his son, who in turn was a master at flattering their reporters.

The Kennedy Clan Joseph and Rose Kennedy had nine children including four sons

Joe, a WWII bomber pilot, killed in action, 1944

John, elected president 1960, assassinated 22 Nov 1963

Bobby, assassinated while running for the Democratic presidential nomination, 6 June 1968

Ted, veteran US senator, elected in 1962 and serving till his death in 2009

He was ruthless and properly understood the rising power of the advertising companies - the world of Mad Men taking shape at the time.

As JFK later said, his father wanted to know the size of the eventual majority because "there was no way he was paying for a landslide".

Smear campaign

The Kennedy machine, an awesomely well organised instrument, had some obvious problems. Joe Kennedy was rumoured to have been a bootlegger, had been brought back to the US in 1940 having announced that "in Britain, democracy is finished", and was a close ally of Senator Joe McCarthy.

Above all, he was a Roman Catholic at a time of fierce anti-Catholic prejudice, including in the overwhelmingly Protestant West Virginia. Yet the Kennedys knew that if they could beat Humphrey and win there, they could win anywhere.

Hubert Humphrey loses the 1960 Democratic nomination to JFK

serves as vice-president under Lyndon Johnson, (1965-69)

wins Democratic nomination in 1968 but loses election to Republican Richard Nixon

Against them, Hubert Humphrey had a classic old-fashioned campaign. He had been too ill to fight in the war. His finances were meagre.

His wife was homely and old-fashioned. He had no private plane, but a bus - with a broken heater - instead.

He was one of the most intelligent, compassionate and literate politicians in modern American history, who had taken on Communists, organised crime and racialism when these were very dangerous fights to pick, and who understood middle America far better than Kennedy. But he was about to be crushed.

The Kennedy team dealt with their Catholic problem above all by smearing Humphrey as a draft-dodger. They saturated the state with advertising, money and helpers.

By the end, a stunned Humphrey, who had compared his fight to that of a corner store against a supermarket chain, was reduced to using the few hundred dollars he and his wife had saved for their daughter's education to pay for a final campaign ad.

Image caption The 1960 US Democratic Convention selects John F Kennedy as its presidential candidate.

Having smeared Humphrey and trashed his reputation, the Kennedys washed their hands and denied it all.

Well, you may say, that's politics. Kennedy went on, after all, to see off the grandees of the Democratic Party - Adlai Stevenson and the rising Texan, Lyndon Baines Johnson (who became his running mate) at the Democratic convention in LA.

Then he narrowly beat Richard Nixon after those famous televised debates when Nixon's heavier growth of beard, badly chosen suit and tendency to sweat persuaded viewers Kennedy was the better man.

When I met some of those involved, including Kennedy's TV adviser in 1960, I came away freshly awestruck by his presentational audacity.

For instance, in that first debate, Kennedy politely excused himself for a "comfort break" a minute before the two men were live on air. He did not come back.

As the studio manager was counting down the final seconds to going live, everyone - Nixon included - was aghast. Just as the count ended, there was Kennedy, smiling at the podium. "Psyching" an opponent doesn't get smarter than that.

Media playback is unsupported on your device Media caption The TV debates showed Kennedy calm and composed

And yet… Kennedy beat Nixon not simply with his ads, his sound bites, his jingles, the carefully posed photographs and the downright lies he told about his health. He beat Nixon by not standing for anything beyond rousing banalities.

On the "missile gap" with the Russians, Kennedy knowingly hyped the danger. Nixon, as vice-president, knew the real facts but also for reasons of national security, could not reveal them. (And Kennedy probably knew that, too.)

On the other great issue - civil rights - the Kennedy team sent one message to black audiences and another to middle America.

Ask not what your country can do for you... President John F Kennedy, Inauguration speech, 20 Jan 1961 LISTEN: Selected extracts of JFK speeches

Did it matter? I came away thinking the mix of big money, smearing, a feel-good blur where policy should have been, and the selling of the candidate like soap flakes, added up to a fairly shameful record.

Even then, he barely won. The younger Nixon, who was liberal on race and more economically mainstream than he became, could well have made a good earlier president.

In office Kennedy made some terrible overseas blunders (though kept his nerve over the Cuban missile crisis) and was slow on domestic policy, particularly civil rights. Had he lived longer, I think he would have had a lower presidential reputation.

The 1960 campaign is not the story I had expected. It's a far more interesting one. It has been obliterated by those images of the handsome young father and husband, then the young king cut down in his prime.

But today we live in a world that has become profoundly cynical about politics. I think we owe it to ourselves to look past those images and ask: aren't there better ways of doing democracy than Kennedy's?

Andrew Marr's JFK: The Making of Modern Politics is on BBC Two at 9pm on Sunday 21 November and then online via BBC iPlayer (UK only).