In order to gain muscle, you need excess calories. In order to lose fat, you need less. So, chasing both goals at once can be a real pain- Most people choose one goal at a time and go after it with everything they've got- I recommend you do the same thing. And remember, while exercise is definitely important, it's only one third of the big picture- Eat, Train, and Rest- Those are the three keys to good results. Since you didn't mention anything about your diet in your post, I'm going to assume that's where you need the most work- Here's a thread to get you started, and make sure to follow the link at the end of the article.
http://www.discussbodybuilding.com/What_the_hell_is_a_calorie_anyway/m_135283/tm.htm