if (!document.getElementById) {
	document.getElementById = function() { return null; }
}

function InitializeMenu(nSelectedID,nLevel) {
    var actuator = document.getElementById(nSelectedID);
	if (actuator == null) {return;}
	if(nLevel == 1){
		P7_swapClass(1,nSelectedID,'open2','closed2','li')
    	actuator.parentNode.style.display = "block"}
	else{
		P7_swapClass(1,nSelectedID,'open','closed','li')
    	actuator.parentNode.style.display = "block"}
}

function HighlightItem(pageType, prodType, subType, prodID, multiTitleProdIndex, prodCatID){
	if(pageType == "ProductType"){
		if (prodType < 10) {prodType = "0" + prodType}
		InitializeMenu("pid" + prodType,0);
		P7_swapClass(1,"sid" + prodType,'open2','closed2','li')
		if(document.getElementById("ppid" + prodType)){document.getElementById("ppid" + prodType).style.backgroundColor = "#D6D6B5"}
	}else if(pageType == "SubType"){
		var sSelectedProdType = "tsid" + subType
		var nTempNum = prodType
		
		if(subType == "ipsoftwareapp"){nTempNum = 27}
		if(subType == "download2"){nTempNum = 27}
		if(subType == "drivers"){nTempNum = 27}
		if(subType == "download44"){nTempNum = 27}
		if(subType == "customcables"){nTempNum = 23}
		if(subType == "iplinksoftware"){nTempNum = 26}
		if(subType == "iplinkapplications"){nTempNum = 26}
		if(subType == "aapselector"){nTempNum = 20}
		if(subType == "connectconfig"){nTempNum = 20}
		if(subType == "aapmaap"){nTempNum = 20}
		if(subType == "iplinkfaq"){nTempNum = 26}
		if(subType == "ipifaqs"){nTempNum = 14}
		if(subType == "ipifaqs2"){nTempNum = 32}				
		if(subType == "ipifaqs3"){nTempNum = 28}				
		if(subType == "mlsystems"){nTempNum = 14}
		if(subType == "pvapplications"){nTempNum = 32}
		if(subType == "pvsystemconfigurator"){nTempNum = 32}
		if(subType == "cableselector"){nTempNum = 23}
		
		//fix problem with Adapters subType that displayed under 2 different prodtypes
		if(prodType == 22){
			InitializeMenu("pid22",0);
			P7_swapClass(1,"sid" + subType + "prodtype22",'open2','closed2','li')
			document.getElementById(sSelectedProdType).style.backgroundColor = "#D6D6B5"
		}else{
			if(nTempNum < 10){InitializeMenu("pid0" + nTempNum,0);}
			else{InitializeMenu("pid" + nTempNum,0);}
			if(subType == "iplinksoftware"){//This is needed because moving GlobalViewer and IRLearner into IP Links > IP Link Software.
				P7_swapClass(1,'tsidiplinksoftware','open2','closed2','li')
				sSelectedProdType = "ttsidiplinksoftware"
			}
			else if(subType == "ipsoftwareapp"){//This is needed because moving GlobalViewer and IRLearner into IP Links > IP Link Software.
				P7_swapClass(1,'tsidipsoftwareapp','open2','closed2','li')
				sSelectedProdType = "ttsidipsoftwareapp"
			}
			else if(subType == "iplinkapplications"){//This is needed because creating 3rd tiers IP Link Applications and IP Link Advertisements into IP Links > IP Link Applications.
				P7_swapClass(1,'tsidiplinkapplications','open2','closed2','li')
				sSelectedProdType = "ttsidiplinkapplications"
			}
			else if(subType == "ipifaqs"){//This is needed because creating 3rd tiers IP Intecom FAQ for MediaLink
				P7_swapClass(1,'sid242','open2','closed2','li')
				sSelectedProdType = "ipifaqs"
			}		
			else if(subType == "ipifaqs2"){//This is needed because creating 3rd tiers IP Intercom FAQ for PoleVault
				P7_swapClass(1,'sid241','open2','closed2','li')
				sSelectedProdType = "ipifaqs2"
			}
			else if(subType == "ipifaqs3"){//This is needed because creating 3rd tiers IP Intercom FAQ for PoleVault
				P7_swapClass(1,'sid264','open2','closed2','li')
				sSelectedProdType = "ipifaqs3"
			}
			else{P7_swapClass(1,"sid" + subType,'open2','closed2','li')}
			
			if(document.getElementById(sSelectedProdType) && (prodCatID == 0 || subType == "aapmaap" || subType == "customcables" || subType == "cableselector" || subType == "pvsystemconfigurator")){
				var oHighlightedItem = document.getElementById(sSelectedProdType + multiTitleProdIndex)
				var oProdCatID = document.getElementById(prodCatID) //This is needed when the 3rd item is a product category. I.E IPLInk > IP Link Software > Tutorial
				if(oProdCatID){oProdCatID.style.backgroundColor = "#D6D6B5"}
				else if(oHighlightedItem){oHighlightedItem.style.backgroundColor = "#D6D6B5"}
				else{document.getElementById(sSelectedProdType).style.backgroundColor = "#D6D6B5"}
			}
		}
		
		//The following SubTypes contains custom items NOT actual products
		//Add SubtypeID which contains customized items....
		var aSubTypeContainsCustomItems = new Array(11,83,85,54,55,56,57,58,119,120,59,61,3,2,121,4,5,6,7,152,153,95,100,8,174,221,28,179,198,270,271,272,273)
		
		for(var i=0;i<aSubTypeContainsCustomItems.length;i++){
			if(subType == aSubTypeContainsCustomItems[i]){
				var sFileHandleID = prodType + "" + prodCatID + "" + subType
				if(document.getElementById(sFileHandleID)){
					document.getElementById(sFileHandleID).style.backgroundColor = "#D6D6B5"
				}
				break;
			}
		}
	}else if(pageType == "Product"){
	    if (prodID == 5098) {prodID = 3183;}    //For PoleVaultUK highlighting
	    var itemID = subType + "" + prodID + "" + multiTitleProdIndex //For regular product pages
		var altItemID = prodType + "" + prodCatID + "" + subType //For custom product pages
		var altItem2ID = "tsidpvsystems"
		
	    if (prodType < 10) {prodType = "0" + prodType}
		InitializeMenu("pid" + prodType,0);
		P7_swapClass(1,"sid" + subType,'open2','closed2','li')
		if(document.getElementById(itemID)){document.getElementById(itemID).style.backgroundColor = "#D6D6B5"}
		else if(document.getElementById(altItemID)){document.getElementById(altItemID).style.backgroundColor = "#D6D6B5"}
		else if(document.getElementById(altItem2ID)){document.getElementById(altItem2ID).style.backgroundColor = "#D6D6B5"}
	}
}

