Vomiting foam simply is a mix of air and stomach/esophageal mucous made when he retches/vomits, it is not indicative of any disease process but tells us he is quite nauseous. The brown color can simply be the result of food dyes left over in his stomach.
Causes of vomiting include bacterial, viral or fungal infections, eating something he should not including a foreign body (rubber band, bones, or toy piece) or inflammatory bowel disease. Other possibilities are internal organ (kidney or liver) disease that cause a build up of waste products which the organs normally remove that can irritate the gastrointestinal tract leading to bleeding or pancreatitis. A gastrointestinal blockage or infiltrative cancers like lymphoma are possible as well.
Does he have a fever (rectal temperature greater then 103F)?
I would start with an acid reducing medication to try and settle his stomach. You can give either:
1)Pepcid ac (famotidine) at a dose one 10mg tablet per 10 to 20 kilos of body weight every 12 hours
2)Prilosec (omeprazole) at a dose of one 20mg tablet per 20 to 40 kilos of body weight every 24 hours.
3)Zantac (Ranitidine) at a dose of one half of a 75mg tablet per 17 to 35 kilos of body weight every 8-12 hours.
These are acid reducers which will decrease irritation of the stomach and esophagus and should help him feel better. They can be used for several days if need be.
Then I recommend a 12 to 24 hour food fast. Water is fine as he needs to stay hydrated but by taking away food we rest his gut and hopefully reset normal gut motions.
In 12 to 24 hours start a bland diet of 1/3 boiled, skinless, white meat chicken minced or boiled, very lean, ground beef mixed with 2/3 boiled, plain white rice or pasta. This is an easily digested bland diet and won't irritate his stomach and intestines. Feed the bland diet mix for several days until his nausea clears, then slowly start mixing in his regular diet. It should take about a week to convert him back, mixing a little more regular and less bland in each meal.
You can also give him probiotics to replace good bacteria in his gut. Fortiflora, Proviable, and Benebac are all very good and any of them can be used. Your veterinarian or many larger pet stores carry them.
If even with the acid reducing medication, his food fast, probiotics and bland diet he still is vomiting or refusing to eat he should be seen by a veterinarian. If he continues vomiting even with the acid reducing medication then he needs to see a veterinarian on an emergency basis, otherwise he will become dehydrated.
Please let me know if you have any further questions.