
image1 = new Image();
image1.src = "/images/arrowGoldRotated.gif";

//detect browser and make adjustments

var thisbrowser = "";
browserDetect();

function browserDetect() {
	if (document.layers) thisbrowser="NN4";
	if (document.all) thisbrowser="ie"
	if (!document.all && document.getElementById) thisbrowser="NN6";
}

function getElement(name) {
	if (thisbrowser == 'ie') return document.all[name];
	else if (thisbrowser == 'NN6') return document.getElementById(name);
	if (thisbrowser == 'NN4') return eval("document."+name);
}

//end detect browser

var firstArray = new Array();
var aboutArray = new Array();
var helpArray = new Array();
var contactArray = new Array();
var frenchArray = new Array();
var legalArray = new Array();

//**********************************************//
// EDITABLE INFORMATION							//
//**********************************************//

//FIRST LEVEL NAV
//"dirs" are names of directories
//"names" are display names on page
firstArray["dirs"] = new Array("about","help","contact","french","legal");
firstArray["names"] = new Array("about us","get help","contact us","français","legal");

//SECOND LEVEL NAV
//"page" are filenames of pages
//"names" are display names on page
aboutArray["pages"] = new Array("demo.shtml","municipalities.shtml","vendors.shtml","partners.shtml");
aboutArray["names"] = new Array("demo","municipalities","vendors","rbc / teranet strategic alliance");
helpArray["pages"] = new Array("faq.shtml","technical.shtml");
helpArray["names"] = new Array("faq","technical inquiries");
contactArray["pages"] = new Array("contact.shtml");
contactArray["names"] = new Array("contact us");
legalArray["pages"] = new Array("privacy.shtml","security.shtml","terms.shtml");
legalArray["names"] = new Array("privacy","security","terms");
frenchPage = "http://www.paietickets.ca";
aboutPage = "/about/partners.shtml";
contactPage = "/contact/contact.shtml";


//**********************************************//
// END EDITABLE INFORMATION			//
//**********************************************//

var secondArray = new Array();
secondArray["about"] = aboutArray;
secondArray["help"] = helpArray;
secondArray["contact"] = contactArray;
secondArray["legal"] = legalArray;

//get path
var directories = window.location.href.split("/");
var firstDir = "";
var secondDir = "";
//these numbers will have to change when not working locally!!!
if (directories.length > 4) {
	firstDir = directories[3];
	secondDir = directories[4];
}

function isFrench(dir) {
	return (dir == "french");
}

function isAbout(dir) {
	return (dir == "about");
}

function isContact(dir) {
	return (dir == "contact");
}

function doNav() {
	//cycle through first level nav elements
	for (var i=0; i<firstArray["dirs"].length; i++) {
		var dir = firstArray["dirs"][i];
		var cell = getElement(dir)
		var s = "";
		
		if (dir == firstDir) s += "<image src='/images/arrowGoldRotated.gif'>&nbsp;&nbsp;";
		else s += "<image src='/images/arrowGrey.gif'>&nbsp;&nbsp;";
		
		if (dir == firstDir) cell.className = "selectedFirst";
		else cell.className = "unSelectedFirst";
		
		if (isFrench(dir)) 
		{
			s += "<a class='navLinkFirstUnselected' href='" + frenchPage + "'>";
		}
		else if (isAbout(dir)) 
		{		    
		    //s += "<a class='navLinkFirstSelected' href='javascript:switchFirst(\"" + dir + "\")'>";		    
		    s += "<a class='navLinkFirstUnselected' href='" + aboutPage + "'>";
		}
		else if (isContact(dir)) 
		{		    		    
		    s += "<a class='navLinkFirstUnselected' href='" + contactPage + "'>";
		}				
		else if (dir == firstDir) 
		{
			s += "<a class='navLinkFirstSelected' href='javascript:switchFirst(\"" + dir + "\")'>";
		}
		else 
		{
			s += "<a class='navLinkFirstUnselected' href='javascript:switchFirst(\"" + dir + "\")'>";
		}
		
		s += firstArray["names"][i];
		s += "</a>";
		cell.innerHTML = s;		
	}

	if (firstDir != "" && !isFrench(firstDir) && !isAbout(firstDir) && !isContact(firstDir)) {
		var secArray = new Array();
		secArray = secondArray[firstDir];
		//cycle through second level nav elements
		for (var i=0; i<10; i++) {
			var cell = getElement("second"+i);
			if (i < secArray["pages"].length) {
				var dir = secArray["pages"][i];
				var s = "";
				if (dir == secondDir) s += "<image src='/images/arrowGold.gif'>&nbsp;&nbsp;";
				else s += "<image src='/images/arrowGrey.gif'>&nbsp;&nbsp;";
				
				if (dir == secondDir) cell.className = "selectedSecond";
				else cell.className = "unselectedSecond";
				
				if (dir == secondDir) s += "<a class='navLinkSecondSelected' href='/" + firstDir + "/" + secArray["pages"][i] + "'>";
				else s += "<a class='navLinkSecondUnselected' href='/" + firstDir + "/" + secArray["pages"][i] + "'>";
				
				s += secArray["names"][i];
				s += "</a>";
				cell.innerHTML = s;
			}
			else if (i == secArray["pages"].length) {
				cell.className = "empty";
				cell.innerHTML = "&nbsp;";
			}
			else {
				cell.innerHTML = "";
			}
		}
	}
}
function switchFirst(name) {
	firstDir = name;
	doNav();
}