function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function getCoords(element){
		for (var lx=0,ly=0;element!=null;
			lx+=element.offsetLeft,ly+=element.offsetTop,element=element.offsetParent);
		return {x:lx,y:ly}
	}

function trimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}


function isNumeric(sText) {
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) IsNumber = false;
   }
   return IsNumber;
}

function simpleslide(){// v2.2, Mod'd
if (arguments.length<4){return;}var v1=arguments,v2=v1[0];if (v2==""){return;}var	v3=eval("findObj('"+v2+"')");if (v3==null){return;}var v4=parseInt(v1[1]),v5=parseInt(v1[2]),v6=parseInt(v1[3]);var v7=(v1.length>4)?parseInt(v1[4]):0,v8=(v1.length>5)?parseInt(v1[5]):0;var v9=10,v10=document.layers?v3:v3.style;if (v3.SL2!=null){clearTimeout(v3.SL2);}var v11=isNaN(parseInt(v10.left))?v3.offsetLeft:parseInt(v10.left);var v12=isNaN(parseInt(v10.top))?v3.offsetTop:parseInt(v10.top);if (v8!=0){if (v8==1){v4=v11-v4;v5=v12;}else if (v8==2){v4=v11+v4;v5=v12;}else if (v8==3){v5=v12-v5;v4=v11;}else {v5=v12+v5;v4=v11;}}var v13=v4,v14=v5;if ((v11!=v4)||(v12!=v5)){if (v7>0){v9=v6;var v15=v7,v16=v7,v17=Math.abs(v11-v4),v18=Math.abs(v12-v5);if (v17<v18){v16=(v17!=0)?((v18/v17)*v7):v7;}else {v15=(v18!=0)?((v17/v18)*v7):v7;}if (v15>=v17){v15=Math.min(Math.ceil(v15),v7);}if (v16>=v18){v16=Math.min(Math.ceil(v16),v7);}if ((v11<v4)&&(v11+v15<v4)){v4=v11+v15;}if ((v11>v4)&&(v11-v15>v4)){v4=v11-v15;}if ((v12<v5)&&(v12+v16<v5)){v5=v12+v16;}if ((v12>v5)&&(v12-v16>v5)){v5=v12-v16;}}else {var v17=((v4-v11)/v6),v18=((v5-v12)/v6);v17=(v17>0)?Math.ceil(v17):Math.floor(v17);v4=v11+v17;v18=(v18>0)?Math.ceil(v18):Math.floor(v18);v5=v12+v18;}var v19=((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1)&&(!window.opera))?"px":"";if (v17!=0){eval("v10.left = '"+v4+v19+"'");}if (v18!=0){eval("v10.top = '"+v5+v19+"'");}var v20="simpleslide('"+v2+"',"+v13+","+v14+","+v6+","+v7+",0)";v3.SL2=setTimeout(v20,v9);}}


function advslide(){// v2.2, Mod'd
if (!(isNumeric(arguments[arguments.length -1]))) doAfter = arguments[arguments.length -1];
if (arguments.length<4){return;}var v1=arguments,v2=v1[0];if (v2==""){return;}var	v3=eval("findObj('"+v2+"')");if (v3==null){return;}var v4=parseInt(v1[1]),v5=parseInt(v1[2]),v6=parseInt(v1[3]);var v7=(v1.length>4)?parseInt(v1[4]):0,v8=(v1.length>5)?parseInt(v1[5]):0;var v9=10,v10=document.layers?v3:v3.style;if (v3.SL2!=null){clearTimeout(v3.SL2);}var v11=isNaN(parseInt(v10.left))?v3.offsetLeft:parseInt(v10.left);var v12=isNaN(parseInt(v10.top))?v3.offsetTop:parseInt(v10.top);if (v8!=0){if (v8==1){v4=v11-v4;v5=v12;}else if (v8==2){v4=v11+v4;v5=v12;}else if (v8==3){v5=v12-v5;v4=v11;}else {v5=v12+v5;v4=v11;}}var v13=v4,v14=v5;if ((v11!=v4)||(v12!=v5)){if (v7>0){v9=v6;var v15=v7,v16=v7,v17=Math.abs(v11-v4),v18=Math.abs(v12-v5);if (v17<v18){v16=(v17!=0)?((v18/v17)*v7):v7;}else {v15=(v18!=0)?((v17/v18)*v7):v7;}if (v15>=v17){v15=Math.min(Math.ceil(v15),v7);}if (v16>=v18){v16=Math.min(Math.ceil(v16),v7);}if ((v11<v4)&&(v11+v15<v4)){v4=v11+v15;}if ((v11>v4)&&(v11-v15>v4)){v4=v11-v15;}if ((v12<v5)&&(v12+v16<v5)){v5=v12+v16;}if ((v12>v5)&&(v12-v16>v5)){v5=v12-v16;}}else {var v17=((v4-v11)/v6),v18=((v5-v12)/v6);v17=(v17>0)?Math.ceil(v17):Math.floor(v17);v4=v11+v17;v18=(v18>0)?Math.ceil(v18):Math.floor(v18);v5=v12+v18;}var v19=((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1)&&(!window.opera))?"px":"";if (v17!=0){eval("v10.left = '"+v4+v19+"'");}if (v18!=0){eval("v10.top = '"+v5+v19+"'");}var v20="advslide('"+v2+"',"+v13+","+v14+","+v6+","+v7+",0)";v3.SL2=setTimeout(v20,v9);} else eval(doAfter);}


