I'm not into Raphael that much buut you have the JS syntax wrong. Maybe this will help:
if (light.attr("fill") == "#ffffff" ){
light.animate({
fill: '#FFFF00'
}, 5000);
} else {
light.animate({
fill: '#ffffff'
}, 5000);
}
Hope this helps.