The fish's behavior you describe is an indication that the fish is suffering from a condition called Swim Bladder Disorder (SBD). The swim bladder is the organ a fish has that enables it to swim upright, swim up and down and maintain it's bouyancy at will. When the swim bladder becomes blocked, enlarged or infected it ceases to function properly. The most common treatment for SBD is to feed peas canned or parboiled frozen peas without the husk. The peas can sometimes help to clear out the swim bladder. Feed 2-3 peas twice a day.
It's also possible that the swim bladder is infected in which case a medicine such as Maracyn -2 can help (see link below).
So what I suggest you do is use the pea diet for 4-5 days. If after 5 days no improvement is seen then try administering the Maracyn 2. If you are outside of the USA then listed below is a link to a medicine that is more easily accesible called
Interpet Swim Bladder 100ml.
Listed below I have also placed a link which will give you additional information re: SBD. Please keep in mind that SBD can be difficult and sometimes impossible to cure. Good luck and please let me know if you have any questions. http://www.drsfostersmith.com/product/prod_display.cfm?c=3578+4615+4842&pcatid=4842