could be the interlock control assembly or the shift lock solenoid... it sounds like you have some electrical issues going on though.... I hate to say this but if you just bought the car, did you get any kind of vehicle history report on it... it's a stretch but do you have any other weird electrical issues or moisture anywhere like head/tail lights? It just seems weird that your headlights would play into the mix