var tglFlag=0;
var lastCell='';
var lastSub=0;
lastHLCell='';
var knownPages=Array();
var knownIds=Array();
knownPages[0]='index.php';
knownPages[1]='articles/index.php';
knownPages[2]='gallery.php';
knownPages[3]='destinations.php';
knownPages[4]='contact.php';
knownPages[5]='aboutus.php';
knownPages[6]='yearbook.php';
knownPages[7]='links.php';

knownIds[0]='home';
knownIds[1]='news';
knownIds[2]='restoration';
knownIds[3]='destinations';
knownIds[4]='contact';
knownIds[5]='aboutus';
knownIds[6]='yearbook';
knownIds[7]='links';

var allPages=Array();
//bindrysvcs--
allPages[0]='index.php|home';
allPages[1]='thesis.php|bindrysvcs';
allPages[2]='magazine.php|bindrysvcs';
allPages[3]='menus.php|bindrysvcs';
allPages[4]='shortrun.php|bindrysvcs';
allPages[5]='ondemand.php|bindrysvcs';
allPages[6]='howitsdone.php|bindrysvcs';
//--Galleries
allPages[7]='restoration.php|restoration';
allPages[8]='textbooks.php|bindrysvcs';
//Destinations
allPages[9]='map.php|aboutus';
allPages[10]='shop.php|destinations';
allPages[11]='wifi.php|destinations';
allPages[12]='resturant.php|destinations';
//aboutus
allPages[13]='history.php|aboutus';
allPages[14]='articles/index.php|news';
allPages[15]='classes.php|news';
//Other
allPages[16]='yearbooks.php|yearbooks';
allPages[17]='links.php|links';

var curPgColor='rgb(225,153,15)';
var ua = window.navigator.userAgent;
var msie = ua.indexOf ( "MSIE " );
var dspType='table-cell';
if ( msie > 0 )      // If Internet Explorer, use this
	dspType='inline';  	

HighlightCurrent(); //Set a highlight on whatever cell this page represents

function SetupCell(cell, currentpg, subval) {
	var ua = window.navigator.userAgent;
	document.getElementById('home').style.backgroundColor="#000000";
	document.getElementById('contact').style.backgroundColor="#000000";
	curpgbgcolor='';
	if (lastCell != '') {
		var y = document.getElementById(lastCell);
		var curpgbgcolor = y.style.backgroundColor.replace(/ /g, '');
	}

	if (lastSub != 0 && lastSub != 9999 && lastSub != undefined) {
		var ls = document.getElementById('sub' + lastSub);
		ls.style.display='none';
	}

	box=document.getElementById(cell);
	box.style.backgroundColor="GoldenRod";
	if (lastCell != cell && lastCell != '') {
		var ua = window.navigator.userAgent;
		if ( ua.indexOf ( "MSIE " ) == -1 ) {
			if (curpgbgcolor != curPgColor) {
				y.style.backgroundColor="#000000";
			}
		} else {
			if (y.style.backgroundColor != "GoldenRod") { //#E1990F
				y.style.backgroundColor="#000000";
			}	
		}
	}
	lastCell = cell;
	for (var i = 0; i < knownPages.length;i++) {
		if (knownPages[i] == currentpg) {
			break;
		}
	}
	lastHLCell=knownIds[i];
	
	if (cell == knownIds[i]) {
		var z=document.getElementById(knownIds[i]);
		z.style.backgroundColor="GoldenRod";
	}

	HighlightCurrent(); //we may overwrite the above with this, but that's the way it is...
	
	if (subval != 9999)
		ShowSub(subval);
	lastSub=subval;			 
}
function HighlightCurrent() {
	var url=document.URL;
	var parts=url.split('/');
	var cc='';
	thispage = parts[parts.length - 1];
	if (thispage == '')
		thispage='index.php';
	var pnms=Array();
	var tmp='';
	if (url.indexOf('/articles') > 0)
		thispage='articles/index.php';
	pgFound=0;
	for (var i = 0; i < allPages.length;i++) {
		tmp = allPages[i];
		pnms=tmp.split('|');
		if (pnms[0] == thispage) {
			pgFound=1;
			break;
		}
	}
	cell=pnms[1];
	if (pgFound == 1) {
		cc=document.getElementById(cell);
		cc.style.backgroundColor="#3C003C"; //"#620062"; //"#4D004D";
	} else {
		//Special case: no sub menus
		if (thispage == "contact.php") {
			document.getElementById('contact').style.backgroundColor="#3C003C"; //"#620062"; //"#4D004D";
		} else if (	thispage == "index.php" || thispage == "") {
			document.getElementById('home').style.backgroundColor="#3C003C"; //"#620062"; //"#4D004D";
		}
	}

}
function ShowSub(val) {
	if (val == undefined)
		return;
	var c = document.getElementById('sub' + val);
	c.style.display=dspType;
	lastSub=val;
	
}
