
//Checks to see whether the site is Global or Region Particular
/*
imgRoot = location.href;
if(imgRoot.split("/sites/")[1]) // Site is Region Particular
{
	specificSite = imgRoot.split("/sites/"); 
	
	//Because global internal pages are /sites/westcon-group-global, need to point to the /images/template
	if(specificSite[1].split("/")[0] == 'westcon-group-global')
		siteRoot = 'template/';
	else siteRoot = specificSite[1].split("/")[0]+"/";
	
	var IMG_ROOT= imgRoot.split("/sites/")[0]+"/images/"+siteRoot;
}
else 
{
	var IMG_ROOT= '/images/template/';
}*/




function searchOnOff()
{
	var searchWidgit = document.getElementById('search_widgit');	
	var status = getCSSValue(searchWidgit, 'display');
	
	//alert(status);
	if(status == 'none' || status == false)
		searchWidgit.style.display = 'block';
	else if(status == 'block')
		searchWidgit.style.display = 'none';	
}

function mainNavHighlight(obj)
{	
	imgRoot = obj.src.split("/");
	
	/* gets the image position */
	IMG_ROOT = '';
	for(i=0; i< imgRoot.length-1; i++ )
	{	IMG_ROOT +=imgRoot[i]+'/';	}
	
	
	objSrc = getRenderedImgSrc(obj); //Gets the name of the ICON without the extention	
	
	// MOUSEOVER ACTION
	obj.src=IMG_ROOT+objSrc+"_on.gif";	
	//alert(obj.src);
	obj.onmouseout = backToOriginalState;	
	function backToOriginalState()
	{
		obj.src=IMG_ROOT+objSrc+".gif";		
	}	
}

function sideNavHighlight(obj, menuType, color)
{	
	if(menuType == 1){
		
		//Initiation
		siteIcon = getFirstChild(obj);//DOM goes down to the site ICON
		siteIconSRC = getRenderedImgSrc(siteIcon); //Gets the name of the ICON without the extention
		objLink = getNextDiv(siteIcon);
				
		// MOUSEOVER ACTION
		obj.style.backgroundImage="url('/images/template/bg_hp_sideNav_on.gif')";
		siteIcon.src = "/images/template/"+siteIconSRC+'_'+color+'.gif';
		objLink.style.color = "#"+color;
		objLink.style.backgroundImage = "url('/images/template/arrow_lblue.gif')";
		
		obj.onmouseout = backToOriginalState1;
	}
	else if(menuType == 3){
		
		//Initiation
		siteIcon = getFirstChild(obj);//DOM goes down to the site ICON
		siteIconSRC = getRenderedImgSrc(siteIcon); //Gets the name of the ICON without the extention
		objLink = getNextDiv(siteIcon);
				
		// MOUSEOVER ACTION
		obj.style.backgroundImage="url('/images/template/bg_hp_sideNav_lg_on.gif')";
		siteIcon.src = "/images/template/"+siteIconSRC+'_'+color+'.gif';
		objLink.style.color = "#"+color;
		objLink.style.backgroundImage = "url('/images/template/arrow_lblue.gif')";
		
		obj.onmouseout = backToOriginalState1;
	}
	else
	{
		obj.style.backgroundImage="url('/images/template/bg_hp_sideNav_on.gif')";
		obj.onmouseout = backToOriginalState2;
	}
	
	function backToOriginalState1()
	{
		obj.style.backgroundImage="none";
		siteIcon.src = "/images/template/"+siteIconSRC+'.gif';
		objLink.style.color = "#005a9c";
		objLink.style.backgroundImage = "url('/images/template/arrow_blue.gif')";		
	}
	function backToOriginalState2()
	{
		obj.style.backgroundImage="none";			
	}
}

function getRenderedImgSrc(imgObj)
{
	imgsrc = imgObj.src;	
	img_root = imgsrc.split("/");
	img_name = img_root[img_root.length-1];
	img_name = img_name.split("_");
	img_name = img_name[0]+'_'+img_name[1];
	justImageName = img_name.split(".");
	
	return justImageName[0]; //Returns just the image name without the extention	
}


function getCSSValue(objName,cssProperty,styleSheet)
{
	returnVal = objName.style[cssProperty];
	
	//alert(returnVal);
	//alert(objName.className+' '+cssProperty);
	//alert("Class Name: "+objName.className+" Property: "+cssProperty+" Getting Prop: "+returnVal);
	
	if(returnVal == ''){
	
		//alert(eval(testObj));
		
		  var cssValue= false;
		
		  var ss = document.styleSheets[0];
		
		//cssRules[0] for mozila, rules for explorer
		
			if (navigator.appName=="Microsoft Internet Explorer")
			{
				
		 		 for(i= 0; i< ss.rules.length; i++)
		  			{
		  			
		   			 if(ss.rules[i].selectorText== ('.'+objName.className))
		    			{
		    				  cssValue= ss.rules[i].style[cssProperty];
							  break;
		   				 }
		
		 			 }
		 	 }//end of the if nav name statement
		 	 else
		 	 {
		 	 	for(i= 0; i< ss.cssRules.length; i++)
		  			{
		
					 if(ss.cssRules[i].selectorText== ('.'+objName.className))
		    			{
		    				  cssValue= ss.cssRules[i].style[cssProperty];
		    				  break;
		   				 }
		
		 			 }
		 	}
		 	 	
		  return(cssValue);
	}
	else
		return returnVal;

}


function getNextDiv(d){
	var nextDiv= d.nextSibling;
	
	while(nextDiv){
		if(nextDiv.tagName && nextDiv.tagName=='A')
			break;
		else
			nextDiv= nextDiv.nextSibling;
	}	
	return nextDiv
}

function getFirstChild(g)
{
		var prevDiv= g.firstChild;
		while(prevDiv)
		{
				if(prevDiv.tagName && prevDiv.tagName=='IMG')
					break;
				else 
					prevDiv= prevDiv.nextSibling;
		}
		return prevDiv;
}

function getPreviousDiv(g)
{
		var prevDiv= g.previousSibling;
		while(prevDiv)
		{
				if(prevDiv.tagName && prevDiv.tagName=='DIV')
					break;
				else 
					prevDiv= prevDiv.previousSibling;
		}
		return prevDiv;
}

function addTableDiffTr(tableId,darkBg,lightBg)
{
	var tableObj = document.getElementById(tableId);
	var tBody = tableObj.getElementsByTagName('TBODY');
	if(tBody){
		var rows = tBody[0].getElementsByTagName('TR');
	}else{
		var rows = tableObj.getElementsByTagName('TR');
	}
	for(var no=0;no<rows.length;no++){
		if(no%2 == 0)
			rows[no].className=lightBg;
		else 
			rows[no].className=darkBg;
	}
	
}




var at = "@";
var dot = ".";
var atrep = "^";
var dotrep = "$";

function hg_em_decrypt2(text){


  var len = text.length;
  var tmp = "";

  while (text.indexOf(atrep)>-1) {
    var idx = text.indexOf(atrep);
    text = "" + (text.substring(0, idx) + at + text.substring((idx + atrep.length), text.length));
  }

  while (text.indexOf(dotrep)>-1) {
    var idx = text.indexOf(dotrep);
    text = "" + (text.substring(0, idx) + dot + text.substring((idx + dotrep.length), text.length));
  }

  for(var i=len-1; i>=0; i--){
    if(i%2 == 0)
      tmp +=text.charAt(i);
  }

  
  tmp = '<a href="mailto:'+tmp+'">'+tmp+'</a>';
  return tmp;
  
}