var activeSub=0;
var SubNum=0;

//function reDo(){ window.location.reload(); }
//    window.onresize = reDo;

    //Define global variables

	    var timerID = null;
		var timerOn = false;
		var timecount = 1000;
		var what = null;
		var newbrowser = true;
		var check = false;

    	function init(){
    	  // alert ("Running Init");
          if (document.layers) {
                        // alert ("Running Netscape 4");
                        layerRef="document.layers";
                        styleSwitch="";
                        visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";

          }else if(document.all){
                        // alert ("Running IE");
                        layerRef="document.all";
                        styleSwitch=".style";
                        visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";

		  }else if(document.getElementById){
                        // alert ("Running Netscape 6");
                        layerRef="document.getElementByID";
                        styleSwitch=".style";
                        visibleVar="visible";
			what="moz";
		  
		  }else{
		  	// alert("Older than 4.0 browser.");
			what="none";
			newbrowser = false;
		  }
		   
		window.status='PIONEER';
		check = true;
		
		callBack();
  	 	}
  	 	
  	 	function callBack()
  	 	{
  	 		//nothing
  	 	}

	// Turns the layers on and off
        function showLayer(layerName, obj){
            var ndl;
        	if(check){
        		if (what =="none"){
        			return;
        			}
        	    left=findPos(obj);
        		document.getElementById(layerName).style.left=left;
	        	if (what == "moz"){
        			document.getElementById(layerName).style.visibility="visible";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
				  ndl = document.getElementsByTagName("select");
				  if (ndl){
					for (i=0; i<ndl.length; ++i){
					  var obj = ndl[i];
					  if (obj.name != "profileID"){
					  	if (obj && obj.offsetParent && obj.style){
							obj.style.visibility = 'hidden';
							}
						}
					 }
				  }
		     } 
		 }
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
		}

        function hideLayer(layerName){
            var ndl;
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="hidden";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
				  ndl = document.getElementsByTagName("select");
				  if (ndl){
					for (i=0; i<ndl.length; ++i){
					  var obj = ndl[i];
					  if (obj && obj.offsetParent && obj.style){
						obj.style.visibility = 'visible';
						}
					 }
				  }
				}
        
        	}
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
        }

		function hideAll(){
				hideLayer('layer1');
				hideLayer('layer2');
				hideLayer('layer3');
				hideLayer('layer4');
				hideLayer('layer5');
				hideLayer('layer6');
				hideLayer('layer7');
				hideLayer('layer8');
				hideLayer('layer9');
				}

		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount);
                timerOn = true;

	        }

		}
		
		function startTime1() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideLayer('layer1')" , timecount);
                timerOn = true;

	        }

		}

		function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID);
                timerID = null;
                timerOn = false;
	        }
		}

		function onLoad(){
			init();		
			}
			
function findPos(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return [curleft];
}			
/* Pioneer.com */
function tabOn(obj){
	obj.className ="goldtab";
}
function tabOff(obj){
	obj.className ="greentab";
}

function showCountryPicker(obj){
	buildCountryPicker();
	hideLayer('layer1'); 
	showLayer('layer1', obj); 
	stopTime();
}

var countryPickerBuilt = false;
var countries = [];
function buildCountryPicker(){
	if(!countryPickerBuilt){
		tblBody = document.getElementById("countryTBody");
		if(tblBody == null || countries==null || countries.length==null){
			return;
		}
		countryPickerBuilt = true;

        // creating all cells
        for (var i = 0; i < countries.length; i++) {
            // creates a table row
            var row = document.createElement("tr");

            // Create a <td> element and a text node, make the text
            // node the contents of the <td>, and put the <td> at
            // the end of the table row
            var cellText = document.createTextNode(countries[i][2]);
			var img = document.createElement("img");
			img.setAttribute("src", "/CMRoot/managed_images/Portal/o2o_images/flags/"+countries[i][1]);

			var link = document.createElement("a");
			//link.setAttribute("href", "/web/site/portal/menuitem."+countries[i][0]);
			link.setAttribute("href", countries[i][0]);
			// link.setAttribute("href", "/portal/site/Public/"+countries[i][0]);
			link.appendChild(img);
			link.appendChild(cellText);

            var cell = document.createElement("td");
            cell.appendChild(link);
 
			if(i%2==0){
				cell.className="navEven";
			}else{
				cell.className="navOdd";
			}

            // add the row to the end of the table body
            row.appendChild(cell);
            tblBody.appendChild(row);
        }
	}
}

function defaultEmailLink(pre, post, name, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@pioneer.com\">"+pre+name+"@pioneer.com"+post+"</a>");
}
function defaultEmailLink2(pre, post, name, params, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@pioneer.com?"+params+"\">"+pre+name+"@pioneer.com"+post+"</a>");
}

function emailLink(pre, post, name, domain, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+pre+name+"@"+domain+post+"</a>");
}
function emailLink2(pre, post, name, domain, params, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+pre+name+"@"+domain+post+"</a>");
}

function fullEmailLink(pres, post, name, domain, name2, domain2, attributes){
    if(domain2.length==0){
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+pre+name2+post+"</a>");
    }else{
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+pre+name2+"@"+domain2+post+"</a>");
    }
	
}
function fullEmailLink2(pre, post, name, domain, params, name2, domain2, attributes){
    if(domain2.length==0){
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+pre+name2+post+"</a>");
    }else{
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+pre+name2+post+"</a>");
    }
	
}