// ||||||||||||||||||||||||||||||||||||||||||||||||||

var agent = navigator.userAgent.toLowerCase(); 
var mac = agent.indexOf("mac") != -1;
var w3c = document.getElementById ? true : false;
var iex = document.all ? true : false;
var ns4 = document.layers ? true : false;

// ||||||||||||||||||||||||||||||||||||||||||||||||||

function newImage(src){
	img = new Image();
	img.src = src;
	return img;
}
function imageSwap(img,obj,div){
	if(ns4 && div != null){
		eval("document."+div+".document.images['"+img+"'].src = "+obj+".src");
	}else{
		document.images[img].src = eval(obj+".src");
	}
}
function getStyle(name, nest){
	nest = nest ? "document."+nest+"." : "";
	return w3c ? document.getElementById(name).style : iexl ? document.all[name].style : ns4 ? eval(nest+"document."+name) : null;
}
function centerWindow(url,name,width,height,scroll){
	var x = (screen.availWidth-width)/2;
	var y = (screen.availHeight-height)/2;
	scroll = scroll ? "scrollbars=yes,resizable=yes," : "scrollbars=no,resizable=no,";
	windowReference = window.open(url,name,"toolbar=no,location=no,status=no,menubar=no,"+scroll+"width="+width+",height="+height+",screenX="+x+",screenY="+y+",top="+y+",left="+x);
	setTimeout("windowReference.focus()",250);
}

CenterMenu = function(name,left,top,width,rollover){
	this.name = name;
	this.left = left;
	this.top = top;
	this.width = width;
	this.rollover = rollover;
	this.timer = null;
	this.obj = name+'Object'; eval(this.obj+'=this');
}
CenterMenu.prototype.show = function(centered){
	clearTimeout(this.timer);
	
	if (centered) {
	  var windowWidth = iex ? document.body.clientWidth : window.innerWidth;
	  var offset = Math.floor((windowWidth-pageWidth)/2);
	  if(offset < 0){
	  	offset = 0;
	  }
	}
	else
	  offset = 0;
	
	//var offset = 0;
	
	if(ns4 && offset > 0){
		if(mac){
			if(document.height < window.innerHeight){
				offset -= 8;
			}
		}else{
			offset -= 8;
		}
	}
	getStyle(this.name).left = offset+this.left;
	getStyle(this.name).visibility = "visible";
	//imageSwap(this.rollover,this.rollover+"_over");
	curMenu = this.name;
}
CenterMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+".hideIt()",500);
}
CenterMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = "hidden";
	//imageSwap(this.rollover,this.rollover+"_out");
}
hideCur = function(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		curMenu = null;
	}
}
startPopup = function(menuobj){
	var name  = Menus[menuobj].name;
	var left  = Menus[menuobj].left;
	var top   = Menus[menuobj].top;
	var width = Menus[menuobj].width;
	var html;
	if(ns4){
		html = '<layer name="'+name+'" left="'+left+'" top="'+top+'" width="'+width+'" z-index="1000" visibility="hidden" ';
	}else{
		html = '<div id="'+name+'" style="position:absolute; left:'+left+'px; top:'+top+'px; width:'+width+'px; z-index:1000; visibility:hidden" ';
	}
	html += 'onMouseOver="Menus.'+menuobj+'.show()" onMouseOut="Menus.'+menuobj+'.hide()">';
	return html;
}
endPopup = function(){
	 return ns4 ? "<\/layer>" : "<\/div>";
}
createCenterMenu = function(name,left,top,width,rollover){
	Menus[name] = new CenterMenu(name,left,top,width,rollover);
}
Menus = new Object();

// ||||||||||||||||||||||||||||||||||||||||||||||||||

var curMenu = null;
var pageWidth = 770;

function fixNetscapeCSS(){
	if(origWidth != window.innerWidth || origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(ns4){
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
	window.onresize = fixNetscapeCSS;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