// Set active or inactive
	function activate(target) {
		if (targetobj = findObj(target)) {
			if (!(targetobj.className.match('active'))) {
				targetobj.className = trimString(targetobj.className + ' active');
			}
		}
	}
	function deactivate(target) {
		if (targetobj = findObj(target)) targetobj.className = trimString(targetobj.className.replace("active", ""));
	}

var delayaction;

function show(obj,parentbtn) {
	clearTimeout(delayaction);
	// special case: the showing of sitespopup (includes repositioning)
	if (obj == 'sitespopup') {	
			findObj('sitespopup').style.top = getCoords(findObj('btn_sites')).y - findObj('sitespopup').offsetHeight + 25 + "px";
		}
	// special cases: the showing of categoriespopups (includes repositioning)
	if (obj == 'categoriespopup') {
			findObj('categoriespopup').style.top = getCoords(findObj('btn_categories')).y + "px";
			findObj('categoriespopup').style.left = getCoords(findObj('btn_categories')).x - getCoords(findObj('container')).x + "px";
			findObj('categoriespopup').style.display = 'block';
		}
	if (obj == 'categoriespopup1') {
			findObj('categoriespopup1').style.top = getCoords(findObj('btn_categories1')).y + "px";
			findObj('categoriespopup1').style.left = getCoords(findObj('btn_categories1')).x - getCoords(findObj('container')).x + "px";
			findObj('categoriespopup1').style.display = 'block';
		}
	if (obj == 'categoriespopup2') {
			findObj('categoriespopup2').style.top = getCoords(findObj('btn_categories2')).y + "px";
			findObj('categoriespopup2').style.left = getCoords(findObj('btn_categories2')).x - getCoords(findObj('container')).x + "px";
			findObj('categoriespopup2').style.display = 'block';
		}
	// special case: the showing of languagespopup (includes repositioning)
	if (obj == 'languagespopup') {
			findObj('languagespopup').style.top = getCoords(findObj('btn_languages')).y + "px";
			findObj('languagespopup').style.left = getCoords(findObj('btn_languages')).x - getCoords(findObj('container')).x + "px";
			findObj('languagespopup').style.display = 'block';
		}
		
	// if parentobj is defined and found
	if ((parentbtn != undefined) && (parentobj=findObj(parentbtn)) && (showobj=findObj(obj))) {		
			//showobj.style.top = getCoords(parentobj).y - showobj.offsetHeight + parentobj.offsetHeight + "px";
			showobj.style.top = getCoords(parentobj).y - showobj.offsetHeight + parentobj.offsetHeight - 380 + "px";
			showobj.style.left = getCoords(parentobj).x - getCoords(findObj('container')).x -14 + "px";
		}
	showHideLayers(obj,'','show')
	}
	
function show2(obj,parentbtn) {
    	clearTimeout(delayaction);
        if ((parentbtn != undefined) && (parentobj=findObj(parentbtn)) && (showobj=findObj(obj))) {	
      		//showobj.style.top = getCoords(parentobj).y - showobj.offsetHeight + parentobj.offsetHeight + "px";
                if (navigator.userAgent.indexOf("MSIE")>=0)
                {
		showobj.style.top = getCoords(parentobj).y - showobj.offsetHeight + parentobj.offsetHeight -8 + "px";
		showobj.style.left = getCoords(parentobj).x - getCoords(findObj('container')).x -14 + "px";
                }
                else
                {
		showobj.style.top = getCoords(parentobj).y - showobj.offsetHeight + parentobj.offsetHeight -2 + "px";
		showobj.style.left = getCoords(parentobj).x - getCoords(findObj('container')).x -2 + "px";
		}
		}
	    showHideLayers(obj,'','show')
	 
}
	
