// New library object for dynamic layers 
//Global document object
d = window.document;
loaded = false;

// repeated below
//if(d.layers){
//	origWidth=innerWidth;
//	origHeight=innerHeight;
//}

// Browser detection object

function lib_bwCheck(){
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom = document.getElementById?1:0
	this.opera5 = this.agent.indexOf("Opera 5")>-1
	this.ie5 = (this.agent.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0
	this.ie6 = (this.agent.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0
	this.ie = this.ie4||this.ie5||this.ie6
	this.mac = this.agent.indexOf("Mac")>-1
	this.ns6 = (this.dom && parseInt(this.ver)>=5)?1:0
	this.ns4 = (document.layers && !this.dom)?1:0
	this.bw = (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
	return this
}
bw = new lib_bwCheck() // Browser object

function lib_obj(obj){
	this.el = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval('document.' + obj):0;
	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
	this.moveIt = lib_moveIt;
	this.showIt = lib_showIt;
	this.hideIt = lib_hideIt;
	return this;
}


function lib_moveIt(x,y){
	if (x){this.x=x; this.css.left = x;}
	if (y){this.y=y; this.css.top = y;}
}

function lib_showIt(){this.css.visibility = "visible"}
function lib_hideIt(){this.css.visibility = "hidden"}

// DHTML fix detection for Netscape browser resize
if (d.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=DHTMLfix;
}
		
// DHTML fix for Netscape browser resize
function DHTMLfix() {
	if (origWidth != innerWidth || origHeight != innerHeight) {
		location.reload();
	}
}

function fixNav(){
	if(d.all)history.go(0)
	if (d.layers) {
		DHTMLfix();
	}
}


// X Position Layer relative to anchor image
function get_xPos(object,offset){
	if(d.layers && !d.dom){
		xPos = d.images[object].x
	} else {
		xPos = d.images[object].offsetLeft;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) xPos = xPos + offset;
	return xPos;
}


// Y Position Layer relative to anchor image 
function get_yPos(object,offset){
	if(d.layers && !d.dom){
		yPos = d.images[object].y
	} else {
		yPos = d.images[object].offsetTop;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) yPos = yPos + offset;
	return yPos
}

// Call this function when page is loaded
function init(){
	place_menus();
	loaded = true;
}

function place_menus(){
	mDiv = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mDiv[menu_ar[i]] = new lib_obj('m' + menu_ar[i]);
		mDiv[menu_ar[i]].moveIt(get_xPos(menu_ar[i]),false);
	}
	mDiv[rightmost_menu].moveIt(get_xPos(rightmost_menu,0),false);
	loaded=true;

	miniLoad();
}


// put the name of the images that trigger the dropdowns in this array
menu_ar = new Array();
menu_ar[0] = 'products';
menu_ar[1] = 'support';
menu_ar[2] = 'company';

// menu variables

rightmost_menu = menu_ar[2];

delay=300;
active = menu_ar[0];
timer = null;

defaultMenuHighlight = '' // set this in the body of the page if one of the menu items should always be highlighted

// rollover functions

function load_menu_rollovers(){
	mro_ar = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mro_ar[menu_ar[i]] = new Array();
		mro_ar[menu_ar[i]]['off']=new Image();
		mro_ar[menu_ar[i]]['on']=new Image();
		mro_ar[menu_ar[i]]['off'].src="/images/nav-"+menu_ar[i]+".gif";
		mro_ar[menu_ar[i]]['on'].src="/images/nav-"+menu_ar[i]+"-on.gif";
	}
}

load_menu_rollovers();

function m_rollover(which){
	if (which != defaultMenuHighlight) {
		document.images[which].src = mro_ar[which]['on'].src;
	}
}

function m_rollout(which){
	if (which != defaultMenuHighlight) {
		document.images[which].src = mro_ar[which]['off'].src;
	}
}



// menu functions 

function changeActive(which){
	if (loaded){
		clearTimeout(timer);
		mDiv[active].hideIt();
		m_rollout(active);
		active=which;
		mDiv[active].showIt();
		m_rollover(active);
	}
}

function killIt(){
	if (loaded){
		mDiv[active].hideIt();
		m_rollout(active);
	}
}

function killMenu(){
	if (loaded){
		timer = setTimeout("killIt()",delay);
	}
}

function sleep(){
	clearTimeout(timer);
}

function new_window(url,winWidth,winHeight) {
			var toolBarParms = "toolbar=0,directories=0,status=0,menubar=0,scrollbars=0";
			toolBarParms = toolBarParms + "resizable=0,width=" + winWidth + ",height=" + winHeight;
			newWin = window.open(url,"Print",toolBarParms);
			newWin.focus();
			newWin.print();
}
