var GrandChildren = new Array();
var Children = new Array();
var Parents = new Array();
ParentSet = false

ParentBirthCount = 0;
ChildBirthCount = 0;
GrandChildBirthCount = 0;


// We figure out the filename to identify which Parent to highlight
ThisFile = document.location + " "

if (ThisFile.indexOf("/") == -1) {
	ThisFile = ThisFile.split("\\")
} else {
	ThisFile = ThisFile.split("/")
}

ThisFileName = ThisFile[ThisFile.length-2] + "/" + ThisFile[ThisFile.length-1]
ThisFileName = ThisFileName.replace(" ","")

function DefaultPopUp(TargetPage,W,H) {

	window.open(TargetPage,'New','width='+W+',height='+H);

}


function AddGrandChild(GrandChildLabel,GrandChildURL) {

	BirthofGrandChildren(GrandChildLabel,GrandChildURL,CurrentChild,CurrentParent);

}

function GrandChild(Label,URL,Child,Parent) {

	this.Label = Label
	this.URL = URL
	this.Child = Child
	this.Parent = Parent
	this.ID = "G"+GrandChildBirthCount
	this.Status = "hidden"
	//this.HasChildren = false
	
	//DevAlert("GrandChild: "+this.Label + "=" + this.ID+";Parent="+this.Parent+";Child="+this.Child); // for development - 

}

function BirthofGrandChildren(LabelG,URLG,ChildG,ParentG) {

eval('GrandChildren['+GrandChildBirthCount+'] = new GrandChild("'+LabelG+'","'+URLG+'","'+ChildG+'","'+ParentG+'")');

GrandChildBirthCount = GrandChildBirthCount + 1;

}





function AddChild(ChildLabel,ChildURL) {

	BirthofChildren(ChildLabel,ChildURL,CurrentParent);

}

//BirthofParents();

function Child(Label,URL,Parent) {

	this.Label = Label
	this.URL = URL
	this.Parent = Parent
	this.ID = "C"+ChildBirthCount
	this.Status = "hidden"
	this.HasChildren = false

	//DevAlert("Child: "+this.Label + "=" + this.ID+";Parent="+this.Parent); // for development - 
	
}

function BirthofChildren(LabelC,URLC,ParentC) {

eval('Children['+ChildBirthCount+'] = new Child("'+LabelC+'","'+URLC+'","'+ParentC+'")');
//[0] = new Child(LabelC,URLC,ParentC);

CurrentChild = "C"+ChildBirthCount
ChildBirthCount = ChildBirthCount + 1;
//CurrentChild = LabelC

}




function Parent(Label,URL) {

	this.Label = Label
	this.URL = URL
	this.ID = "P"+ParentBirthCount
	this.Status = "hidden"
	this.HasChildren = false
	
	//DevAlert("Parent: "+this.Label + "=" + this.ID); // for development - 
		
}



function AddParent(ParentB,URLB) {

eval('Parents['+ParentBirthCount+'] = new Parent("'+ParentB+'","'+URLB+'")');
//Parents[0] = new Parent("ParentOne","about/index.html");
//Parents[1] = new Parent("ParentTwo","about/index.html");

CurrentParent = "P"+ParentBirthCount
ParentBirthCount = ParentBirthCount + 1;


}

FirstX = 0;
LastX = 0;
SecondLastX = 0;



function IDFirstXCoord() {

//alert(StringSample); // for development - 
var vers = navigator.appVersion;
vers = vers.substring(0,1);
// Netscape and IE output the screen width differently

if (navigator.userAgent.indexOf("MSIE") > 0) {
//alert(document.body.clientWidth + "x" + document.body.clientHeight);

TotalWidth = document.body.clientWidth
// We get the total width -10 to account for scrollbars

FirstX = ((document.body.clientWidth - 718)/2)
// We take off 300 for the permanent buttons
// and half it to get one figure for the title, and one for the href

LastX = TotalWidth - FirstX

} else {                                                
//alert(window.outerWidth + "x" + window.outerHeight);
TotalWidth = window.outerWidth
FirstX = ((window.outerWidth - 718)/2)
// See above


}


}

IDFirstXCoord();

// Sets a parent with current highlight
function SetCurrentParent(ParentID,ParentCountValue) {
eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.background = "#'+ParentBackgroundCurrent+'"');
		eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderLeft = "1px solid #'+ParentBorderLeftCurrent+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderRight = "1px solid #'+ParentBorderRightCurrent+'"');
eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderTop = "1px solid #'+ParentBorderTopCurrent+'"');
eval('document.'+DocumentObject+OpenObjBracket+'ParentID+"_link"'+CloseObjBracket+'.style.color = "#'+ParentTextCurrent+'"');
ParentSet = true
CurrentPagesParent = ParentID
}

