Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Restore your phone and don't jailbreak it again. That will be sure to fix the issue. You downloaded some type adware.

It is generally a bad idea to jailbreak your phone if you are not sure what you are doing.
 
are you sure it's the built-in messages app?
and you didn't replace it with some other "alternative"?
 
jailbreak and use pirated versions of FULL PAID apps you find in the AppStore for free from Installous
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.