function hide(obj,delaytime) {
	if (delaytime != undefined) {
		delayaction = setTimeout("showHideLayers('" + obj + "','','hide');if ('" + obj + "'.match('popup')) findObj('" + obj + "').style.top = '0px'",10);
	}
	else {
		showHideLayers(obj,'','hide');
	}
}

function focusfld(fieldid,action) {
		if (action==1) {
			findObj(fieldid).className = 'focused';
		}
		if (action==0) {
			findObj(fieldid).className = '';
		}
	}
	
function menuflip(tabnmbr) {
		if (tabnmbr==1) findObj('leftcol').className = 'menutab1';
		if (tabnmbr==2) findObj('leftcol').className = 'menutab2';
	}


//this one takes care of the submenus
function submenu(subnmbr) {
	
	//hide submenus
	
	var divs = document.getElementsByTagName('div');	//get all divs
	for(i=0;i<divs.length;i++){							//loop through divs
		if(divs[i].id.match(/sub\d/)){					//if their name has 'sub'
			hide(divs[i].id)							//hide them
		}
	}
	
	if (subnmbr!=null) {
	
		// get menu item y-coordinate
		var obj,locV;
		if (obj=findObj('item' + subnmbr)) {
			myElement = getCoords(obj);
			locV = myElement.y;
		}
		
		// set submenu to same coordinate -1
		// show menu	
		var obj;
		if (obj=findObj('sub' + subnmbr)) {
			obj.style.top = locV -2 + 'px';
			show('sub' + subnmbr);
		}
	}
}

var activepath = 0;


// switching tabs
function tab(tabnmbr) {
	// hide all tab contents	
		var divs = document.getElementsByTagName('div');	
		for(i=0;i<divs.length;i++){							
			if(divs[i].id.match(/tabcontent\d/)){					
				if (targetobj = findObj(divs[i].id)) targetobj.className = trimString(targetobj.className.replace("active", ""));							
			}
		}

	// set all tabs to inactive	
		var lis = document.getElementsByTagName('li');
		for(i=0;i<lis.length;i++){	
			if(lis[i].id.match(/tab\d/)){
				if (targetobj = findObj(lis[i].id)) targetobj.className = trimString(targetobj.className.replace("active", ""));
			}
		}

	// activate given tab
	if (tabnmbr != 'undefined') {
		if (targetobj = findObj('tab' + tabnmbr)) targetobj.className = trimString(targetobj.className + ' active');
		if (targetobj = findObj('tabcontent' + tabnmbr)) targetobj.className = trimString(targetobj.className + ' active');
	}
}

// Handle home page paths
	function openpath(pathnmbr) {
		if (pathnmbr != activepath) {
			if (findObj('campaign')) simpleslide('campaign',-2,293,5,0,0);
			for (i=1;i<5;i++) {
				if (i <= pathnmbr) simpleslide('path' + i,0,i*35-15,5,0,0);	
				if (i > pathnmbr) simpleslide('path' + i,0,i*35+82,5,0,0);
				if (i != pathnmbr) simpleslide('pathinfo' + i,0,-74,5,0,0); deactivate('path' + i);
			
			}
			advslide('pathinfo' + pathnmbr,0,23,5,0,0,'activate("path' + pathnmbr + '")') 	// name, x, y, spd, todoafter
			activepath = pathnmbr;
		}
		else {
			for (i=1;i<5;i++) {
				simpleslide('path' + i,0,i*35-15,5,0,0);
				simpleslide('pathinfo' + i,0,-74,5,0,0);
			}
			deactivate('path' + activepath);
			activepath = 0;
			if (findObj('campaign')) simpleslide('campaign',-2,179,5,0,0);
		}
	}


