/* 
	This function changes the background colour, and adds the second nav to a div area
*/

function showObj(ObjIndex, ObjDiv) {
	var Obj = (document.getElementById) ? document.getElementById(ObjDiv) : eval("document.all['" + ObjDiv + "']");
	Obj.className = navArray[ObjIndex][0][1];
	//Obj.style.backgroundColor = navArray[ObjIndex][0][1];
	Obj.innerHTML = buildnav(ObjIndex);
}

/*
	creates the nav
*/
function buildnav(ObjIndex){
	htmlnav = '<ul>';
	for (x = 1; x < navArray[ObjIndex].length; x++) {
		htmlnav += '<li><a href="'+navArray[ObjIndex][x][1]+'">'+navArray[ObjIndex][x][0]+'</a></li>';
		if (x < (navArray[ObjIndex].length-1)) {
			htmlnav += '<li>:</li>';
		}
	}
	htmlnav += '</ul>';
	return htmlnav;
}

/* 
	show the nav of the current page based on the name of the page 
*/

function do_shownav(str,ObjDiv) {
	for (i = 0; i < navArray.length; i++) {
		if (navArray[i][0][0] == str) {
			showObj(i,ObjDiv);
			break;
		}
	}
	
}

function defaulttext(obj,type,defaultvalue){
	
	if (type==1){
		if (obj.value == defaultvalue){
			obj.value = '';
		}
	}
	if (type==2){
		if (obj.value == ''){
			obj.value = defaultvalue;
		}
	}
}


/* this chnages the state of the moused over nav item */
function selectedNav(selected, state) {
	if (state == 1) {
		document.getElementById(selected).className = 'topnav-selected';
	}
	
	else {
		document.getElementById(selected).className = 'topnav';
	}
}

/* this chnages the state of the moused over nav item */
function selectedSecondNav(selected, state) {
	if (state == 1) {
		document.getElementById(selected).className = 'second-nav-item-selected';
	}
	
	else {
		document.getElementById(selected).className = 'second-nav-item';
	}
}

/* this chnages the state of the moused over nav item */
function selectedThirdNav(selected, state) {
	if (state == 1) {
		document.getElementById(selected).className = 'third-nav-item-selected';
	}
	
	else {
		document.getElementById(selected).className = 'third-nav-item';
	}
}
