/* Add delay to top nav drop down */
	function attachHooks() {
		var menu = document.getElementById('navbar');
			if (menu != null) {  //Check if null solves issue with navbar not existing on classic modalwindow template
				var menuItems = menu.getElementsByTagName('li');
				var thisSubMenu;
				
				for (var i=0; i<menuItems.length; i++)
				{
					menuItems[i].onmouseover = function() {activateMenuWithDelay();};
					menuItems[i].onmouseout = function() {deactivateMenuWithDelay();};
				}
			}
	}
	
	function activateMenuWithDelay() {
		var menu = document.getElementById('navbar');
			if (menu != null) {
				if (menu.timer) {
					clearTimeout(menu.timer);
				}
				menu.timer = setTimeout("activateMenu()", 400);
			}
	}
	
	function activateMenu() {
		var menu = document.getElementById('navbar');
			if (menu != null) {
				menu.setAttribute('class', 'activeMenu');
			}
	}
	
	
	function deactivateMenu() {
		var menu = document.getElementById('navbar');
			if (menu != null) {
				menu.setAttribute('class', 'inactiveMenu');
			}
	}
	
	function deactivateMenuWithDelay() {
		var menu = document.getElementById('navbar');
			if (menu != null) {
				if (menu.timer) {
					clearTimeout(menu.timer);
				}
				menu.timer = setTimeout("deactivateMenu()", 500);
			}
	}
	
	function addLoadEvent(func) {
		  var oldonload = window.onload;
		  if (typeof window.onload != 'function') {
			window.onload = func;
		  } else {
			window.onload = function() {
			  oldonload();
			  func();
			}
		  }
	}
	
	addLoadEvent(attachHooks);
	addLoadEvent(deactivateMenu);
	
/* Code to all hover dropdown for IE6 - Currently used for country nav and top navigation dropdown */
//Conditional to put script in IE6 browsers
var isIE6 = (navigator.userAgent.toLowerCase().substr(25,6)=="msie 6") ? true : false;

if (isIE6 == true ) {

	// JS used to make 
	
	function sfHover(element_id) {
		  var sfEls = document.getElementById(element_id).getElementsByTagName("li");
		  for (var i=0; i<sfEls.length; i++) {
              sfEls[i].onmouseover=function() {
                 this.className+=" sfhover";
              }
              sfEls[i].onmouseout=function() {
                 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    	}
 	  }
	}
// Add the IDs that you want to use the hover function below - CSS must have a hover "sfhover" class too
	function sfStart() {
	  sfHover("navbar");
	}
	if (window.attachEvent) window.attachEvent("onload", sfStart);
}

/*Killer OO JS Menu Script by Pete Smith Version 1.2*/

var menu_script_loaded = true;

function Menu(label){
	this.items = new Array();
	this.actions = new Array();
	this.codes = new Array();
	//Now, make the container of menus
	//Automatically add it to the array of menus
    this.label = label;
	//methods for this object
	this.html = Html;
	this.addMenuItem = addMenuItem;
	this.showMenu = showMenu;
	this.hideMenu = hideMenu;
}

function addOmnitureCode(txt) {
	 var s =s_gi(s_account);  
	s.linkTrackVars='prop36';
//	s.linkTrackEvents='event56';
	
	s.prop36= domain + "_" + txt; //please pick appropriate value from the spreadsheet
	//s.events='event56';
	s.tl(this,'o','Redirects Cookie');
}

function Html(){
	var output = new String();
	output += '<div id="'+this.label+'" class="menu_lay" onmouseover="thisMenu.showMenu()" onmouseout="thisMenu.hideMenu()">';
   if (this.actions.length > 1) {
      for (var i=0; i < this.actions.length; i++){ 
         output += '\n<div class="menuitem" onmouseover="onMenuItemOver(this)" onmouseout="onMenuItemOut(this)" onclick="location.href=\''+this.actions[i]+'\';addOmnitureCode(\''+this.codes[i]+'\')">';
     		output += '&nbsp;<a href="'+ this.actions[i]+ '">';
     		output += this.items[i] + '</a>&nbsp;';
     		output += '</div>\n';
     	}
   } else {
     output += '\n<div class="info_lay">'+this.items[0]+'</div>';
   }
	output += '</div>\n\n';
return output;
}


function addMenuItem(label, action, code) {
    this.items[this.items.length] = label;
    this.actions[this.actions.length] = action;
	this.codes[this.codes.length] = code;
}

