/*  ************************************************** */
/*  **					                                    ** */
/*  **	JS Source Files                             ** */
/*  **	www.agency.com                              ** */
/*  **	Created: 02/04                              ** */
/*  **					                                    ** */
/*  ************************************************** */

var menuCount = 4; // number of 1st level menu items 
var alayerOn = 0;
var alayerOn1 = 0;
var delaySpeed = 10000; //delay until auto hiding menu; in milliseconds

/* determining whether msie or netscape being used and what versions */
var IE4 = (document.all && !document.getElementById) ? 1 : 0;
var NS4 = (document.layers) ? 1 : 0;
var IE5 = (document.all && document.getElementById) ? 1 : 0;
var N6 = (document.getElementById && !document.all) ? 1 : 0;
var ie = (IE4 || IE5) ? 1 : 0;
var n = (NS4 || N6) ? 1 : 0;

/* error handling 
window.onerror = errorHandler;
function errorHandler()
{
	return true;
}
*/
/* these functions perform syntax patching to allow both msie and netscape to interpret the same code  */
function divB(obj,nest,level1,level0)
{
	if (!N6)
	{
		nest=(!nest) ? '':'document.'+nest+'.';
		level0=(!level0) ? '':'document.'+level0+'.';		
		level1=(!level1) ? '':'document.'+level1+'.';
		this.css=(n) ? eval(level0+level1+nest+'document.'+obj):eval('document.all.'+obj+'.style');
	}
	else
	{
		nest=(!nest) ? '':'document.getElementById('+nest+').';
		this.css=(n) ? eval('document.getElementById("'+obj+'").style'):eval('document.getElementById("'+obj+'").style');
	}
	return this;
}

function divA(obj,nest,level1)
{
	if (!N6)
	{
		nest=(!nest) ? '':'document.'+nest+'.';
		level1=(!level1) ? '':'document.'+level1+'.';
		this.css=(n) ? eval(level1+nest+'document.'+obj):eval('document.all.'+obj+'.style');
	}
	else
	{
		nest=(!nest) ? '':'document.getElementById('+nest+').';
		this.css=(n) ? eval('document.getElementById("'+obj+'").style'):eval('document.getElementById("'+obj+'").style');
	}
	return this;
}

/* function to create menu layers */
function dDMCreate()
{
	dDMB=new Array();
	for (var j=0;j<menuCount;j++)
	{
		dDMB[j]=new divB('L2i'+(j+1),'innerMenu','menu','outerMenuHoldingDiv');
	}
	dDMB[0].css.visibility='hidden';
}

function tDMCreate()
{	
	tDMB=new Array();
	for (var j=0;j<menuCount;j++)
	{
		tDMB[j]=new divB('L1i'+(j+1)+'Over','innerMenu','menu','outerMenuHoldingDiv');
	}
	tDMB[0].css.visibility='hidden';
	dDMCreate();
}

/* function to flip second menu layers off and on */
function flipLayersTopMenu(numx,left,top)
{
	tDMB[alayerOn1].css.visibility='hidden';
	alayerOn1=numx;
	tDMB[alayerOn1].css.top=top;
	tDMB[alayerOn1].css.left=left;
	tDMB[alayerOn1].css.visibility='visible';
}

function flipLayersMenu(num,left,top)
{
	// Win NS4.0 doesn't like clearInt() called here
	if (!navigator.appName=="Mozilla" || navigator.appVersion.indexOf("4.0")<0) clearInt();
	dDMB[alayerOn].css.visibility='hidden';
	alayerOn=num;
	dDMB[alayerOn].css.top=top;
	dDMB[alayerOn].css.left=left;
	dDMB[alayerOn].css.visibility='visible';
	showMenu(); // turns toolbar links on within toolbar area
	if (NS4)
	{
		turnMenuOff();
	}
}

/* function to hide second level menu */
/* second level menu is needed to be turned of when you are reading the page */
function hideSecondMenu()
{
	for (var i=0;i<menuCount;i++)
	{
		dDMB[i].css.visibility='hidden';
	}
	for (var j=0;j<menuCount;j++)
	{
		tDMB[j].css.visibility='hidden';
	}
	clearInt();
	hideMenu();	// turns links on within toolbar area
	highLighter();		
}

function hideFirstMenu()
{
	for (var j = 0; j <= 3; j++)
	{
		tDMB[j].css.visibility='hidden';
	}
	hideSecondMenu();
}

/* this function turns of the second level menus after certain time */
var timerFunc2 = null;

function turnMenuOff()
{
	clearInt();
	timerFunc2 = setInterval("hideSecondMenu()",delaySpeed);
}

/* function to clear intervals */
function clearInt()
{
	clearInterval(timerFunc2);
}

/* functions to show and hide links out with toolbar, as netscape */
/* places its blocks over links and means any link within the toolbar area */
/* are not clickable, so we manipulate the zIndex to make them */
/* appear or disappear depending on whether toolbar visible or not */
function showMenu()
{
// this is to show menu so that menu is in focus
	if(IE4 || IE5)
	{
		outerMenuHoldingDiv.style.zIndex = "8";
		outerMenuHoldingDiv.style.clip = "rect(0,760,190,0)";	
	}	
	if (NS4)
	{
		var begin = document.outerMenuHoldingDiv;
		begin.zIndex = "8";	
		begin.document.menu.zIndex = "8";
		begin.document.menu.document.innerMenu.zIndex = "8";
		begin.clip.width = 760;				
		begin.clip.bottom = 190;		
	}	
	if (N6)
	{
		document.getElementById("outerMenuHoldingDiv").style.zIndex = "8";
		document.getElementById("outerMenuHoldingDiv").style.clip = "rect(0,760,190,0)";
	}
}

function hideMenu()
{
// this is to hide menu so that links in page work are focused
	if(IE4 || IE5)
	{
		outerMenuHoldingDiv.style.zIndex = "4";
		outerMenuHoldingDiv.style.clip = "rect(0,760,20,0)";
		turnMenuOff();		
	}
	if (NS4)
	{
		var begin = document.outerMenuHoldingDiv;
		begin.zIndex = "4";	
		begin.document.menu.zIndex = "4";
		begin.document.menu.document.innerMenu.zIndex = "4";
		begin.clip.bottom = 20;
		begin.clip.width = 760;							
	}
	if (N6)
	{
		document.getElementById("outerMenuHoldingDiv").style.zIndex = "4";
		document.getElementById("outerMenuHoldingDiv").style.clip = "rect(0,760,20,0)";
		turnMenuOff();
	}
}

/* this is a work a round for the netscape resize bug */
if (document.layers)
{
	origWidth = innerWidth;
	origHeight = innerHeight;
}

function correctResize()
{
	if (innerWidth != origWidth || innerHeight != origHeight)
	location.reload();
}
if (document.layers) onResize = correctResize;

/* function to control highlighted state */
var highLighted = false;

function highLighter()
{
	if (highLighted != false)
	{
		if (highLighted == "i")
		{
			flipLayersTopMenu(0,0,0);	
		}
		if (highLighted == "c")
		{
			flipLayersTopMenu(1,189,0);	
		}
		if (highLighted == "p")
		{
			flipLayersTopMenu(2,379,0);	
		}
		if (highLighted == "h")
		{
			flipLayersTopMenu(3,568,0);	
		}				
	}
	else
	{
	}		
}