// JavaScript Document

function initLiHover() {
	var elements = document.getElementById("wrapper_header").getElementsByTagName("li");
	var idx = 0;
	
	for (idx = 0; idx < elements.length; idx++) {
		elements[idx].onmouseover = function() {this.className += " hover";}
		elements[idx].onmouseout = function() {this.className = this.className.replace(new RegExp(" hover\\b"), "");}
	}	
}

function initRollovers() {
   var all_links;
   var link;
   var idx;

   if (!document.getElementsByTagName) {
      return;   
   }
   
   all_links = document.getElementsByTagName("a");
   
   for (idx = 0; idx < all_links.length; idx++) {
      link = all_links[idx];
	  
	  if (link.className && (' ' + link.className + ' ').indexOf(' rollover ') != -1) {
	     if (link.childNodes && link.childNodes.length == 1 && (link.childNodes[0].nodeName.toLowerCase() == 'img' || link.childNodes[0].nodeName.toLowerCase() == 'input')) {
			  
			// Pre-load state 2 images
			tmp_image = new Image();
			tmp_image.src = link.childNodes[0].src.replace(/(\.[^.]+)$/, "_f1$1");
				
	      link.onmouseover = mouseover;
			link.onmouseout = mouseout;
			link.onfocus = mouseover;
			link.onblur = mouseout;
		 }
	  }
   }
}

function findTarget(e) {
	var target;
	
	if (window.event && window.event.srcElement) {
		target = window.event.srcElement;
	}
	else if (e && e.target) {
		target = e.target;	   
	}
	
	if (!target) return null;
	
	while (target != document.body && target.nodeName.toLowerCase() != "a") {
		target = target.parentNode;   
	}
	
	if (target.nodeName.toLowerCase() != "a") return null;
	
	return target;
}

function mouseover(e) {
	var target = findTarget(e);
	var img_tag;
	
	if (!target) return;
	
	img_tag = target.childNodes[0];
	
	if (img_tag.src.indexOf("_f1.") < 0) img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, "_f1$1"); 
}

function mouseout(e) {
	var target = findTarget(e);
	var img_tag;
	
	if (!target) return;
	
	img_tag = target.childNodes[0];
	img_tag.src = img_tag.src.replace(/_f1(\.[^.]+)$/, "$1");   
}

function initPage() {
	initRollovers();
	initLiHover();
}

if (window.attachEvent) {window.attachEvent("onload", initPage);} else {window.onload = initRollovers;}
	
// Associate Return keypress to its correct postback call
// Used for newsletter, search & login
function clickButton(e, buttonid)
{ 	var bt = document.getElementById(buttonid);
		//alert(document.getElementById(buttonid));
		if (typeof bt == 'object')
		{		if(navigator.appName.indexOf("Netscape")>(-1))
				{		if (e.keyCode == 13)
						{		bt.click();
		      	  	return false;
		      	}
		  	}
		  	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		  	{		if (event.keyCode == 13)
		  			{		bt.click();
		      			return false;
		  			}
		  	}
		}
}

function SetCookie(name, value)
{	document.cookie = name+"="+value;
}

function GetCookie(Name)
{ var re=new RegExp(Name+"=[^;]+", "i");
	if (document.cookie.match(re))
	{	return document.cookie.match(re)[0].split("=")[1];
	}
	return "";
}

function forceClickButton(E, buttonid)
{		var bt = document.getElementById(buttonid);
		if (typeof bt == 'object')
		{		if(navigator.appName.indexOf("Netscape")>(-1))
				{		bt.click();
		      	return false;
		  	}
		  	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		  	{		bt.click();
		      		return false;
		  	}
		}
}