function fireMenu( menu_id, thisLink, orient ) {
	thisMenu = window.menus[menu_id];
	thisLink.onmouseout = function(){  thisLink.style.backgroundColor=''; thisMenu.hideMenu();}
	hideAllMenus();
	thisMenu.showMenu();
	positionMenu(thisLink,orient);
	
	//DD detection Section
	//Now we get the rendered position coords, and attach to the object.
	thisMenu.coords = getMyCoords(document.getElementById(thisMenu.label));
	//Now we loop over all, attaching coords only if IE
 if (document.all) {
      for (var i in document.all){
      if (document.all[i].type == "select-one" || document.all[i].type == "select-multiple") {
         document.all[i].coords = getMyCoords(document.all[i]);
             if ( doICollide (thisMenu , document.all[i]) ) {
                 hideObject(document.all[i]);
             }
         }
      }
    }
}

function showHiddenDD(){
   if (document.all){
      for (var i in document.all){
         if (document.all[i].type == "select-one" || document.all[i].type == "select-multiple" && document.all[i].style.visibility == "hidden") {
            showObject(document.all[i]);
         }
      }
   }
}

function hideObject(hideObject){
    hideObject.style.visibility = "hidden";
}

function showObject(showObject){
    showObject.style.visibility = "visible";
}


function getMyCoords(getObject){
   coords = new Object();
   coords.width = getObject.offsetWidth;
   coords.height = getObject.offsetHeight;
   coords.oLeft = getPageOffsetLeft(getObject);
   coords.oTop = getPageOffsetTop(getObject);
   return coords;
}

function doICollide(object1 , object2) {
    //First we find out if the A coord is within the object2.
    if (object1.coords.oLeft < object2.coords.oLeft + object2.coords.width && object2.coords.oLeft < object1.coords.oLeft + object1.coords.width ) {
        if (object1.coords.oTop < object2.coords.oTop + object2.coords.height && object2.coords.oTop < object1.coords.oTop + object1.coords.height ) {
            return true;
        }
    }
}

function positionMenu(thisObject,orient){
//Get x and y position of the link
	coords = getMyCoords(thisObject);
//Now calculate the Height and Width
	linkHeight = thisObject.offsetHeight;
	linkWidth = thisObject.offsetWidth;
	switch(orient) {
		case "r":
			oLeft = coords.oLeft + linkWidth;
			oTop = coords.oTop;
		break;
		default:
			oLeft = coords.oLeft;
			oTop = coords.oTop + linkHeight;
		break;
	}
	//Now we position the menu
	document.getElementById(thisMenu.label).style.left = oLeft + "px";
	document.getElementById(thisMenu.label).style.top = oTop + "px";
    //We only want to position to left edge of block level elements, and only handles the shorties.
    if ( thisObject.tagName != "A" && document.getElementById(thisMenu.label).offsetWidth < thisObject.offsetWidth ) {
	    document.getElementById(thisMenu.label).style.width = thisObject.offsetWidth + 15;
    }

}

function hideAllMenus(){
	for (i=0; i<window.menus.length; i++) {
		document.getElementById(window.menus[i].label).style.display = "none";
	}
	showHiddenDD();
}

function showMenu(){
	if (window.hideMenuTimer) window.clearTimeout(hideMenuTimer);
	document.getElementById(thisMenu.label).style.display = "block";
}

function hideMenu(){
	hideMenuTimer = setTimeout("document.getElementById('"+thisMenu.label+"').style.display = 'none'; showHiddenDD();",850);
}


function onMenuItemOver(thisMenuItem){
	thisMenuItem.className = "menuitem_hover";
}

function onMenuItemOut(thisMenuItem){
	thisMenuItem.className = "menuitem";
}

function addMenu(menu){
	//The array that holds the menu objects is menus
	if (!window.menus) window.menus = new Array();
		window.menus[menu.label] = menu;
		window.menus[window.menus.length] = menu;
		
}

function makeMenus(){
	if (!document.getElementById("menuContainer")){
		container = document.createElement("DIV");
		container.id = "menuContainer"
	}
document.body.appendChild(container) ;
//Now, put our nice html in da laya playa.
  container.innerHTML = complete_html;
}

function printMenus(){
var h = new String();
	for (var i=0; i<window.menus.length; i++) {
		h += window.menus[i].html();  
	}
return h;
}


/* Top Navigation Rollover Delay - Works with jQuery hoverIntent 
$(document).ready(function() {
						   
$("ul#navbar").addClass("inactiveMenu");						   
						   
//On Hover Over
function megaHoverOver(){
    $(this).addClass("activeMenu");
	$(this).removeClass("inactiveMenu");
}
//On Hover Out
function megaHoverOut(){
	$(this).removeClass("activeMenu");
  	$(this).addClass("inactiveMenu");
}

//Set custom configurations
var config = {
     sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)
     interval: 200, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};

$("ul#navbar").hoverIntent(config); //Trigger Hover intent with custom configurations

});

*/