I want to know how a mad man could "legitimately" be elected as head of Germany.
This is a pretty big subject and I'm sure someone who has their thoughts in a better order than I can give you a comprehensive reply..
Basically you have to understand post WWI politics and the effects that the Treaty of Versailles had on Germany, effectively NSDAP and eventually Hitler gave them someone to blame and a cause that could make Germany into a country to be proud of again. Very effective propaganda and a very charismatic orator also helped to sway the people. At the same time remember that throughout Europe there was a general feeling of appeasement, no-one really wanted to get involved in another war.
Also keep in mind that although many people think the entire German public supported NSDAP/Nazi Party/Hitler this is not strictly true, there was a fair amount of political maneuvering to get Hitler to power.
I did a quick search and found these threads that have some interesting links:
http://www.reddit.com/r/AskHistorians/comments/2fd6gr/i_know_this_may_be_an_unpopular_idea_but_does/
http://www.reddit.com/r/AskHistorians/comments/1k24nl/how_did_hitler_win_over_the_whole_of_germany/
http://www.reddit.com/r/AskHistorians/comments/2b4ppi/history_of_germany_that_focuses_on_19291934/