window.onload = initAll;
function initAll(){
var tds = document.getElementById("myTR").getElementsByTagName("td");
for(var i=0; i< tds.length; i++){
tds.onmouseover = doThis;
tds.onmouseout = undoThis;
}
}
function doThis(){
var element = document.getElementById(this.id);
switch(this.id){
case "td1":
element.blahblah = something; // do stuff related to the element here
break;
default:
//default
break;
}
//code related globally
}
function undoThis(){
//here change the background to default
}