function DonateNowMouseOver() {

	eval('document.'+DocumentObject+OpenObjBracket+'"donate_now"'+CloseObjBracket+'.style.background = DonateNowBackgroundHighlight');
}

function DonateNowMouseOut() {

	eval('document.'+DocumentObject+OpenObjBracket+'"donate_now"'+CloseObjBracket+'.style.background = DonateNowBackground');
}

function TopBarMouseOver(TopBarName) {
	eval('document.'+DocumentObject+OpenObjBracket+'"'+TopBarName+'"'+CloseObjBracket+'.style.color = TopBarTextHighlight');
}

function TopBarMouseOut(TopBarName) {
	eval('document.'+DocumentObject+OpenObjBracket+'"'+TopBarName+'"'+CloseObjBracket+'.style.color = TopBarText');
}

function ParentMouseOver(ParentID,ParentCountValue) {

if (ie4) {
	document.SelectLayer = eval('document.'+DocumentObject+OpenObjBracket+'"VisibleSelect"'+CloseObjBracket)
	document.SelectLayer.style.visibility = "hidden";
	}
	
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderTop = "1px solid #'+ParentBorderTopHighlight+'"');
	//alert(eval('document.'+DocumentObject+'(ParentID).id')); // for development - 
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID+"_link"'+CloseObjBracket+'.style.color = "#'+ParentTextHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.background = "#'+ParentBackgroundHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderLeft = "1px solid #'+ParentBorderLeftHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderRight = "1px solid #'+ParentBorderRightHighlight+'"');
	if (Parents[ParentCountValue].HasChildren == true) {
		eval('document.'+DocumentObject+OpenObjBracket+'ParentID+"_lineage"'+CloseObjBracket+'.style.visibility = VisibilityShown')
	}
	

	
	
	eval("Parents["+ParentCountValue+"].Status = 'visible'");
	

	
}

function ParentMouseOut(ParentID,ParentCountValue) {
	
	
	
	//CurrentPagesParent = Parents[ParentCount].ID
	if (CurrentPagesParent == Parents[ParentCountValue].ID) {
		ThisParentBorderLeft = ParentBorderLeftCurrent
		ThisParentBorderRight = ParentBorderRightCurrent
		ThisParentBorderTop = ParentBorderTopCurrent
		ThisParentBackground = ParentBackgroundCurrent
		ThisParentText = ParentTextCurrent
		//alert("highlight " + ParentCount); // for development - 
	} else {
		ThisParentBorderLeft = ParentBorderLeft
		ThisParentBorderRight = ParentBorderRight
		ThisParentBorderTop = ParentBorderTop
		ThisParentBackground = ""
		ThisParentText = ParentText
	}
	
	eval("Parents["+ParentCountValue+"].Status = 'hidden'");
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderTop = "1px solid #'+ParentBorderTopHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID+"_link"'+CloseObjBracket+'.style.color = "#'+ThisParentText+'"');
	
	
	//ParentWipe(ParentID,ParentCountValue)
	setTimeout('ParentWipe("'+ParentID+'",'+ParentCountValue+')', 20)
	
}

function ParentWipe(ParentID,ParentCountValue) {
		
	if (CurrentPagesParent == Parents[ParentCountValue].ID) {
		ThisParentBorderLeft = ParentBorderLeftCurrent
		ThisParentBorderRight = ParentBorderRightCurrent
		ThisParentBorderTop = ParentBorderTopCurrent
		ThisParentBackground = ParentBackgroundCurrent
		ThisParentText = ParentTextCurrent
		//alert("highlight " + ParentCount); // for development - 
	} else {
		ThisParentBorderLeft = ParentBorderLeft
		ThisParentBorderRight = ParentBorderRight
		ThisParentBorderTop = ParentBorderTop
		ThisParentBackground = ParentBackground
		ThisParentText = ParentText
	}
	
	if (eval("Parents["+ParentCountValue+"].Status") != 'visible') {	
	
		if (ie4) {
		document.SelectLayer = eval('document.'+DocumentObject+OpenObjBracket+'"VisibleSelect"'+CloseObjBracket)
		document.SelectLayer.style.visibility = "visible";
		}
		
	
		eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.background = "#'+ThisParentBackground+'"');
		eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderLeft = "1px solid #'+ThisParentBorderLeft+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ParentID'+CloseObjBracket+'.style.borderRight = "1px solid #'+ThisParentBorderRight+'"');
		eval('document.'+DocumentObject+OpenObjBracket+'ParentID+"_lineage"'+CloseObjBracket+'.style.visibility = VisibilityHidden')
	}
	
}

