    //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');
				}


		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , 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();
	hideAll(); 
	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", "/staticweb/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.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(name, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@pioneer.com\">"+name+"@pioneer.com</a>");
}
function defaultEmailLink2(name, params, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@pioneer.com?"+params+"\">"+name+"@pioneer.com</a>");
}

function emailLink(name, domain, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+name+"@"+domain+"</a>");
}
function emailLink2(name, domain, params, attributes){
	document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+name+"@"+domain+"</a>");
}

function fullEmailLink(name, domain, name2, domain2, attributes){
    if(domain2.length==0){
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+name2+"</a>");
    }else{
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"\">"+name2+"@"+domain2+"</a>");
    }
	
}
function fullEmailLink2(name, domain, params, name2, domain2, attributes){
    if(domain2.length==0){
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+name2+"</a>");
    }else{
        document.writeln("<a"+attributes+" href=\"mailto:"+name+"@"+domain+"?"+params+"\">"+name2+"</a>");
    }
	
}

function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
   }
   else {
       return document[movieName];
   }
}

function clearMCopyDiv(str) {
  document.getElementById("mCopyDiv").innerHTML = ""; 
  return "clear"
}

function callExternalInterface(whatType, name, title, mediaCopy) {
    getMovieName("myMovie").callMediaInputs(whatType, name, title);
    document.getElementById("mCopyDiv").innerHTML = mediaCopy; 
}

function showImg(scr, field, txt) {
            document.getElementById(field).innerHTML = txt;
}

function divVisible(strHide, strShow){
            var arrHide = new Array();
            arrHide = strHide.split(',');
            for(i=0;i<arrHide.length;i++){
                        document.getElementById(arrHide[i]).style.display='none';
            }
            var arrShow = new Array();
            arrShow = strShow.split(',');
            for(i=0;i<arrShow.length;i++){
                        document.getElementById(arrShow[i]).style.display='inline';
            }
}

gSlideshowInterval = 8;
gNumberOfImages = 1;
gCurrentImage = 0;
gImageFolder = "";
gImageCapableBrowser = canManipulateImages();
gArrImages = new Array();
gLoadedOnce = 0;

function canManipulateImages() {
            if (document.images)
                        return true;
            else
                        return false;
}
function loadSlide(imageURL) {
            if (gImageCapableBrowser) {
                        document.slide.src = gImageFolder + imageURL;
                        return false;
            }
            else {
                        return true;
            }
}
function nextSlide() {
            gCurrentImage = (gCurrentImage + 1) % gNumberOfImages;
            loadSlide(gArrImages[gCurrentImage]);
}
function fncSetupRotate(strLoc, strImages, intervalVal){
            if(gLoadedOnce==0){
                        gImageFolder = strLoc;
                        gArrImages = strImages.split(",")
                        gNumberOfImages = gArrImages.length;
                        gSlideshowInterval = intervalVal
                        setInterval("nextSlide()",gSlideshowInterval * 1000);
                        gLoadedOnce = 1;
            }
}

/* ObjectSwap - Bypasses the new ActiveX Activation requirement in Internet Explorer by swapping existing ActiveX objects on the page with the same objects. Can also be used for Flash version detection by adding the param:
<param name="flashVersion" value="8" /> to the object tag.

Author: Karina Steffens, www.neo-archaic.net
Created: April 2006
Changes and bug fixes: May 2006
Bug fixes: June 2006
Changes: October 2006 (Included Opera9 and excluded IE5.5)
*/

//Check if the browser is InternetExplorer, and if it supports the getElementById DOM method
var ie = (document.defaultCharset && document.getElementById && !window.home);
var opera9 = false;
if (ie){
	//Check for ie 5.5 and exclude it from the script
	var ver=navigator.appVersion.split("MSIE")
	ver=parseFloat(ver[1])
	ie = (ver >=6)
}else if (navigator.userAgent.indexOf("Opera")!=-1) {
	//Check for Opera9 and include it in the ObjectSwap
	var versionindex=navigator.userAgent.indexOf("Opera")+6
	if (parseInt(navigator.userAgent.charAt(versionindex))>=9)
	opera9 = true;
}
//Perform ObjectSwap if the browser is IE or Opera (if not just check flashVersion)
var oswap = (ie || opera9)

//Hide the object to prevent it from loading twice
if (oswap){
	document.write ("<style id='hideObject'> object{display:none;} </style>");
}

