// |||||||||||||||||||||||||||||||||||||||||||||||||| SIMPLE MENU SCRIPT

Menu = {timer : null, current : null};
Menu.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menu.show = function(name, rellink){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).visibility = "visible";
	this.current = name;
	
	setupMenu(name, rellink);

}
Menu.hide = function(){
	this.timer = setTimeout("Menu.doHide()",100);
}
Menu.doHide = function(){
	if(this.current){
		this.getStyle(this.current).visibility = "hidden";
		this.current = null;
		resetMenu();
	}
}

// |||||||||||||||||||||||||||||||||||||||||||||||||| END SIMPLE MENU SCRIPT

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

var curSubMenu = null;
var curSubMenu_link = null;

function setupMenu(men_id, men_rellink) {
	
	var menu = document.getElementById(men_id);
	var link_el = document.getElementById(men_rellink);
	
	menu.style.left = getPageOffsetLeft(link_el) + "px";
	menu.style.top = (getPageOffsetTop(link_el) + 17) + "px";
	
	// hilite product menu link
	link_el.style.color = "#99A6F7";
	
	showSubMenu()
}

function resetMenu() {

	var productmenu = document.getElementById("productmenu");
	var products_link_el1 = document.getElementById("products_link_el");
	var products_link_el2 = document.getElementById("sale_link_el");
	
	products_link_el1.style.color = "white";
	products_link_el2.style.color = "white";
	
	productmenu.style.width = "200px"
	productmenu.style.visibility = "hidden"

	resetSubMenu();
		
}

function resetSubMenu() {

	if (curSubMenu!=null) {
		curSubMenu_link.style.backgroundImage = ""
		curSubMenu_link.style.backgroundColor = "#333A65"
		curSubMenu.style.visibility = "hidden";
		curSubMenu.style.width = "0px";
	}
}

function showSubMenu(el) {
	
	resetSubMenu();
	
	mainmen_el = document.getElementById("productmenu");
	curSubMenu = document.getElementById(el);
	curSubMenu_link = document.getElementById(el + "_link")
	
	mainmen_el.style.width = 400 + "px"
	
	curSubMenu.style.width = "200px";
	curSubMenu.style.visibility = "visible";
	curSubMenu_link.style.backgroundColor = "#495286"
	curSubMenu_link.style.backgroundImage = "url('../images_site/i_p-mainnav_item_back.gif')"
}
