//window.onload=init;

function init() {
	
	

	if(document.getElementById && document.createTextNode) {
		//please wait on forms
		var menu = document.getElementById('animatedtabs');
		var anchors = menu.getElementsByTagName('a');
		var spans = menu.getElementsByTagName('span');
		for(var i=0, length=anchors.length;i<length;i++) {
			anchors[i].onmouseover= function() {			
				var spot = 5;
				this.setAttribute('spot', spot);
				this.style.backgroundPosition= '0px 0px';				
			}
			anchors[i].onmouseout= function() {
				var spot = 0;
				this.setAttribute('spot', spot);
			}
			
			spans[i].onmouseover= function() {
				var spot = 5;
				this.setAttribute('spot', spot);
				this.style.backgroundPosition= '100% 0px';				
			}
			spans[i].onmouseout= function() {
				var spot = 0;
				this.setAttribute('spot', spot);
			}
			
		}
		animate();
	}
}

function animate() {
	var menu = document.getElementById('animatedtabs');
	var anchors = menu.getElementsByTagName('a');
	var spans = menu.getElementsByTagName('span');
	for(var i=0, length=anchors.length;i<length;i++) {
		var spot = anchors[i].getAttribute('spot');
		if (spot>0) {
			spot = spot - 1;
			if(spot<0) spot = 0;
			anchors[i].style.backgroundPosition= '0px ' + spot+'px';
			anchors[i].setAttribute('spot', spot);
			
			spans[i].style.backgroundPosition= '100% ' + spot+'px';
			spans[i].setAttribute('spot', spot);
		}
	}

	setTimeout(animate, 1);
}
