// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
// If you do remove this, I will hunt you down :)
//
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- Version Date 8-6-02 ---------------------------------------------------------------

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 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;
}
//Items to hide
var hideItems = new Array("hideState", "hideRegion");

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

CenterMenu = function(name,left,top){
	this.name = name;
	this.left = left;
	this.top = top;
	this.timer = null;
	this.obj = name+'Object';
	eval(this.obj+'=this');
}
var comboHide = false;

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(iex && offset > 0){ // Ugly iex Bug Fix
		if(mac){
			if(document.height < window.innerHeight){
				offset -= 0;
			}
		}else{
			offset -= 0;
		}
	}
	getStyle(this.name).left = offset+this.left;
	getStyle(this.name).visibility = 'visible';
	curMenu = this.name;	
	
	if(this.name == 'submenu1'){
		for (var i=0; i < hideItems.length; i++){
			if(document.getElementById(hideItems[i]) != null){
				document.getElementById(hideItems[i]).style.visibility = 'hidden';
			}
		}
	}
	comboHide = true;
	
}
CenterMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+'.hideIt()',0);
	comboHide = false;
}
CenterMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = 'hidden';
	
	if(comboHide == false){
		for (var i=0; i < hideItems.length; i++){
			if(document.getElementById(hideItems[i]) != null){
				document.getElementById(hideItems[i]).style.visibility = 'visible';
			}
		}
	}
	
}

CenterMenu.prototype.startMenu = function(){
	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();
		curMenu = null;
	}
	//for (var i=0; i < hideItems.length; i++){
		//document.getElementById(hideItems[i]).style.visibility = 'hidden';
	//}
}
endMenu = function(){
	 return ns4 ? '<\/layer>' : '<\/div>';
}
createCenterMenu = function(name,left,top){
	Menus[name] = new CenterMenu(name,left,top);
}

Menus = new Object();
var curMenu = null;
if(is_fx){
	var pageWidth = 792;
} else {
	var pageWidth = 774;
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
// Build Menu Structure

createCenterMenu('submenu0', 51, 113);
createCenterMenu('submenu1', 132, 113);
createCenterMenu('submenu2', 488, 113);
createCenterMenu('submenu3', 391, 109);
createCenterMenu('submenu4', 494, 109);
createCenterMenu('submenu5', 260, 225);
createCenterMenu('submenu6', 210, 200);
createCenterMenu('submenu7', -189, 71);
createCenterMenu('submenu8', 152, 200);
createCenterMenu('submenu9', 85, 195);
createCenterMenu('submenu10', 203, 113);

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

function nav_DoFSCommand(command, args) { 
  if (command == "showMenu") {
  	hideCur();
	Menus[args].show();
  }
}