Electrical problem on Diesil Passat

On parking up,Parking light flashes and braking does not come on,so we are having to leave it in gear.There are occassions when this is not possible.So i have to dissconnect the battery,then reattache, then it will work for a time untill it decides to do it again.

Any ideas appreciated.