/*function displayDropDown(state) {
		dropDownToWorkWith = eval('document.'+DocumentObject +OpenObjBracket+ "functionDropDown"+CloseObjBracket + '.style');
    	dropDownToWorkWith.visibility = state;
}*/

function ChildMouseOver(ChildID,ChildCountValue) {
	
	if (ie4) {
	document.SelectLayer = eval('document.'+DocumentObject+OpenObjBracket+'"VisibleSelect"'+CloseObjBracket)
	document.SelectLayer.style.visibility = "hidden";
	}
	
	
	// Current Item Highlight
	eval('document.'+DocumentObject+OpenObjBracket+'ChildID'+CloseObjBracket+'.style.background = "#'+ChildBackgroundHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ChildID+"_link"'+CloseObjBracket+'.style.color = "#'+ChildTextHighlight+'"');
		
	// Show next drop down
	//eval('document.'+DocumentObject+OpenObjBracket+'ChildID+"_lineage"'+CloseObjBracket+'.style.visibility = VisibilityShown')
	
	eval("Children["+ChildCountValue+"].Status = 'visible'");
	
    //displayDropDown('hidden'); // disappear

	
}

function ChildMouseOut(ChildID,ChildCountValue) {

	eval('document.'+DocumentObject+OpenObjBracket+'ChildID'+CloseObjBracket+'.style.background = "#'+ChildBackground+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'ChildID+"_link"'+CloseObjBracket+'.style.color = "#'+ChildText+'"');
	
	eval("Children["+ChildCountValue+"].Status = 'hidden'");
	
	setTimeout('ChildWipe("'+ChildID+'",'+ChildCountValue+')', 200)

	//displayDropDown('visible'); // appear


	
}

function ChildWipe(ChildID,ChildCountValue) {
		
	
	
	if (eval("Children["+ChildCountValue+"].Status") != 'visible') {	
		// Show next drop down
		eval('document.'+DocumentObject+OpenObjBracket+'ChildID+"_lineage"'+CloseObjBracket+'.style.visibility = VisibilityHidden')
	}
	
}

function GrandChildMouseOver(GrandChildID,GrandChildCountValue) {
	
	if (ie4) {
	document.SelectLayer = eval('document.'+DocumentObject+OpenObjBracket+'"VisibleSelect"'+CloseObjBracket)
	document.SelectLayer.style.visibility = "hidden";
	}
	
	// Current Item Highlight
	eval('document.'+DocumentObject+OpenObjBracket+'GrandChildID'+CloseObjBracket+'.style.background = "#'+GChildBackgroundHighlight+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'GrandChildID+"_link"'+CloseObjBracket+'.style.color = "#'+GChildTextHighlight+'"');
		
	// Show next drop down
	//document.all[GrandChildID+"_lineage"].style.visibility = "visible"
	
	eval("GrandChildren["+GrandChildCountValue+"].Status = 'visible'");
	
}

function GrandChildMouseOut(GrandChildID,GrandChildCountValue) {

	eval('document.'+DocumentObject+OpenObjBracket+'GrandChildID'+CloseObjBracket+'.style.background = "#'+GChildBackground+'"');
	eval('document.'+DocumentObject+OpenObjBracket+'GrandChildID+"_link"'+CloseObjBracket+'.style.color = "#'+GChildText+'"');
	
	//eval("GrandChildren["+GrandChildCountValue+"].Status = 'hidden'");
	
	//setTimeout('GrandChildWipe("'+GrandChildID+'",'+GrandChildCountValue+')', 200)
	
}

function GrandChildWipe(GrandChildID,GrandChildCountValue) {
		
	
	if (eval("GrandChildren["+GrandChildCountValue+"].Status") != 'visible') {	
		// Show next drop down
		eval('document.'+DocumentObject+OpenObjBracket+'ChildID+"_lineage"'+CloseObjBracket+'.style.visibility = VisibilityHidden')
	}
	
}

function TargetOutput(URLtoTest) {
	
	TargetValue = ""

	if (URLtoTest.indexOf(".pdf") != -1) {
		TargetValue = " target=&quot;new&quot; "
	}
	
		if ((URLtoTest.indexOf("http") != -1) && (URLtoTest.indexOf("nygh.on.ca") == -1) && (URLtoTest.indexOf("workopolis") == -1)) {
		TargetValue = " target=&quot;new&quot; "
		
	}
	
	return TargetValue
}