function P7_swapClass(){ 
	var i, x, tB, j=0, tA=new Array(), arg=P7_swapClass.arguments;
	if(document.getElementsByTagName){
		for(i=4;i<arg.length;i++){
			tB=document.getElementsByTagName(arg[i]);
			for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}
		}
		for(i=0;i<tA.length;i++){
			if(tA[i].className){
				if(tA[i].id==arg[1]){
					if(arg[0]==1){
						tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
					else{tA[i].className=arg[2];}
				}
				else if(arg[0]==1 && arg[1]=='none'){
					if(tA[i].className==arg[2] || tA[i].className==arg[3]){
						tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
					}
					else if(tA[i].className==arg[2]){tA[i].className=arg[3];}
				}
			}
		}
}
// the following PVII function writes the styles that control menu hiding and showing
// so that browsers with script disabled can see a fully expanded menu without having to toggle
// the entire menu onLoad, allowing the onLoad event to simply expose a single menu
function P7_writeStyles(a){
	var tS="<sty"+"le type=\"text/css\">";
	tS+="\n"+a+"\n<"+"/sty"+"le>";document.write(tS);
}
P7_writeStyles('.closed ul{display:none;}.open ul{display:block;}.closed2 ul{display:none;}.open2 ul{display:block;}.closed3 ul {display:none;}.open3 ul {display:block;}');


function m(obj) {
     var o = obj.parentNode.getElementsByTagName("dfn")[0];
	 var h = obj.parentNode.getElementsByTagName("ins")[0];
	 if(o.className == ""||o.className == "db"){
	    o.className = "dn";
		h.className = "";
	 }
	 else {
	    o.className = "db";
	    h.className = "";
	 }
}