// Handle the region-country -selector
	var currregion, currcountry;
	
	function region(regionnmbr) {
		
		currregion = regionnmbr;
		// activate the right item in the region list
		var as = document.getElementsByTagName('a');
		for(i=0;i<as.length;i++){	
			if(as[i].id.match(/regionlistitem\d/)){
				if (targetobj = findObj(as[i].id)) deactivate(as[i].id);
			}
		}
		if (obj = findObj('regionlistitem' + regionnmbr)) {
			activate(obj.id);
			// change regions button text
			btntext = obj.innerHTML;
			if (btntext.length > 21) btntext = btntext.substr(0,21) + "..."; 
			findObj('regionsbtn').innerHTML = btntext;
			// change countries button text
			findObj('countriesbtn').innerHTML = "Select a country";
		}


		// activate the right country list
		var uls = document.getElementsByTagName('ul');
		for(i=0;i<uls.length;i++){	
			if(uls[i].id.match(/countrylist\d/)){
				if (targetobj = findObj(uls[i].id)) deactivate(uls[i].id);
			}
		}
		if (obj = findObj('countrylist' + regionnmbr)) {
			activate(obj.id);
		}
	}
	
	function country(itemid) {

		//countryid = itemid.substr(15,itemid.length);
		// activate the right item in the region list
		var as = document.getElementsByTagName('a');
		for(i=0;i<as.length;i++){	
			if(as[i].id.match("countrylistitem")){
				if (targetobj = findObj(as[i].id)) deactivate(as[i].id);
			}
		}
		if (obj = findObj(itemid)) {
			activate(obj.id);
			// change regions button text
			btntext = obj.innerHTML;
			if (btntext.length > 21) btntext = btntext.substr(0,21) + "..."; 
			findObj('countriesbtn').innerHTML = btntext;
		}

		// activate the right country content
		//var divs = document.getElementsByTagName('div');
		//for(i=0;i<divs.length;i++){	
		//	if(divs[i].id.match("countrycontent")){
		//		if (targetobj = findObj(divs[i].id)) deactivate(divs[i].id);
		//	}
		//}
		//if (obj = findObj('countrycontent' + countryid)) {
		//	activate(obj.id);
		//}
		//else {
		//	activate('countrycontent0-0');
		//}

		
		showHint(itemid);
		deactivate('countrycontent0-0');
		activate('countrycontent1-1');
	}

	function country2(itemid) {

		//countryid = itemid.substr(15,itemid.length);
		// activate the right item in the region list
		var as = document.getElementsByTagName('a');
		for(i=0;i<as.length;i++){	
			if(as[i].id.match("countrylistitem")){
				if (targetobj = findObj(as[i].id)) deactivate(as[i].id);
			}
		}
		if (obj = findObj(itemid)) {
			activate(obj.id);
			// change regions button text
			btntext = obj.innerHTML;
			if (btntext.length > 21) btntext = btntext.substr(0,21) + "..."; 
			findObj('countriesbtn').innerHTML = btntext;
		}

		// activate the right country content
		//var divs = document.getElementsByTagName('div');
		//for(i=0;i<divs.length;i++){	
		//	if(divs[i].id.match("countrycontent")){
		//		if (targetobj = findObj(divs[i].id)) deactivate(divs[i].id);
		//	}
		//}
		//if (obj = findObj('countrycontent' + countryid)) {
		//	activate(obj.id);
		//}
		//else {
		//	activate('countrycontent0-0');
		//}

		
		//showHint(itemid);
		deactivate('countrycontent0-0');
		deactivate('countrycontent1-1');
		
		var countryid = itemid.substr(16,itemid.length);

		window.open("aspx/PersonalhelpInfo.aspx?Index=" + countryid, "", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=560,height=450")
	}


// PRINTING

function printpage() {
		window.print();
	}


// MAILING

function mailpage() {
		document.location='mailto:?subject=Check this out!&body=' + location.href; 
	}


// TABLE STRIPES

onload = function() { stripe ('middlecol') };

 function stripe(id) {
    var table = document.getElementById(id);
    if (! table) { return; }
    
    var trs = table.getElementsByTagName("tr");

    for (var i = 0; i < trs.length; i += 2) {
      trs[i].className += " even";
    }
  }




// CONTACT TAB SEARCH

var xmlHttp

function showHint(objCountry)
{ 	

	if(objCountry.length>0) 
	{
		var countryid = objCountry.substr(16,objCountry.length);
		var url="aspx/ContactInfo.aspx?sid=" + Math.random() + "&Index=" + countryid
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
   	 }
	else
	{
		window.document.getElementById("countrycontent1-1").innerHTML = "";	
	}
} 

function stateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
 	window.document.getElementById("countrycontent1-1").innerHTML = xmlHttp.responseText	
    } 
} 

function GetXmlHttpObject(handler)
{  
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        try
        { 
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
        } 
        catch(e)
        { 
            alert("Error. Try newer version of Opera browser.") 
            return 
        }  
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    { 
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        } 
        try
        { 
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler 
            return objXmlHttp
        } 
        catch(e)
        { 
            alert("Error. ActiveX might be disabled") 
            return 
        } 
    } 

    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
    }
}