//	Vars
var gCurSelected = "";
var NAV_BAR_SRC = "/navbarsrc/";
var images = new Array();

//	Section Directory Name.
//	[n][0] = directory name.	[n][1] = button name
var dirNames = new Array();
dirNames[0] = ['/about','bAbout'];
dirNames[1] = ['/contact','bContactInfo'];
dirNames[2] = ['/adv','bCurrentADV'];
dirNames[3] = ['/news','bNewsPress'];
dirNames[4] = ['/piv','bPIV'];
dirNames[5] = ['/services','bServices'];
dirNames[6] = ['/process','bTheProcess'];
dirNames[7] = ['/why','bWhyChooseTAG'];

//	------------------------------------------
//  Preload all the off screen images
function preloadNavbar()  {
	images[0] = new Image();	images[0].src = NAV_BAR_SRC + "bAbout_f2.gif";
	images[1] = new Image();	images[1].src = NAV_BAR_SRC + "bAbout_f3.gif";
	images[2] = new Image();	images[2].src = NAV_BAR_SRC + "bContactInfo_f2.gif";
	images[3] = new Image();	images[3].src = NAV_BAR_SRC + "bContactInfo_f3.gif";
	images[4] = new Image();	images[4].src = NAV_BAR_SRC + "bCurrentADV_f2.gif";
	images[5] = new Image();	images[5].src = NAV_BAR_SRC + "bCurrentADV_f3.gif";
	images[6] = new Image();	images[6].src = NAV_BAR_SRC + "bNewsPress_f2.gif";
	images[7] = new Image();	images[7].src = NAV_BAR_SRC + "bNewsPress_f3.gif";
	images[8] = new Image();	images[8].src = NAV_BAR_SRC + "bPIV_f2.gif";
	images[9] = new Image();	images[9].src = NAV_BAR_SRC + "bPIV_f3.gif";
	images[10] = new Image();	images[10].src = NAV_BAR_SRC + "bServices_f2.gif";
	images[11] = new Image();	images[11].src = NAV_BAR_SRC + "bServices_f3.gif";
	images[12] = new Image();	images[12].src = NAV_BAR_SRC + "bTheProcess_f2.gif";
	images[13] = new Image();	images[13].src = NAV_BAR_SRC + "bTheProcess_f3.gif";
	images[14] = new Image();	images[14].src = NAV_BAR_SRC + "bWhyChooseTAG_f2.gif";
	images[15] = new Image();	images[15].src = NAV_BAR_SRC + "bWhyChooseTAG_f3.gif";
}

//	------------------------------------------
//  Figures out which Section we are in.
function setCurSection()	{
	for( i=0 ; i<dirNames.length ; i++)  {
		var pattern = new RegExp(dirNames[i][0]);
		if(pattern.test(window.location) == true)  {
			gCurSelected = dirNames[i][1];
			swapImgSrc(dirNames[i][1], NAV_BAR_SRC + dirNames[i][1] + '_f3.gif');
		}
	}
}

//	------------------------------------------
//  A simple function that swaps the src attribute of a named image
function swapImgSrc(imgName, newSrc)  {
	for( i=0 ; i<document.images.length ; i++ )  {
		if( document.images[i].id == imgName)	{
			document.images[i].src = newSrc;
			return;
		}
	}
}

//	------------------------------------------
//  
function navbar(imgName, cmd)  {
	if(imgName != gCurSelected)  {
		var src = "";
		if(cmd == "over")  {
			src = NAV_BAR_SRC + imgName + "_f2.gif";
		} else {
			src = NAV_BAR_SRC + imgName + ".gif";
		}
		swapImgSrc(imgName, src);
	}
}