var NA = new Object(); // global namespace

NA.Pload = 
{
	c:new Object(),
	l:function(a)
	{	if (NA.Pload.d)
		{	rslt = new Image();
			rslt.src = NA.Pload.path + a;
			return rslt; }	},
	load:function(n,i) { NA.Pload.c[n] = NA.Pload.l(i); },
	use:function(n,t) { if (NA.Pload.d) document.getElementById(t).src = NA.Pload.c[n].src; }
}
NA.Pload.d = (document.images && document.getElementById) ? 1 : 0;
NA.Pload.path = "/_res/images/";

NA.Pload.load("m1", 	"nav-live.gif");
NA.Pload.load("m1on", 	"nav-live-on.gif");
NA.Pload.load("m2", 	"nav-enjoy.gif");
NA.Pload.load("m2on", 	"nav-enjoy-on.gif");
NA.Pload.load("m3", 	"nav-own.gif");
NA.Pload.load("m3on", 	"nav-own-on.gif");
NA.Pload.load("m4", 	"nav-care.gif");
NA.Pload.load("m4on", 	"nav-care-on.gif");
NA.Pload.load("m5", 	"nav-inquire.gif");
NA.Pload.load("m5on", 	"nav-inquire-on.gif");

NA.ieChild = function(element, node, type, classes)
{
	if (document.getElementById(element))
	{
		var els = document.getElementById(element).getElementsByTagName(node);
		var theClass = classes.split(",");
		for (var i=els.length-1; i>=0; i--)
		{
			if (type == "both" || type == "first") 	els[i].firstChild.className += " " + theClass[0];
			if (type == "both" || type == "last") 	els[i].lastChild.className  += " " + theClass[1];
		}
	}
}

NA.on = 0;

NA.setOn = function() { if (NA.on != 0) NA.Pload.use("m" + NA.on + "on", "navm" + NA.on); }

NA.open 	= new Object();
NA.close 	= new Object();

NA.startUp = function()
{
	var saf = (window.getComputedStyle == undefined && !document.all) ? true : false; // for safari bugs
	
	if (!document.getElementById) return true;
	// start menu
	var isIE = document.all && document.getElementById;
	if (document.getElementById)
	{
		var navRoot = document.getElementById("nav-list");
		var x = 1;
		var on;
		
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			
			node = navRoot.childNodes[i];
			
			if (node.nodeName == "LI")
			{
				node.id = "m" + x; 	// these are used below

				node.onmouseover = function()
				{
					if (isIE) this.className+=" over";
					if (!saf)
					{
						clearTimeout(NA.close[this.id]);
						NA.open[this.id] = setTimeout("NA.Pload.use('" + this.id + "on', 'nav" + this.id + "')", 1);
					}
				}
				node.onmouseout = function()
				{
					if (isIE) this.className=this.className.replace(" over", "");
					if (this.id == "m" + NA.on)
					{
						NA.setOn(); // set current menu state on
						return;
					}
					if (!saf)
					{
						clearTimeout(NA.open[this.id]); 
						NA.close[this.id] = setTimeout("NA.Pload.use('" + this.id + "', 'nav" + this.id + "');", 100);
					}
				}
				x++;
			}
		}
	}

	// style menu for IE
	// these are dynamically assigned ids for the child menus, we're using them for the last child in IE
	if (isIE)
	{
		var ms = new Array("m1", "m2", "m3", "m4", "m5", "footer");
		var msc = 0;
		while (msc < ms.length)
		{
			NA.ieChild(ms[msc], "UL", "last", ",ieLast");
			msc++;
		}
	}
	NA.setOn(); // set current menu state on
}

NA.addLoadEvent = function(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
    	window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

NA.addLoadEvent(NA.startUp);


// *********************************************************************
// Function to create pop-up windows at a custom size.
// w = width
// h = height
// d = directories
// l = location
// m = menubar
// r = resizeable
// sc = scrollbars
// st = status
// t = toolbar
// EXAMPLE CALL: <a href="javascript:popUp('[URL]','[WINDOW NAME]',400,300,1,1,0,0,0,0,0);">LINK</a>
// *********************************************************************
function popUp(URL,name,w,h,d,l,m,r,sc,st,t) {
	var featureStr = "";
	featureStr = "width=" + w + ",height=" + h + ",directories=" + d + ",location=" + l + ",menubar=" + m + ",resizable=" + r + ",scrollbars=" + sc + ",status=" + st + ",toolbar=" + t;
	window.open(URL,name,featureStr);
}
