var agent = navigator.userAgent.toLowerCase(); 
var mac = agent.indexOf('mac') != -1;
var firefox = agent.indexOf('firefox') != -1; // || agent.indexOf('netscape') != -1 || agent.indexOf('opera') != -1;
var opera = agent.indexOf('opera') != -1;
var netscape = agent.indexOf('netscape') != -1;
var w3c = document.getElementById ? true : false;
var iex = document.all ? true : false;
var ns4 = document.layers ? true : false;

function fixNetscape(){
	if(origWidth != window.innerWidth || origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(ns4){
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
	window.onresize = fixNetscape;
}
function getStyle(name, nest){
	nest = nest ? 'document.'+nest+'.' : '';
	return w3c ? document.getElementById(name).style : iex ? document.all[name].style : ns4 ? eval(nest+'document.'+name) : false;
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Menu Constructor

CenterMenu = function(name,imgname,left,top){
	this.name = name;
	this.imgname = imgname;
	this.left = left;
	this.top = top;
	this.timer = null;
	this.obj = name+'Object';
	eval(this.obj+'=this');
}
CenterMenu.prototype.show = function(){
	clearTimeout(this.timer);
	var windowWidth = iex ? document.body.clientWidth : window.innerWidth;
	var offset = Math.floor((windowWidth-pageWidth)/2);
	if(offset < 0){
		offset = 0;
	}
	if((opera && offset > 0) || (netscape && offset > 0)) { //fix opera and netscape offset
		if(mac) {
			if(document.height < window.innerHeight){
				offset += 1;
			}
		}else{
			offset += 1;
		}
	}
		
	if((ns4 && offset > 0) || (firefox && offset > 0) || (netscape && offset > 0)){ // firefox/netscape offset fix
		if(mac){
			if(document.height < window.innerHeight){
				offset -= 8;
			}
		}else{
			offset -= 8;
		}
	}
	
	if(firefox && offset > 0){ // firefox offset fix
		if(mac){
			if(document.height < window.innerHeight){
				offset += 1;
			}
		}else{
			offset += 1;
		}
	}
	
	getStyle(this.name).left = offset+this.left;
	getStyle(this.name).visibility = 'visible';
	curMenu = this.name;
}
CenterMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+'.hideIt()',500);
}
CenterMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = 'hidden';
	twinOff(this.imgname);
}
CenterMenu.prototype.startMenu = function(){
	//alert(this.left);
	var html;
	if(ns4){
		html = '<layer name="'+this.name+'" left="'+this.left+'" top="'+this.top+'" z-index="1000" visibility="hidden" ';
	}else{
		html = '<div id="'+this.name+'" style="position:absolute; left:'+this.left+'px; top:'+this.top+'px; z-index:1000; visibility:hidden" ';
	}
	html += 'onMouseOver="Menus.'+this.name+'.show()" onMouseOut="Menus.'+this.name+'.hide()">';
	return html;
}

// Global Menu Functions
hideCur = function(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		//twinOff(curMenu);
		curMenu = null;
	}
}
endMenu = function(){
	 return ns4 ? '<\/layer>' : '<\/div>';
}
createCenterMenu = function(name,imgname,left,top){
	Menus[name] = new CenterMenu(name,imgname,left,top);
}

Menus = new Object();
var curMenu = null;
var pageWidth = 754;
var yCoord = 139;



