var interval = 1;
var jump = 3;
var doing = new Array();
function navSetup() {
	if(document.getElementById("menu")) {
		var all = document.getElementById("menu").getElementsByTagName("div");
		for(x in all) {
			if(all[x].className == "menu_item_hover_main") {
				all[x].style.opacity = "1";
				all[x].style.filter = "alpha(opacity=100)"; 
			}
			else if(all[x].className == "menu_item_hover_hover") {
				all[x].style.opacity = "0";				
				all[x].style.filter = "alpha(opacity=0)"; 
			}
		}
	}
}

function navFade(item, type) {
	var both = item.getElementsByTagName("span");
	for(x in both) {
		if(both[x].className == "menu_item_text") {
			var section = both[x].id;
		}
	}
	doing[section] = type;
	if(type == 0) {
		setTimeout("navFadeTimer('"+section+"',0)", interval);
	}
	if(type == 1) {
		setTimeout("navFadeTimer('"+section+"',1)", interval);
	}
}

function loginShow() {
	var box = document.getElementById("menu_login_popout");
	box.style.display = 'block';
	section = "login";
	doing[section] = 0;
	setTimeout("navFadeTimer('"+section+"',0)", interval);
}
function loginHide() {
	section = "login";
	doing[section] = 1;
	setTimeout("navFadeTimer('"+section+"',1)", interval);
}

function navFadeTimer(section, type) {
	var item = document.getElementById(section).parentNode;
	if(item.id != "menu_item_current") {
		var both = item.getElementsByTagName("div");
		for(x in both) {
			if(both[x].className == "menu_item_hover_main") {
				var main = both[x];
			}
			else if(both[x].className == "menu_item_hover_hover") {
				var hover = both[x];
			}
		}
		var mainopac = parseInt(main.style.opacity * 100);
		var hoveropac = parseInt(hover.style.opacity * 100);
		if(type == 0) {
			if(mainopac <= '0' && hoveropac >= '100') {
				main.style.opacity = '0';
				main.style.filter = "alpha(opacity=0)";
				hover.style.opacity = '1';
				hover.style.filter = "alpha(opacity=100)";
			}
			else {
				if(doing[section] == type) {
					main.style.opacity = (mainopac - jump)/100;
					main.style.filter = "alpha(opacity=" + (mainopac - jump) + ")";
					hover.style.opacity = 1 - main.style.opacity;
					hover.style.filter = "alpha(opacity=" + (100 - (mainopac + jump)) + ")";
					if(section == "login") {
						var box = document.getElementById("menu_login_popout");
						box.style.opacity = hover.style.opacity;	
						box.style.filter = hover.style.filter;
					}
					setTimeout("navFadeTimer('"+section+"',0)", interval);
				}
			}
		}
		if(type == 1) {
			if(mainopac >= '100' && hoveropac <= '0') {
				main.style.opacity = '1';
				main.style.filter = "alpha(opacity=100)";
				hover.style.opacity = '0';
				hover.style.filter = "alpha(opacity=0)";
				if(section == "login") {
					var box = document.getElementById("menu_login_popout");
					box.style.display = 'none';
				}
			}
			else {
				if(doing[section] == type) {
					main.style.opacity = (mainopac + jump)/100;
					main.style.filter = "alpha(opacity=" + (mainopac + jump) + ")";
					hover.style.opacity = 1 - main.style.opacity;
					hover.style.filter = "alpha(opacity=" + (100 - (mainopac + jump)) + ")";
					if(section == "login") {
						var box = document.getElementById("menu_login_popout");
						box.style.opacity = hover.style.opacity;	
						box.style.filter = hover.style.filter;
					}
					setTimeout("navFadeTimer('"+section+"',1)", interval);
				}
			}
		}
	}
}