// Generic Variable Declarations
DropDownList = Parent[0];
AltDropDown = ""
ThisChildY = 0
DevCSVOutput = "" // DevCSVOutput is a variable used to output a csv of the drop down items for development purposes
SelectPresent = "" // This is set to 'true' on pages where a select box needs to be hidden for the drop down
CurrentHost = window.location.host + ""
ChildLeft = ChildLeft + FirstX
CurrentPagesParent = ""
CurrentChild = ""
CurrentChildID = ""
HasGrandChildren =  false
SlashMark= ""
ParentName = ""

if (ParentBorderLeft == "") {
	ParentBorderLeft = ParentBackground
}
if (ParentBorderRight == "") {
	ParentBorderRight = ParentBackground
}
if (ParentBorderLeftHighlight == "") {
	ParentBorderLeftHighlight = ParentBackgroundHighlight
}
if (ParentBorderRightHighlight == "") {
	ParentBorderRightHighlight = ParentBackgroundHighlight
}
if (ParentBorderTop == "") {
	ParentBorderTop = ParentBackground
}
if (ParentBorderTopHighlight == "") {
	ParentBorderTopHighlight = ParentBackgroundHighlight
}
if (ParentBorderTop == "") {
	ParentBorderTop = ParentBackground
}
if (ParentBorderBottomHighlight == "") {
	ParentBorderBottomHighlight = ParentBackgroundHighlight
}


if (ChildBorderLeft == "") {
	ChildBorderLeft = ChildBackground
}
if (ChildBorderRight == "") {
	ChildBorderRight = ChildBackground
}
if (ChildBorderLeftHighlight == "") {
	ChildBorderLeftHighlight = ChildBackgroundHighlight
}
if (ChildBorderRightHighlight == "") {
	ChildBorderRightHighlight = ChildBackgroundHighlight
}
if (ChildBorderTop == "") {
	ChildBorderTop = ChildBackground
}
if (ChildBorderTopHighlight == "") {
	ChildBorderTopHighlight = ChildBackgroundHighlight
}
if (ChildBorderTop == "") {
	ChildBorderTop = ChildBackground
}
if (ChildBorderBottomHighlight == "") {
	ChildBorderBottomHighlight = ChildBackgroundHighlight
}


if (GChildBorderLeft == "") {
	GChildBorderLeft = GChildBackground
}
if (GChildBorderRight == "") {
	GChildBorderRight = GChildBackground
}
if (GChildBorderLeftHighlight == "") {
	GChildBorderLeftHighlight = GChildBackgroundHighlight
}
if (GChildBorderRightHighlight == "") {
	GChildBorderRightHighlight = GChildBackgroundHighlight
}
if (GChildBorderTop == "") {
	GChildBorderTop = GChildBackground
}
if (GChildBorderTopHighlight == "") {
	GChildBorderTopHighlight = GChildBackgroundHighlight
}
if (GChildBorderTop == "") {
	GChildBorderTop = GChildBackground
}
if (GChildBorderBottomHighlight == "") {
	GChildBorderBottomHighlight = GChildBackgroundHighlight
}


//alert(ThisFileName); // for development - 


// ** HOW IT WORKS **
// DropDownContents.js consists of functions (contained in DropDownFunctions.js) that build an object for each navigations level - Parent, Child, GrandChild
// In this file, we now loop through each parent, then it's child, then its grandchild, outputting links as we go

