Ysf.Dom.quiet = true;

var browser = navigator.appName;

PanelMenu = {
   timers: new Array (),
   elements: new Array (),
   
   offsetX: {'header': 0, 'main': -10, 'default': 1, 'sub': 0, 'bottom':4},
   offsetY: {'header': 32, 'main': 0, 'default': 0, 'sub': 29, 'bottom':20},
   
   enter: function (el) {
      var c = $child(el, 'ul');
      
     if (el.parentNode.parentNode.tagName.toLowerCase () == 'li') 
	{
         this.hold(el.parentNode.parentNode);
      }

      if (c) 
{
		c.style.display = 'block';

        	var r = el.parentNode.parentNode.parentNode;

         	var orientation = 'default';
         	if (r.tagName.toLowerCase () == 'map' && r.id == 'root-nav') 
		{
         		orientation = 'header';
			c.style.top = px(el.offsetTop + this.offsetY[orientation]);
	     		c.style.left = px(this.offsetX[orientation]);
        	} 
		else if ($ancestor (el, 'map').id == 'main-nav') 
		{
            	orientation = 'main';
			c.style.top = px(this.offsetY[orientation]);
	     		c.style.left = px(this.offsetX[orientation]);
		}
		else if ($ancestor (el, 'map').id == 'bottom-nav') 
		{
           		orientation = 'bottom';
			c.style.bottom = px(this.offsetY[orientation]);
	     		c.style.left = px(this.offsetX[orientation]);
         	}
		else
		{
			c.style.top = px(this.offsetY[orientation]);
	     		c.style.left = px(this.offsetX[orientation]);
		}
	}
   },
   
   hold: function (el) {
      if (this.timers[el.id]) {
         clearTimeout(this.timers[el.id]);
      }
      if (el.parentNode.parentNode.tagName.toLowerCase () == 'li') {
         this.hold(el.parentNode.parentNode);
      }
   },
   
   exit: function (el) {
      this.elements[el.id] = el;
      this.timers[el.id] = setTimeout('PanelMenu.close(\'' + el.id + '\')', 200);
   },
   
   close: function (id) {
      el = this.elements[id];
      var c = $child(el, 'ul');
      if (c) {
         c.style.display = 'none';
      }
   }
};

var showhidetimer = "undefined";
 
function showsubhilite(divId){
	var i;
	var divElement = document.getElementById(divId);
	divElement.style.display = "block";
}

function hidesubhilite(divId){
   var i;
   var divElement = document.getElementById(divId); 
   divElement.style.display = "none";
}

function hidesubhilitewithdelay(divId){
	showhidetimer = setTimeout('hidesubhilite(\'' + divId + '\')', 200)
}

function clearhide(){
	clearTimeout(showhidetimer);
}

// Show the submenu
function showSub(name)
{

	for (var i = 1 ; i <= 5; i++)
	{
		document.getElementById('menu_' + i).style.display = 'none'; 

	}
	
	// Show the submenu of clicked topmenuitem hide the breadcrumb
	if(document.getElementById('menu_' + name))
	{
		document.getElementById('menu_' + name).style.display = 'block';
		
		var screenWidth = document.getElementById('mainMenu').offsetWidth;
		var menuWidth = document.getElementById('menu_' + name).offsetWidth;
		
		if(screenWidth - menuWidth > 2)
		{
			var spaceBothSides = (screenWidth - menuWidth) / 2;
			document.getElementById('menu_' + name).style.left = spaceBothSides-12 + 'px'; 
		}
		document.getElementById('crumbPath').style.display = 'none';
	}
	
}


