From what I can remember, all four founders of Hogwarts were friends, including Godric and Salazar. When the school first began, each of the four headmaters would personally choose the students that they wanted in thier houses. I'm sure the Ravenclaw guy was an intelectuall, so he probably preffered to choose the smarter kids. Godric Gryfindor admired bravery, so he chose the bravest students to be in his house. And so on.
At some point, Salazar had a disagreement with the other three wizards because he felt that Hogwarts should only accept pureblood wizards.
Later on, the four wizards accepted that they would someday die, and they realized that somebody else would have to sort the student's into houses because they would no longer be around. So Godric Gryfindor put a spell on his hat to make it intelligent. This is what the sorting hat is. Then the four wizards were able to choose what traits they wanted in thier houses, and the hat would then choose whichever house that would best suit the personality of the student.
Godric put his sword in the hat and presumably, the other wizards probably put items in the hat too.
I don't really think that Salazar was a bad guy, just that he had old fashioned beliefs and felt that Hogwarts would be more efficient with only pureblood students. Godric and Salazar may have even been quite close, but this idea was obviously quite important to Salazar, and when Godric disagreed with it, their friendship probably started to weaken and Salazar probably started to become more and more isolated.
While it was not originally intended for Gryfindor and Slytherin to compete, that was what ended up happening anyway.
In the fifth book (I think) the Sorting Hat sings a song that explains (to a degree) what happened. I feel like re-reading that part now
![:lol:](./images/smilies/lol.gif)