// Most specs (ie div widths. heights) are declared in the DropDownContent.jjs file
document.write("<table cellpadding=0 cellspacing=0 border=0 bgcolor=ffffff width="+ParentWidth+"><tr height=10><td></td></tr>")
// First we loop through the Parent object
for (ParentCount = 0;ParentCount<Parents.length;ParentCount ++) {
	
	
	

	
	// DevCSVOutput is a variable used to output a csv of the drop down items for development purposes	
	DevCSVOutput = DevCSVOutput + Parents[ParentCount].Label + "," + Parents[ParentCount].URL + "\r"
	
	ThisChildY = -1

	// We identify if this is the first item (dictates X or Y position)
	if (ParentCount == 0) {
		ThisParentX = FirstX
		ThisParentY = YDistanceFromTop
		ThisParentsHeight = ParentsHeight
		//alert("First Instance"+ThisParentsHeight); // for development -
		//alert(ChildWidth);
	} else {
	
	BreakSearch = Parents[ParentCount-1].Label
	if (BreakSearch.indexOf("<br>") != -1) {
		BreakSearch = BreakSearch.split("<br>")
		NumberBreaks = BreakSearch.length-1
		ThisParentY = ThisParentY + ((ParentsHeight-3) * NumberBreaks)
		//ThisParentsHeight = (ParentsHeight * (NumberBreaks+1))
		//alert("Break"+ThisParentsHeight+"NumberBreaks:"+NumberBreaks); // for development -
	}
	
		ThisParentX = ThisParentX + Parents[ParentCount-1].Width
		ThisParentY = ThisParentY + ParentsHeight
		ThisParentsHeight = ParentsHeight
     	//alert("No break"+ThisParentsHeight); // for development -
		//alert(ChildWidth);
	}
	
	CurrentBreakSearch = Parents[ParentCount].Label
	if (CurrentBreakSearch.indexOf("<br>") != -1) {
		CurrentBreakSearch = CurrentBreakSearch.split("<br>")
		CurrentNumberBreaks = CurrentBreakSearch.length-1
		ThisParentsHeight = ((ParentsHeight-3) * (CurrentNumberBreaks+1))
		//alert("Break"+ThisParentsHeight+"CurrentNumberBreaks:"+CurrentNumberBreaks); // for development -
	}
	
		//ThisParentsHeight = ParentsHeight
     	//alert("No break"+ThisParentsHeight); // for development -
		
	 //alert(Parents[ParentCount].Label+" "+ThisParentsHeight); // for development - 
	
	// 
	if (ParentCount == (Parents.length-1)) {
		ChildWidth= (Parents[Parents.length-1].Width-2)
		//alert(ChildWidth); // for development - 
	}
	

	// 
	if ((ParentCount == (Parents.length-2)) && (ParentDisplayType == "horizontal")) {
		//GrannyLeft = (RightBarStarts-(RightBarStarts*2)+1)
		GrannyLeft = (ChildWidth-(ChildWidth*2)+1)
		//alert(GrannyLeft); // for development - 
	} else if ((ParentCount == (Parents.length-1)) && (ParentDisplayType == "horizontal")) {
		//GrannyLeft = (RightBarStarts-(RightBarStarts*2+RightBarStarts/2))
	    GrannyLeft = (ChildWidth-(ChildWidth*2+ChildWidth/2))
	} else {
		//GrannyLeft = RightBarStarts+1		
		GrannyLeft = ChildWidth+1	
	}
	
	// We figure out the filename to identify which Parent to highlight
	TargetParentFull = Parents[ParentCount].URL + " "

	if (TargetParentFull.indexOf("/") == -1) {
		TargetParentFull = TargetParentFull.split("\\")
		TargetParent = TargetParentFull[TargetParentFull.length-1]
		TargetParent = TargetParent.replace(" ","")
	} else {
		TargetParentFull = TargetParentFull.split("/")
		TargetParent = TargetParentFull[TargetParentFull.length-1]
		TargetParent = TargetParent.replace(" ","")
	}
	
	//alert(ThisFileName + "==" + TargetParent); // for development - 
	
	//alert(CurrentX);
	if (ThisFileName == Parents[ParentCount].URL) {
		CurrentPagesParent = Parents[ParentCount].ID
		TemplateType = "sub1"
		ThisParentBorderLeft = ParentBorderLeftCurrent
		ThisParentBorderRight = ParentBorderRightCurrent
		ThisParentBorderTop = ParentBorderTopCurrent
		ThisParentBackground = " background: #"+ParentBackgroundCurrent+";"
		ThisParentText = " style='color="+ParentTextCurrent+"' "
		//alert("highlight " + ParentCount); // for development - 
	} else {
		ThisParentBorderLeft = ParentBorderLeft
		ThisParentBorderRight = ParentBorderRight
		ThisParentBorderTop = ParentBorderTop
		ThisParentBackground = ""
		ThisParentText = ""
	}
	
	
	// This is the base div for the parent
	document.write('<tr height='+ThisParentsHeight+'><td width='+Parents[ParentCount].Width+'><'+TagLabel+' id="'+Parents[ParentCount].ID+'" name="'+Parents[ParentCount].ID+'" style="height:'+ThisParentsHeight+'px; width:'+Parents[ParentCount].Width+'; border-left:1px solid #'+ThisParentBorderLeft+'; border-right:1px solid #'+ThisParentBorderRight+';border-top:1px solid #'+ThisParentBorderTop+'; left:'+ChildWidth+'px; '+ThisParentBackground+';"  onmouseover="ParentMouseOver(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//HideSelect();" onmouseout="ParentMouseOut(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//ShowSelect();">');
	
	// This is the parents link
	if (Parents[ParentCount].URL == "") {
	
		
		document.write('&nbsp;&nbsp;<A HREF="javascript://" id="'+Parents[ParentCount].ID+'_link" '+ThisParentText+' onmouseout="ParentMouseOut(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);" onmouseover="ParentMouseOver(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);" class="BlueMenuItems" '+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>')
	
	// If the page is NOT hosted at halton (ie the recruitingsite.com pages)
	} else if (Parents[ParentCount].URL.indexOf("http") != -1) {
						
											
							document.write('<a href="'+Parents[ParentCount].URL+'" id="'+Parents[ParentCount].ID+'_link" '+ThisParentText+' class=DropDownLink'+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
	} else {
							document.write('<a href="'+RootFolder+Parents[ParentCount].URL+'" id="'+Parents[ParentCount].ID+'_link" '+ThisParentText+' class=DropDownLink'+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
	
	}
					
		
	
	//alert(eval(Parents[ParentCount].ID+'_link')); // for development - 
	
	document.write('</'+TagLabel+'>')
	//document.write('</'+TagLabel+'></tr>')
	
	
	// This is the base div for the children
	document.write('<'+TagLabel+' ID="'+Parents[ParentCount].ID+'_lineage" STYLE="border-top:1px solid #'+ChildBorderTop+'; position:absolute; left: '+ChildLeft+'; z-index: 100; width:'+ChildWidth+';  '+YValueLabel+': '+ThisParentY+'px; visibility:'+VisibilityHidden+'; x-index:100;" onmouseover="ParentMouseOver(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//HideSelect();" onmouseout="ParentMouseOut(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//ShowSelect();">');
	//document.write('<'+TagLabel+' ID="'+Parents[ParentCount].ID+'_lineage" STYLE="border-top:1px solid #00804E; position:absolute; z-index: 100; width:'+ChildWidth+';  '+YValueLabel+': '+YDistanceFromTop+'px; visibility:'+VisibilityHidden+'; z-index:100;" onmouseover="ParentMouseOver(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//HideSelect();" onmouseout="ParentMouseOut(&quot;'+Parents[ParentCount].ID+'&quot;,&quot;'+ParentCount+'&quot;);//ShowSelect();">');
	
	//alert("Children.length - " + Children.length); // for development - 
	// We now loop through the children object
	for (ChildCount = 0;ChildCount<Children.length;ChildCount++) {

		
		// If our children object has a parent value the same as our parent, then we output a link
		if (Children[ChildCount].Parent == Parents[ParentCount].ID) {
		
		Parents[ParentCount].HasChildren = true
			// We figure out the filename to identify which Parent to highlight
		TargetChildFull = Children[ChildCount].URL + " "

		if (TargetChildFull.indexOf("/") == -1) {
			TargetChildFull = TargetChildFull.split("\\")
			TargetChild = TargetChildFull[TargetChildFull.length-1]
			TargetChild = TargetChild.replace(" ","")
			TargetChildDirectory =  TargetChildFull[TargetChildFull.length-2] + "\\" + TargetChild
		} else {
			TargetChildFull = TargetChildFull.split("/")
			TargetChild = TargetChildFull[TargetChildFull.length-1]
			TargetChild = TargetChild.replace(" ","")
			TargetChildDirectory =  TargetChildFull[TargetChildFull.length-2] + "/" + TargetChild
		}
		//alert(ThisFileName); // for development - 
			if (ThisFileName == Children[ChildCount].URL) { // we identify the current parent to highlight
				//alert("highlight " + Parents[ParentCount].ID); // for development - 
				
				//CurrentPagesParent = Parents[ParentCount].ID
				TemplateType = "sub2"
				//SetCurrentParent(Parents[ParentCount].ID,ParentCount)
				MyLineage = "child"
				
				CurrentChild = "<table class=sl_table border=2 bordercolor=EC8000 cellpadding=15 cellspacing=0><td><span class='sl_title'>"+Children[ChildCount].Label + "</span><br><br>"
				CurrentChildID = Children[ChildCount].ID
				
			}
			
			
		// DevCSVOutput is a variable used to output a csv of the drop down items for development purposes
		DevCSVOutput = DevCSVOutput + "  " + Children[ChildCount].Label + "," + Children[ChildCount].URL + "\r"
		

		//This is the invdividual childs div and link
		document.write('<'+TagLabel+' id="'+Children[ChildCount].ID+'" class="DropDown" style="height:'+ChildHeight+'; z-index: 100; width:'+ChildWidth+';" onmouseover="ChildMouseOver(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);" onmouseout="ChildMouseOut(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);"><table cellpadding=0 cellspacing=0 width='+ChildWidth+'><td>')
		
		// If the url is empty, we void it with a blank javascript
		if (Children[ChildCount].URL == "") {
			document.write('<a href="javascript://'+Children[ChildCount].URL+'" id="'+Children[ChildCount].ID+'_link" class=DropDownLink'+TargetOutput(Children[ChildCount].URL)+'   style="color:'+ChildText+';">'+Children[ChildCount].Label+'</a>')
		
		// If the page is NOT hosted at halton (ie the recruitingsite.com pages)
					} else if (Children[ChildCount].URL.indexOf("http") != -1) {
						
											
							document.write('<a href="'+Children[ChildCount].URL+'" id="'+Children[ChildCount].ID+'_link" class=DropDownLink'+TargetOutput(Children[ChildCount].URL)+'  style="color:'+ChildText+';">'+Children[ChildCount].Label+'</a></'+TagLabel+'>');
					
					} else {
							document.write('<a href="'+RootFolder+Children[ChildCount].URL+'" id="'+Children[ChildCount].ID+'_link" class=DropDownLink'+TargetOutput(Children[ChildCount].URL)+'   style="color:'+ChildText+';">'+Children[ChildCount].Label+'</a></'+TagLabel+'>');
					}
					
					
					
					//document.write(GrandChildren[GrandChildCount].Label);		
					
				
		
		document.write('</td></table></'+TagLabel+'>');
			
			//document.write('<a href="" name="'+Children[ChildCount].Label+'" onMouseOver="MO(Children['+ChildCount+'].Parent,Children['+ChildCount+'].Label)">');
			//document.write(Children[ChildCount].Label)
			//document.write('</a>')
				
				ThisBorderTop = 'border-top:1px solid #'+GChildBorderTop
				
				// This is the base div for the grandchildren of this parent 
				//document.write('<'+TagLabel+' ID="'+Children[ChildCount].ID+'_lineage" STYLE="'+ThisBorderTop+'; position:absolute; z-index:100; width:'+GrandChildWidth+'; left: '+GrannyLeft+'px; '+YValueLabel+': '+ThisChildY+'px; visibility:'+VisibilityHidden+';" onmouseover="ChildMouseOver(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);"  onmouseout="ChildMouseOut(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);">');

document.write('<'+TagLabel+' ID="'+Children[ChildCount].ID+'_lineage" STYLE="position:absolute; z-index:100; width:'+GrandChildWidth+'; left: '+GrannyLeft+'px; '+YValueLabel+': '+ThisChildY+'px; visibility:'+VisibilityHidden+';" onmouseover="ChildMouseOver(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);"  onmouseout="ChildMouseOut(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);">');
//document.write('<'+TagLabel+' ID="'+Children[ChildCount].ID+'_lineage" STYLE="position:absolute; z-index:100; width:'+GrandChildWidth+'; left: '+GrannyLeft+'px; '+YValueLabel+': '+ThisChildY+'px; visibility:'+VisibilityHidden+';" onmouseover="ChildMouseOver(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);"  onmouseout="ChildMouseOut(&quot;'+Children[ChildCount].ID+'&quot;,&quot;'+ChildCount+'&quot;);">');
			//alert("GrandChildren.length - "+GrandChildren.length); // for development - 
			
			// We now loop through the grandchildren object
			for (GrandChildCount = 0;GrandChildCount<GrandChildren.length;GrandChildCount++) {
			
				//DevAlert("GrandChildren[GrandChildCount].Child-"+GrandChildren[GrandChildCount].Child);
				CurrentGrandChildCount = 0
				// If our grandchildren object has a child value the same as our child, then we output a link
				if (GrandChildren[GrandChildCount].Child == Children[ChildCount].ID) {
					
					CurrentGrandChildCount = CurrentGrandChildCount + 1
					
					if (CurrentChildID == GrandChildren[GrandChildCount].Child) {
						CurrentChild = CurrentChild + "<a href='"+RootFolder+ GrandChildren[GrandChildCount].URL +"'>" + GrandChildren[GrandChildCount].Label + "</a><br>"
						HasGrandChildren = true
					}
					
						// We figure out the filename to identify which Parent to highlight
					TargetGrandChildFull = GrandChildren[GrandChildCount].URL + " "

					if (TargetGrandChildFull.indexOf("/") == -1) {
						TargetGrandChildFull = TargetGrandChildFull.split("\\")
						TargetGrandChild = TargetGrandChildFull[TargetGrandChildFull.length-1]
						TargetGrandChild = TargetGrandChild.replace(" ","")
						TargetGrandChildDirectory =  TargetGrandChildFull[TargetGrandChildFull.length-2] + "\\" + TargetChild
					} else {
						TargetGrandChildFull = TargetGrandChildFull.split("/")
						TargetGrandChild = TargetGrandChildFull[TargetGrandChildFull.length-1]
						TargetGrandChild = TargetGrandChild.replace(" ","")
						TargetGrandChildDirectory =  TargetGrandChildFull[TargetGrandChildFull.length-2] + "/" + TargetChild
					}
		
					if (ThisFileName == TargetGrandChild) { // we identify the current parent to highlight
					//alert("highlight " + Parents[ParentCount].ID); // for development - 
					CurrentPagesParent = Parents[ParentCount].ID
					TemplateType = "sub2"
					SetCurrentParent(Parents[ParentCount].ID,ParentCount)
					MyLineage= "grandchild"
					}
					// DevCSVOutput is a variable used to output a csv of the drop down items for development purposes
					DevCSVOutput = DevCSVOutput + "    " + GrandChildren[GrandChildCount].Label + "," + GrandChildren[GrandChildCount].URL + "\r"
					
					if (GrandChildCount == 0) {
					BorderTop = 0
					} else {
					BorderTop = 0
					}
					
					//This is the invdividual grandchilds div 			
					document.write('<'+TagLabel+' ID="'+GrandChildren[GrandChildCount].ID+'" class="DropDown" style="height:'+GrandChildHeight+'; z-index: 100; width:'+GrandChildWidth+'" onmouseover="GrandChildMouseOver(&quot;'+GrandChildren[GrandChildCount].ID+'&quot;,&quot;'+GrandChildCount+'&quot;);" onmouseout="GrandChildMouseOut(&quot;'+GrandChildren[GrandChildCount].ID+'&quot;,&quot;'+GrandChildCount+'&quot;);">');
					
					// This is the individual grandchilds link
					
					// If the grandchild does not have a link attached to it, we void the href with a blank javascript call
					if (GrandChildren[GrandChildCount].URL == "") {
					document.write('<a href="javascript://" id="'+GrandChildren[GrandChildCount].ID+'_link" class=DropDownLink'+TargetOutput(GrandChildren[GrandChildCount].URL)+'>'+GrandChildren[GrandChildCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
					
					// If the page is NOT hosted at halton (ie the recruitingsite.com pages)
					} else if (CurrentHost != LiveDomain) {
						
						
						if (GrandChildren[GrandChildCount].URL.indexOf("http") != -1) {
						
											
							document.write('<a href="'+GrandChildren[GrandChildCount].URL+'" id="'+GrandChildren[GrandChildCount].ID+'_link" class=DropDownLink'+TargetOutput(GrandChildren[GrandChildCount].URL)+'>'+GrandChildren[GrandChildCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
						} else {
							document.write('<a href="'+RootFolder+GrandChildren[GrandChildCount].URL+'" id="'+GrandChildren[GrandChildCount].ID+'_link" class=DropDownLink'+TargetOutput(GrandChildren[GrandChildCount].URL)+'>'+GrandChildren[GrandChildCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
						}
					
					
					} else {
					document.write('<a href="'+SlashMark+GrandChildren[GrandChildCount].URL+'" id="'+GrandChildren[GrandChildCount].ID+'_link" class=DropDownLink'+TargetOutput(GrandChildren[GrandChildCount].URL)+'>'+GrandChildren[GrandChildCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
					}
					
					
					
				
				}
				
			//document.write(GrandChildren[GrandChildCount].Label);		
					
			}
			
			//if (CurrentGrandChildCount != 0) {
					//alert("line"); // for development - 
			//alert('document.'+DocumentObject+OpenObjBracket+Children[ChildCount].ID+'_lineage'+CloseObjBracket+'.style.borderTop = "1px solid #'+GChildBorderTop+'"');
			//eval('document.'+DocumentObject+OpenObjBracket+Children[ChildCount].ID+'_lineage'+CloseObjBracket+'.style.borderTop = "1px solid #'+GChildBorderTop+'"');
					//eval(Children[ChildCount].ID+'_lineage')
			//}
			// We now close up tags, and reset/rebuild height values
			ThisChildY = (ThisChildY + ChildHeight);
			document.write("</"+TagLabel+">");
			
		}
		
	}
document.write("</"+TagLabel+"></tr>");
	document.write('</'+TagLabel+'>');
}

//alert(CurrentHost); // for development - 

//DevAlert(DevCSVOutput); // for development - 

if (CurrentChild != "") {
	CurrentChild = CurrentChild + "<br></td></table>"
}

if (HasGrandChildren == false) {
	CurrentChild = ""
}
function MO(P,C) {

	
			alert("Highlight:"+P+","+C);

	

}

