
var highlight = 0;
var maxNav = 10;
var i;
for (i=1; i<=maxNav; i++)
{

		if (window.location == document.getElementById("nav"+i).href)
		{
			highlight = i;
			break;
		}

}

if (highlight == 0)
{
	var pathName = window.location.pathname;

	if (pathName=="" || pathName =="/")	//www.phosphor.co.nz or www.phosphor.co.nz/
	{
		highlight = 1;
	}
	else if (pathName.match(/\d{3}/i )!=null)
	{
		highlight=2;
	}
	else
	{
		
		for (i=1; i<=maxNav; i++)
		{
			var prefix = document.getElementById("nav"+i).innerHTML.split(" ")[0].toLowerCase().substr(0,4);


			if (pathName.indexOf(prefix) > -1)
			{
				highlight=i;
				break;
			}
		}
	}
}


if (highlight>0)
{

	
	document.getElementById("nav"+ highlight).style.color= "yellow";

}

// Just a few of them.... don't bother.... load them all at each page
MM_preloadImages('images/buttons/btn-site-masterplan_f2.gif',
				 'images/buttons/btn-site-neighbourhood5_f2.gif',
				 'images/buttons/btn-location-map_f2.gif',
				 'images/buttons/btn-location-back_f2.gif');


/*

function prev()
{
	if (highlight > 1)	// can't go prev at 1
	{
		window.location = document.getElementById("am"+(highlight-1)).href;
	}
}

function next()
{
	if (highlight < maxNav)	//can't go next at maxNav
	{
		window.location = document.getElementById("am"+(highlight+1)).href;
	}
}
*/




/**** SUBNAV HIGHLIGHT ****/

function subnavMouseOver(id)
{
	var tdl = 	document.getElementById('tdl' + id);
	var tdr = 	document.getElementById('tdr' + id);
	if (tdl.className.indexOf('-highlight') == -1)
	{
		tdl.className =tdl.className + '-highlight'
		tdr.className = tdr.className + '-highlight';
	}
}

function subnavMouseOut(id)
{
	var tdl = 	document.getElementById('tdl' + id);
	var tdr = 	document.getElementById('tdr' + id);
	tdl.className=	tdl.className.replace(/-highlight/gi, "");
	tdr.className=tdr.className.replace(/-highlight/gi, "");
}


/**** SUBSUBNAV STUFF ****/
var timeoutID;

function showSubSub(id)
{
	clearTimeout(timeoutID);

	// clear all, fix for subnav-> subsubnav -> another line in subnav
	if (document.getElementById('sub-subnav').innerHTML != "")
	{
		for (var i=1; i<20; i++)
		{
			try
			{
				subnavMouseOut(i);
			}
			catch(ex)
			{
				break;
			}
		}
	}
	document.getElementById('sub-subnav').innerHTML = document.getElementById('sub-subnav'+ id).innerHTML;
	subnavMouseOver(id);
}

function hideSubSub(id)
{
	subnavMouseOut(id);
	// delay by 0.2 sec, the time req to get from subnav to subsubnav... 
	timeoutID = setTimeout("hideSubSubDelayed(" + id + ");",200);

}
function hideSubSubQuick(id)
{
	// subsubnav table onmouseout call this
	// not sure why calling hideSubSubDelayed directly doesn't work
	timeoutID = setTimeout("hideSubSubDelayed(" + id + ");",50);
}

function hideSubSubDelayed(id)
{

	document.getElementById("sub-subnav").innerHTML = "";
	subnavMouseOut(id);
}

function registerSubSubEntered(id)
{
	clearTimeout(timeoutID);
	subnavMouseOver(id);
}

