Contests vs. Gambling (wheres the line drawn)

Lets say there was a contest with an entry fee, and the entry fee went towards the prize money.

Is that considered Gambling? Or illegal?

Sort of like but with them you are buying credits to enter into the contest. and there is a predertemined prize number.