﻿



/*
	##################################
	Main NavTop object constructor
	##################################
*/
function NavTop(layerId)
{
	// id of layer that holds the main NavTop bar (if there is one)
	this.layerId = layerId;
	
	// array to hold collection of Items
	this.item = new Array();
	
	// method to add a new Item without having to create one separately
	this.add = nt_AddItem;
}
/*
	##################################
*/



/*
	##################################
	object constructor for a main nav top menu item
	##################################
*/
function NavTopItem(navTop, layerId)
{
	
	// mouse event handlers
	this.over = nt_ItemOver;
	this.out = nt_ItemOut;
	
	// id of layer that holds the SubMenuItems
	this.layerId = layerId;
	
	// array to hold collection of SubItems
	this.subItem = new Array();
	this.subMenuTimer;
	
	// method to add a new subitem
	this.add = nt_AddSubItem;
	
	// create a reference to the parent navTOp item
	this.navTop = navTop;
}

// object constructor for a nav top menu sub item
function NavTopSubItem(Item, imageId, imageOverUrl, imageOutUrl)
{
	this.item = Item;
	
	// create a reference to the image as an object
	if (document.images[imageId])
	{
		this.image = document.images[imageId];
	}
	else if (document.layers[layerId].document.images[imageId]) 
	{
		this.image = document.layers[layerId].document.images[imageId]
	}
	
	// create the image to display on mouseout (or whenever there is not a mouseover)
	this.imageOut = new Image();
	this.imageOut.src = imageOutUrl;
	
	// create the image to display on mouseover
	this.imageOver = new Image();
	this.imageOver.src = imageOverUrl
	
	// mouse event handlers
	this.over = nt_SubItemOver;
	this.out = nt_SubItemOut;
}


function nt_AddItem(layerId)
{
	this.item[this.item.length] = new NavTopItem(this, layerId);
}

function nt_AddSubItem(imageId, imageOutUrl, imageOverUrl)
{
	this.subItem[this.subItem.length] = new NavTopSubItem(this, imageId, imageOverUrl, imageOutUrl);
}

function nt_ItemOver()
{
	window.clearTimeout(this.subMenuTimer);
	if(this.layerId != null) nt_showLayer(this.layerId);
}

function nt_ItemOut()
{
	if(this.layerId != null) this.subMenuTimer = window.setTimeout("nt_hideLayer('" + this.layerId + "');", 300);
}

function nt_SubItemOver()
{
	window.clearTimeout(this.item.subMenuTimer);
	nt_ImageOver(this);
}

function nt_SubItemOut()
{
	nt_ImageOut(this);
	this.item.out();
	
}	

function nt_ImageOver(object)
{
	object.image.src = object.imageOver.src;
}

function nt_ImageOut(object)
{
	object.image.src = object.imageOut.src;
}


// these methods are used for async calls such as those from a setTimeOut
// in which case the object references will be lost
function nt_showLayer(theLayer){	
	if (document.layers){
		eval("document.layers." + theLayer + ".visibility = 'show'");
	} else if (document.all){
		eval("document.all." + theLayer + ".style.visibility = 'visible'");
	} else{
		eval("document.getElementById('" + theLayer + "').style.visibility = 'visible'");
	}
}

function nt_hideLayer(theLayer){
	if (document.layers){
		eval("document.layers." + theLayer + ".visibility = 'hide'");
	} else if (document.all){
		eval("document.all." + theLayer + ".style.visibility = 'hidden'");
	} else{
		eval("document.getElementById('" + theLayer + "').style.visibility = 'hidden'");
	}
}

function nt_swapImage(imgId, imgUrl, layerId)
{
	if (document.images[imgId]) 
	{
		document.images[imgId].src = imgUrl;
	}
	else if (document.layers[layerId].document.images[imgId])
	{
		document.layers[layerId].document.images[imgId].src = imgUrl;
	}
}

