
// ||||||||||||||||||||||||||||||||||||||||||||||||||

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;
var isDOM = (document.getElementById) ? true : false;
var isNS4 = (document.layers) ? true : false;
var isIE = (document.all) ? true : false;
var isIE4 = document.all;
// var isIE4 = isIE && !isDOM;
var isIE5 = document.all;
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var isIE4M = isIE4 && isMac;
var isOpera = (navigator.userAgent.indexOf("Opera")!=-1);
var isKonqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);
var gWindowWidth=0;


// Get style of menus
function getStyle(name, nest){
	nest = nest ? "document."+nest+"." : "";
	return w3c ? document.getElementById(name).style : iex ? document.all[name].style : ns4 ? eval(nest+"document."+name) : null;
}

//  Used to center certain windows
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);
}

// This function hides all of the read information some how.

function CenterMenu(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');
}


function CenterMenu.prototype.show(){
	clearTimeout(this.timer);
	var windowWidth = iex ? document.body.clientWidth : window.innerWidth;
	var offset = Math.floor((windowWidth-pageWidth));
	
	
 if(offset < 0){
 		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;

}



function CenterMenu.prototype.hide(){
	this.timer = setTimeout(this.obj+".hideIt()",500);
}


function CenterMenu.prototype.hideIt(){
	getStyle(this.name).visibility = "hidden";
//	imageSwap(this.rollover,this.rollover+"_out");
}



function hideCur(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		curMenu = null;
	}
}


function startMenu(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;
}


function endMenu(){
	 return ns4 ? "<\/layer>" : "<\/div>";
}



function createCenterMenu(name,left,top,width,rollover){
	Menus[name] = new CenterMenu(name,left,top,width,rollover);
}



Menus = new Object();

// ||||||||||||||||||||||||||||||||||||||||||||||||||

var curMenu = null;
var pageWidth = 500;


// Sub Menus
createCenterMenu("submenu1", (pageWidth) - 700, 140, 140, "Pack");
createCenterMenu("submenu2", (pageWidth) - 595, 140, 140, "Dens");
createCenterMenu("submenu3", (pageWidth) - 490, 140, 140, "Advancement");
createCenterMenu("submenu4", (pageWidth) - 350, 140, 140, "Scouting");
createCenterMenu("submenu5", (pageWidth  - 230), 140, 140, "Parents");
createCenterMenu("submenu6", (pageWidth  - 160), 140, 140, "Leaders");


