// JavaScript Document

function init() {

	if(document.getElementById && document.createTextNode) {
		var menu = document.getElementById('menu');
		var anchors = menu.getElementsByTagName('a');
		for(var i=0, length=anchors.length;i<length;i++) {
			var returnId = anchors[i].id;
			if (returnId != "open") {
				anchors[i].onmouseout= function() {
					var spot = -1;
					this.setAttribute('spot', spot);
					this.style.backgroundPosition= '0px -80px';
				}		
				anchors[i].onmouseover= function() {
					var spot = 80;
					this.setAttribute('spot', spot);
				}
				animate();
			}
			else anchors[i].style.backgroundPosition= '0px 0px';			
		}
	}
}

function animate() {
	var menu = document.getElementById('menu');
	var anchors = menu.getElementsByTagName('a');
	
	for(var i=0, length=anchors.length;i<length;i++) {
		var returnId = anchors[i].id;
		if (returnId != "open") {
			var spot = anchors[i].getAttribute('spot');
			var pos = 0;
			if (spot>0) {
			  spot = spot - 2;
			  pos = 0 + spot;	  
			  if(spot<0) spot = 0;
			  anchors[i].style.backgroundPosition= '0px '+pos+'px';
			  anchors[i].setAttribute('spot', spot);
			}
		}
	}

  setTimeout(animate, 20);
}

window.onload=init;