I had the exact same problem a while ago, and fixed it relatively easily. The problem in my case was that I was using an aftermarket power cord/supply that provided the wrong wattage. Your computer should be using an 85W supply (based on this link from Apple). Check the power brick to see if you may be using a 60W supply, like I was. Replacing it with an 85 Watt one should fix the problem if this is it. If that doesn't work, check out this link where there is a long discussion about fixing this problem.