Could be a bad battery or alternator. This would mean your car is not getting enough power distribution. If your sure everything is connected right and grounded properly have your charging system and battery tested.
probably.and would the idle problem be that the cars idle memory was wiped when the battery was unplugged?