/*Replace all flash objects on the page with the same flash object, 
by rewriting the outerHTML values
This bypasses the new IE ActiveX object activation issue*/
objectswap = function(){
	if (!document.getElementsByTagName){
		return;
	}
	//An array of ids for flash detection
	var stripQueue = [];
	//Get a list of all ActiveX objects
	var objects = document.getElementsByTagName('object');
	for (var i=0; i<objects.length; i++){			
		var o = objects[i];	
		var h = o.outerHTML;
		//The outer html omits the param tags, so we must retrieve and insert these separately
		var params = "";
		var hasFlash = true;
		for (var j = 0; j<o.childNodes.length; j++) {
			var p = o.childNodes[j];
			if (p.tagName == "PARAM"){
				//Check for version first - applies to all browsers
				//For this to work, a new param needs to be included in the object with the name "flashVersion" eg:
				//<param name="flashVersion" value="7" />
				if (p.name == "flashVersion"){
					hasFlash = detectFlash(p.value);
					if (!hasFlash){
						//Add the objects id to the list (create a new id if there's isn't one already)
						o.id = (o.id == "") ? ("stripFlash"+i) : o.id;
						stripQueue.push(o.id);
						break;
					}
				} 
				params += p.outerHTML;		       
			}
		}	
		if (!hasFlash){
			continue;
		}		
		//Only target internet explorer
		if (!oswap){
			continue;
		} 
		//Avoid specified objects, marked with a "noswap" classname
		if (o.className.toLowerCase().indexOf ("noswap") != -1){
			continue;
		}		
		//Get the tag and attributes part of the outer html of the object
		var tag = h.split(">")[0] + ">";			
		//Add up the various bits that comprise the object:
		//The tag with the attributes, the params and it's inner html
		var newObject = tag + params + o.innerHTML + " </OBJECT>";	
		//And rewrite the outer html of the tag 
		o.outerHTML = newObject;
	}
	//Strip flash objects
	if (stripQueue.length) {
		stripFlash(stripQueue)
	}
	//Make the objects visible again
	if (oswap){
		document.getElementById("hideObject").disabled = true;
	}
}

detectFlash = function(version){
	if(navigator.plugins && navigator.plugins.length){
		//Non-IE flash detection.
		var plugin = navigator.plugins["Shockwave Flash"];
		if (plugin == undefined){
			return false;
		}
		var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];
		return (Number(ver) >= Number(version))
	} else if (ie && typeof (ActiveXObject) == "function"){
	//IE flash detection.
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
			return true;
		}
		catch(e){
			return false;
		}
	}
	//Catchall - skip detection
	return true;
}

//Loop through an array of ids to strip
//Replace the object by a div tag containing the same innerHTML.
//To display an alternative image, message for the user or a link to the flash installation page, place it inside the object tag.  
//For the usual object/embed pairs it needs to be enclosed in comments to hide from gecko based browsers.
stripFlash = function (stripQueue){
	if (!document.createElement){
		return;
	}
	for (var i=0; i<stripQueue.length; i++){
		var o = document.getElementById(stripQueue[i]);
		var newHTML = o.innerHTML;	
		//Strip the comments
		newHTML = newHTML.replace(/<!--\s/g, "");
		newHTML = newHTML.replace(/\s-->/g, "");
		//Neutralise the embed tag
		newHTML = newHTML.replace(/<embed/gi, "<span");		
		//Create a new div element with properties from the object
		var d = document.createElement("div");
		d.innerHTML = newHTML;
		d.className = o.className;
		d.id = o.id;
		//And swap the object with the new div
		o.parentNode.replaceChild(d, o);
	}
}

//Initiate the function without conflicting with the window.onload event of any preceding scripts
var tempFunc = window.onload;
window.onload = function(){
	if (typeof (tempFunc) == "function"){
		try{
			tempFunc();
		} catch(e){}
	}
	objectswap();
}

/*
	CCILinking - replaces div tags with class cciDiv with the appropriate links for TeamSite users
*/

// function that takes a function and adds it to the onload event
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function') {
		window.onload = func;
	
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// function parses the DOM structure looking for ccidiv class and shows teamsite links if user is valid.
function cciLinking() {
	// Make sure the browser supports DOM methods
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	// Grab all the div tags and call ajax service for each div with classname cci
	var divs = document.getElementsByTagName("div");
	for (var i=0; i<divs.length; i++) {
		if (divs[i].className == "cciDiv") {
			var guid = divs[i].lastChild.nodeValue;
			var obj = divs[i];
			var url = "/CCILinking/Links?guid="+guid+"&datehack=" + new Date().getTime();
			var links = getXML(obj, url);
			if (links != "") {
				obj.innerHTML = "<hr>"+links+"<hr>";
				obj.style.display = "block";
			}
		}
	}
}

// function that performs the XMLHttpRequest
function getXML(obj, url) {
	var links = "";
	http = false;
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try {
			http = new XMLHttpRequest();
		} catch(e) {
			http = false;
		}
	} else if(window.ActiveXObject) {
		try {
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				http = false;
			}
		}
	}	

	http.open("GET", url, false);
	http.send(null);
	if (http.readyState == 4 && http.status == 200) {
		if(!http.responseXML) return "";
		if(!http.responseXML.documentElement) return "";
		if(!document.getElementById) return false;
		var linknodes = http.responseXML.documentElement.getElementsByTagName("link");

		for (var i = 0; i < linknodes.length; i++) {
			var node = linknodes[i];
			if (i != (linknodes.length - 1)) {
				links += "<a href=\""+node.firstChild.nodeValue+"\" alt=\""+node.getAttribute("alt")+"\" target=\""+node.getAttribute("target")+"\">"+node.getAttribute("label")+"</a> |";
			} else {
				links += "<a href=\""+node.firstChild.nodeValue+"\" alt=\""+node.getAttribute("alt")+"\" target=\""+node.getAttribute("target")+"\">"+node.getAttribute("label")+"</a>";						   
			}
		}
	}
	return links;	
}

addLoadEvent(init);
addLoadEvent(cciLinking);
addLoadEvent(objectswap);

