It seems as though your betta may have ammonia poisoning.
I mistakenly gave my betta fish ammonia poisoning too. It can happen if you put your betta into a tank before it has "cycled". An un-cycled fish tank means that there is not enough GOOD bacteria in the tank to get rid of all your fishes poop. The poop is what creates all the ammonia that is poisoning your little fishie. I made this same mistake, not knowing enough about my betta before I bought it.
The only thing you can really do, is buy a test kit and do LOTS of water changes. You should consider doing as much as 10% each day if you can.
Eventually you will see the ammonia levels in your tank lower as the beneficial bacteria begins to grow.
Unfortunately, the battle is not over once you get rid of the ammonia. Mr. Betta will also experience nitrite poisoning. When your ammonia levels finally go down, your nitrite levels will start to rise. High nitrite levels are also very harmful to your fish. Continue doing lots of water changes and eventually (and slowly i might add) these nitrites will turn into nitrates (that's nitrate with an "A" not an "I"). When you have nitrate in your tank you are in the clear.
I have had my betta for a month now, and my 2 gallon tank has still not cycled.
At first my poor fish just lay on the bottom of the tank and was not very active. After about a week (even though he still had poisoning), he started becoming much more active.
Now he is flourishing. He swims through his plants, goes in and out of his cave, and dances whenever he thinks he is getting food.
Don't feel too bad if you didn't know about cycling. Many first time fish owners have never even heard of it (and neither have people in the pet store).
Good luck with your fish! I'm sure he will pull through. They are very tough little guys.
Remember to feed him a varied diet of pellets, flakes and bloodworms for treats!