// JavaScript Document

var animation_up;

var ID;

var last_element;
var last_submenu;
var last_submenu_up;

var down_actual_value;
var down_element;
var down_ID;
var down_step;
var down_stop_value;

var up_actual_value;
var up_element;
var up_ID;
var up_step;
var up_stop_value;

function isIE () {

	if (navigator.appName=="Microsoft Internet Explorer") {
		return true;
	} 
	return false;
}

function click_submenu(evt,id) {

	if (isIE()) {
		element = event.srcElement.parentElement.parentElement.parentElement;
	    clearInterval(ID);
		clearInterval(up_ID);
		clearInterval(down_ID);
	} else {
		element = evt.target.parentNode.parentNode.parentNode;
	}

	if (last_submenu==id) {
		if (last_submenu_up) {
			last_submenu_up = false;
			hide_submenu(id);
			last_element.style.backgroundImage= "url(/img/backgrounds/bg_button.gif)";
			last_element.style.color= "#FFFFFF";
		} else {
			last_submenu_up = true;
			show_submenu(id);
			element.style.backgroundImage= "url(/img/backgrounds/bg_button_on.gif)";
			element.style.color= "#990000";
		}
	} else {
		last_submenu_up = true;
		show_hide_submenu(last_submenu , id);
		if (last_element) {
			last_element.style.backgroundImage= "url(/img/backgrounds/bg_button.gif)";
			last_element.style.color= "#FFFFFF";
		}
		element.style.backgroundImage= "url(/img/backgrounds/bg_button_on.gif)";
		element.style.color= "#990000";
	}
	last_submenu = id;
	last_element = element;
}

function show_hide_submenu(last_submenu, id) {

	if (last_submenu) {
		var lastElement;
		var newElement;
		var colSubmenu = document.getElementsByTagName("div");

		for (i=0; i<colSubmenu.length;i++) {
			if (colSubmenu.item(i).id==last_submenu) {
				colSubmenu.item(i).style.display="none";
				lastElement = colSubmenu.item(i);
			}
			if (colSubmenu.item(i).id==id) {
				colSubmenu.item(i).style.display="inline";
				newElement = colSubmenu.item(i); 
			}
		}
		if (isIE()) {animation_change_opacity2(newElement, 60, 1, lastElement, 0, 1);}
	} else {
		show_submenu(id);
	}
}

function show_submenu(id) {

	var colSubmenu = document.getElementsByTagName("div");

	for (i=0; i<colSubmenu.length;i++) {
		if (colSubmenu.item(i).id==id) {
			colSubmenu.item(i).style.display="inline";
			if (isIE()) {animation_change_opacity(colSubmenu.item(i), 60, 1, true);}
		}
	}
}

function hide_submenu(id) {
	
	var colSubmenu = document.getElementsByTagName("div");

	for (i=0; i<colSubmenu.length;i++) {
		if (colSubmenu.item(i).id==id) {
			colSubmenu.item(i).style.display="none";
		if (isIE()) {animation_change_opacity(colSubmenu.item(i), 0, 1, false);}
		}
	}
}

function animation_change_opacity2(lup_element, lup_stop_value, lup_step, ldown_element, ldown_stop_value, ldown_step) {
	
	up_actual_value = lup_element.filters.alpha.opacity;
	up_element = lup_element;
	up_step = lup_step;
	up_stop_value = lup_stop_value;
	
	down_actual_value = ldown_element.filters.alpha.opacity;
	down_element = ldown_element;
	down_step = ldown_step;
	down_stop_value = ldown_stop_value;
	
   	ID = setInterval("change_opacity2()", 10)
}

function change_opacity2() {

	up_actual_value = up_actual_value + up_step;
	up_element.filters.alpha.opacity = up_actual_value;
	down_actual_value = down_actual_value - down_step;
	down_element.filters.alpha.opacity = down_actual_value;
	if (up_actual_value > up_stop_value) {
	    clearInterval(ID);
	}
}


function animation_change_opacity(element, stop_value, step, up) {
	
	if (up) {
		up_actual_value = element.filters.alpha.opacity;
		up_element = element;
		up_step = step;
		up_stop_value = stop_value;
		animation_up = up;
    	up_ID = setInterval("change_opacity()", 10)
	} else {
		down_actual_value = element.filters.alpha.opacity;
		down_element = element;
		down_step = step;
		down_stop_value = stop_value;
		animation_up = up;
    	down_ID = setInterval("change_opacity()", 10)
	}
}

function change_opacity() {

	if (animation_up) {
		up_actual_value = up_actual_value + up_step;
		up_element.filters.alpha.opacity = up_actual_value;
		if (up_actual_value > up_stop_value) {
		    clearInterval(up_ID);
		}
	} else {
		down_actual_value = down_actual_value - down_step;
		down_element.filters.alpha.opacity = down_actual_value;
		if (down_actual_value < down_stop_value) {
		    clearInterval(down_ID);
		}
	}
}

function menuOver(evt) {

	if (isIE()) {
		evt.srcElement.style.fontWeight="bold";
	} else {
		evt.target.style.fontWeight="bold";
	}
}

function menuOut(evt) {

	if (isIE()) {
		evt.srcElement.style.fontWeight="normal";
	} else {
		evt.target.style.fontWeight="normal";
	}
}
	