// JavaScript Document
var animate = new Array();
var interval;
//var debug;

function init(){
	var td = document.getElementById("links").getElementsByTagName("td");
	for(var x = 1; x <= td.length; x++){
		animate[x] = new Array();
		animate[x]['object'] = td[x-1];
		animate[x]['animate'] = "none";
	}
	//debug = document.getElementById("debug");
	addEvents();
}

function addEvents(){
	for(var x = 1; x < animate.length; x++){
		animate[x]['object'].onmouseover = function(){
			for(var x = 1; x < animate.length; x++){
				if(animate[x]['object'] == this){
					animate[x]['animate'] = "show";
				}
			}
		}
		animate[x]['object'].onmouseout = function(){
			for(var x = 1; x < animate.length; x++){
				if(animate[x]['object'] == this){
					animate[x]['animate'] = "hide";
				}
			}
		}
	}
	
	interval = window.setInterval("checkAnimation()", 20);
}

function checkAnimation(){
	var steps = 50;
	
	for(var x = 1; x < animate.length; x++){
		switch(animate[x]['animate']){
			case 'show':
				var obj = document.getElementById("hover"+x);
				if(document.all){
					if(obj.style.filter == ""){
						obj.style.filter = "Alpha(opacity="+(100/steps)+")";
					}else{
						if(parseInt(obj.style.filter.substr(14, obj.style.filter.length-14)) < 100){
							var opacity = parseInt(obj.style.filter.substr(14, obj.style.filter.length-14)) + 100/steps;
							obj.style.filter = "Alpha(opacity="+opacity+")";
						}else{
							animate[x]['animate'] = "none";
						}
					}
				}else{
					if(obj.style.MozOpacity == "" || obj.style.opacity == ""){
						obj.style.MozOpacity = 1/steps;
						obj.style.opacity = 1/steps;
					}else{
						if(parseFloat(obj.style.MozOpacity) < 1 || parseFloat(obj.style.opacity) < 1){
							obj.style.MozOpacity = parseFloat(obj.style.MozOpacity) + 1/steps;
							obj.style.opacity = parseFloat(obj.style.opacity) + 1/steps;
						}else{
							animate[x]['animate'] = "none";
						}
					}
				}
			break;
			case 'hide':
				var obj = document.getElementById("hover"+x);
				if(document.all){
					if(parseInt(obj.style.filter.substr(14, obj.style.filter.length-14)) > 0){
						var opacity = parseInt(obj.style.filter.substr(14, obj.style.filter.length-14)) - 100/steps;
						obj.style.filter = "Alpha(opacity="+opacity+")";
					}else{
						animate[x]['animate'] = "none";
					}
				}else{
					if(parseFloat(obj.style.MozOpacity) > 0 || parseFloat(obj.style.opacity) > 0){
						obj.style.MozOpacity = parseFloat(obj.style.MozOpacity) - 1/steps;
						obj.style.opacity = parseFloat(obj.style.opacity) - 1/steps;
					}else{
						animate[x]['animate'] = "none";
					}
				}
			break;
		}
	}
}

function highlight(obj){
	var image = obj.src;
	
	image = image.substr(0, (image.length - 5))+"h"+image.substr((image.length - 4), 4);
	obj.src = image;
}

function normal(obj){
	var image = obj.src;
	
	image = image.substr(0, (image.length - 5))+"n"+image.substr((image.length - 4), 4);
	obj.src = image;
}