// 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 + ""

// ** 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


// 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
	ThisGrandChildY = -1
	
	// We identify if this is the first item (dictates X position)
	if (ParentCount == 0) {
		ThisParentX = FirstX
		//alert(ChildWidth);
	} else {
		ThisParentX = ThisParentX + Parents[ParentCount-1].Width
     	//alert(ChildWidth);
	}

	// 
	if (ParentCount == (Parents.length-1)) {
		ChildWidth= (Parents[Parents.length-1].Width-2)
		//alert(ChildWidth); // for development - 
	}
	

	// 
	if (ParentCount == (Parents.length-2)) {
		GrannyLeft = (ChildWidth-(ChildWidth*2)+1)
		GreatGrannyLeft = (GrandChildWidth-(GrandChildWidth*2))
		//alert(GrannyLeft); // for development - 
	} else if (ParentCount == (Parents.length-1)) {
	    GrannyLeft = (ChildWidth-(ChildWidth*2+ChildWidth/2))
		GreatGrannyLeft = (GrandChildWidth-(GrandChildWidth*2+GrandChildWidth/2))
	} else {
		GrannyLeft = ChildWidth+1		
		if (ie4) {
			GreatGrannyLeft = GrandChildWidth-1	
		} else {
			GreatGrannyLeft = GrandChildWidth+1		
		}
	}
	

	
	//alert(CurrentX);
	
	
	// This is the base div for the parent
	document.write('<td width='+Parents[ParentCount].Width+' ><'+TagLabel+' align="center" id="'+Parents[ParentCount].ID+'" name="'+Parents[ParentCount].ID+'" style="height:'+ParentsHeight+'px; width:'+Parents[ParentCount].Width+'; border-left:1px solid #0B3D91; border-right:1px solid #0B3D91;left:'+ChildWidth+'px;"  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('<A HREF="javascript://" 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 (CurrentHost != "www.haltonhealthcare.com") {
						
						
						if (Parents[ChildCount].URL.indexOf("http") != -1) {
						
											
							document.write('<a href="'+Parents[ParentCount].URL+'" id="'+Parents[ParentCount].ID+'_link" class=DropDownLink'+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
						} else {
							document.write('<a href="http://www.haltonhealthcare.com/'+Parents[ParentCount].URL+'" id="'+Parents[ParentCount].ID+'_link" class=DropDownLink'+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
						}
					
					
					} else {
					document.write('<a href="/dev/'+Parents[ParentCount].URL+'" id="'+Parents[ParentCount].ID+'_link" class=DropDownLink'+TargetOutput(Parents[ParentCount].URL)+'>'+Parents[ParentCount].Label+'</a>&nbsp;&nbsp;&nbsp;</'+TagLabel+'>');
					}
	
	document.write('</'+TagLabel+'>')
	
	
	// This is the base div for the children
	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();">');
	
	
	// 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) {

		// 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)+'>'+Children[ChildCount].Label+'</a>')
		
		// If the page is NOT hosted at halton (ie the recruitingsite.com pages)
					} else if (CurrentHost != "www.haltonhealthcare.com") {
						
						
						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)+'>'+Children[ChildCount].Label+'</a></'+TagLabel+'>');
						} else {
							document.write('<a href="http://www.haltonhealthcare.com/'+Children[ChildCount].URL+'" id="'+Children[ChildCount].ID+'_link" class=DropDownLink'+TargetOutput(Children[ChildCount].URL)+'>'+Children[ChildCount].Label+'</a></'+TagLabel+'>');
						}
					
					
					} else {
					document.write('<a href="'+SlashMark+Children[ChildCount].URL+'" id="'+Children[ChildCount].ID+'_link" class=DropDownLink'+TargetOutput(Children[ChildCount].URL)+'>'+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>')
						
				// This is the base div for the grandchildren of this parent 
				document.write('<'+TagLabel+' ID="'+Children[ChildCount].ID+'_lineage" STYLE="border-top:0px solid #00804E; 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;);">');


			// We now loop through the grandchildren object
			for (GrandChildCount = 0;GrandChildCount<GrandChildren.length;GrandChildCount++) {
				
			
				
				
				//DevAlert("GrandChildren[GrandChildCount].Child-"+GrandChildren[GrandChildCount].Child);
				
				// 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) {
					OutputLink(GrandChildren[GrandChildCount].Child,Children[ChildCount].ID,GrandChildren[GrandChildCount].ID,GrandChildren[GrandChildCount].URL,GrandChildren[GrandChildCount].Label,GrandChildWidth,GrandChildHeight,GrandChildCount,"GrandChild");
					
						//ThisGrandChildY = ThisChildY
						
						// This is the base div for the greatgrandchildren of this parent 
						document.write('<'+TagLabel+' ID="'+GrandChildren[GrandChildCount].ID+'_lineage" STYLE="position:absolute; z-index:100; width:'+GreatGrandChildWidth+'; left: '+GreatGrannyLeft+'px; '+YValueLabel+': '+ThisGrandChildY+'px; visibility:'+VisibilityHidden+';" onmouseover="GrandChildMouseOver(&quot;'+GrandChildren[GrandChildCount].ID+'&quot;,&quot;'+GrandChildCount+'&quot;);"  onmouseout="GrandChildMouseOut(&quot;'+GrandChildren[GrandChildCount].ID+'&quot;,&quot;'+GrandChildCount+'&quot;);">');

					
					
	
						// We now loop through the grandchildren object
						for (GreatGrandChildCount = 0;GreatGrandChildCount<GreatGrandChildren.length;GreatGrandChildCount++) {
			
							// If our Greatgrandchildren object has a child value the same as our grandchild, then we output a link

							if (GreatGrandChildren[GreatGrandChildCount].Child == GrandChildren[GrandChildCount].ID) {
							OutputLink(GreatGrandChildren[GreatGrandChildCount].Child,GrandChildren[GrandChildCount].ID,GreatGrandChildren[GreatGrandChildCount].ID,GreatGrandChildren[GreatGrandChildCount].URL,GreatGrandChildren[GreatGrandChildCount].Label,GreatGrandChildWidth,GreatGrandChildHeight,GreatGrandChildCount,"GreatGrandChild");
						
						
							}
						
						}
						
					// Dev only
					document.write('</'+TagLabel+'>');
					
					
			// We now close up tags, and reset/rebuild height values
			ThisGrandChildY = (ThisGrandChildY + GrandChildHeight);
				}
				
				
			
			
			}
			
			// We now close up tags, and reset/rebuild height values
			ThisChildY = (ThisChildY + ChildHeight);
			document.write("</"+TagLabel+">");
			
		}
		
	}
document.write("</"+TagLabel+">");
	document.write('</'+TagLabel+'></td>');
}


//alert(CurrentHost); // for development - 

//DevAlert(DevCSVOutput); // for development - 

function MO(P,C) {

	
			alert("Highlight:"+P+","+C);

	

}

