I have this code:
You're looking for the style property on the element, there is no background-color attribute:
background-color
document.getElementById("pic1").style.backgroundColor = "red";
That said, generally best to style things with CSS and add/remove classes.