var shouldHideSelects = false;
var selectedCell,mainSelectedCell,topPos;
var IE = document.all?true:false;
var dom = (document.getElementById)? true : false;
var nn4 = (document.layers)? true : false;
var ie4 = (!dom && document.all)? true : false;

var tempX = 0;
var tempY = 0;

var start = 0;
var activmenu = 0;
var overactiv = 0;
var cur = 0;
var tim;
var menuCount=0;
var menus=new Array();

var tstart = 0;
var tactivmenu = 0;
var toveractiv = 0;
var tcur = 0;
var ttim;
var tmenuCount=0;
var tmenus=new Array();

//Start Top Nav
function tmenu (top, wid) {
	this.top=top;
	this.wid=wid
	this.childCount=0; 
	this.children=new Array;
}

function tmenuItem (name,url) { 
	this.name=name; 
	this.url=url;
}
function BuildTopMenus(){
	for (var tcurMenu=0; tcurMenu<tmenuCount; tcurMenu++) {
	document.write('<LAYER VISIBILITY="HIDE"><DIV style="z-index: 1; width:');
	document.write(tmenus[tcurMenu].wid);
	document.write('px; visibility: hidden; display:none; position: absolute;top:');
	document.write(tmenus[tcurMenu].top);
	document.write('px;" id="tmenu');
	document.write(tcurMenu);
	document.write('"><table border="0" cellspacing="0" cellpadding="0" width=');
	document.write(tmenus[tcurMenu].wid);
	document.write('><tr><td id="subnav">');
		for (var tcurItem=0; tcurItem<tmenus[tcurMenu].childCount; tcurItem++){
			document.write("<A");
			document.write(" onMouseOut=\"toptimeactiv();");
			document.write('" OnMouseOver="toptimedisable();');
			document.write('" href="');
			document.write(tmenus[tcurMenu].children[tcurItem].url);
			document.write('" id="link' + tcurMenu + '-' + tcurItem + '">');
			document.write(tmenus[tcurMenu].children[tcurItem].name);
			document.write('</a>');
		}
	document.write('</td></tr></table></div></layer>');
	}
}

function tm (top,wid) {
	tmenus.push(new tmenu(top, wid));
	tmenuCount++;
}

function ta (name,url) {
	tmenus[tmenuCount-1].children.push(new tmenuItem(name,url));
	tmenus[tmenuCount-1].childCount++;
}

function showtopmenu(tel,showactmenu, cx){
hideSelects()
	if (dom){
		document.getElementById(tel).style.visibility = "visible";
		document.getElementById(tel).style.display = "block";
		document.getElementById(tel).style.left=cx;
	}
	tactivmenu = 1;
}
	
function hidetopmenu(tel,hideactmenu){
showSelects()
	if (dom){
	document.getElementById(tel).style.visibility = "hidden";
	document.getElementById(tel).style.display = "none";
	}
	else if (ie4){
		document.all[tel].style.visibility = "hidden";
		document.all[tel].style.display = "none";
	}
	else if (nn4){
		document.layers[tel].visibility = "hide";
		document.layers[tel].display = "none";
	}
	tactivmenu = 0;
	remHighlightCell();
}

function topactiv(tel, cx){
	if (tactivmenu == 1){
		if (tel != tcur){
		hidetopmenu(tcur,"tactivmenu");
		showtopmenu(tel,"tactivmenu", cx);
		tcur = tel;
	}else if (tactivmenu == 1){
		showtopmenu(tel,"tactivmenu", cx);
		tcur = tel;
	}
	}else{
		showtopmenu(tel,"tactivmenu", cx);
		tcur = tel;
	}
}

function toptimeactiv(){
	toveractiv = 0;
	ttim = setTimeout('ttopactiv()','200'); 
}

function ttopactiv(){
	if (toveractiv == 0 && tactivmenu == 1)
		hidemenu(tcur,"tactivmenu");
}

function toptimedisable(){
	if (tstart != 0){
		clearTimeout(ttim);
		toveractiv=1;
	}else
		tstart = 1;
}
//End Top Nav

//Start Left Nav
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

function highlightMainCell(obj){
	if(mainSelectedCell)
		mainSelectedCell.className = "";


	mainSelectedCell = document.getElementById(obj);
}

function highlightCell(obj){
	selectedCell = document.getElementById(obj);
}

function remHighlightCell(){
	if(selectedCell)
		selectedCell.className = "keephighlight";
	if(mainSelectedCell)
		mainSelectedCell.className = "";
}

function keepHighlightCell(obj){
	obj.className = "keephighlight";
}

function getMouseXY(e) {
	if (IE){
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
  	}else {
		tempX = e.pageX;
		tempY = e.pageY;
  	}  
	if (tempX < 0){tempX = 0;}
  	if (tempY < 0){tempY = 0;}
  	return true;
}

function menu () {  
	this.childCount=0; 
	this.children=new Array;
}

function menuItem (name,url) { 
	this.name=name; 
	this.url=url;
}

function BuildMenus(){
	for (var curMenu=0; curMenu<menuCount; curMenu++) {
	document.write("<LAYER VISIBILITY=\"HIDE\"><DIV style=\"z-index: 1; width:200px; visibility: hidden; display:none; position: absolute;left:325px;");
	document.write(mX);
	document.write("\" id=\"menu");
	document.write(curMenu);
	document.write("\" onMouseover=\"keepHighlightCell(mainSelectedCell)\">");
	document.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=130><tr><td id=\"subnav\">");
		for (var curItem=0; curItem<menus[curMenu].childCount; curItem++){
			document.write("<A onMouseOut=\"timeactiv();\" OnMouseOver=\"timedisable();\" href=\"");
			document.write(menus[curMenu].children[curItem].url);
			document.write("\" id='link" + curMenu + "-" + curItem + "'>");
			document.write(menus[curMenu].children[curItem].name);
			document.write("</a>");
		}
	document.write("</td></tr></table></div></layer>");
	}
}

function m () {
	menus.push(new menu());
	menuCount++;
}

function a (name,url) {
	menus[menuCount-1].children.push(new menuItem(name,url));
	menus[menuCount-1].childCount++;
}

function showmenu(el,showactmenu){
hideSelects()
	if (dom){
		document.getElementById(el).style.visibility = "visible";
		document.getElementById(el).style.display = "block";
		if(topPos)
			document.getElementById(el).style.top=topPos;
		else
			document.getElementById(el).style.top=tempY-10;
	}
	activmenu = 1;
}
	
function hidemenu(el,hideactmenu){
showSelects()
	if (dom){
	document.getElementById(el).style.visibility = "hidden";
	document.getElementById(el).style.display = "none";
	}
	else if (ie4){
		document.all[el].style.visibility = "hidden";
		document.all[el].style.display = "none";
	}
	else if (nn4){
		document.layers[el].visibility = "hide";
		document.layers[el].display = "none";
	}
	activmenu = 0;
	remHighlightCell();
}

function activ(el){
	if (activmenu == 1){
		if (el != cur){
		hidemenu(cur,"activmenu");
		showmenu(el,"activmenu");
		cur = el;
	}else if (activmenu == 1){
		showmenu(el,"activmenu");
		cur = el;
	}
	}else{
		showmenu(el,"activmenu");
		cur = el;
	}
}

function timeactiv(){
	overactiv = 0;
	tim = setTimeout('tactiv()','200'); 
}

function tactiv(){
	if (overactiv == 0 && activmenu == 1)
		hidemenu(cur,"activmenu");
}

function timedisable(){
	if (start != 0){
		clearTimeout(tim);
		overactiv=1;
	}else
		start = 1;
}

var selectContainer = document.getElementsByTagName("SELECT1");

function hideSelects(){
	for(i=0; i<selectContainer.length; i++) {
		if (selectContainer[i].id!="price_menu")
			selectContainer[i].style.visibility = "hidden";
	}
}

function showSelects(){
	for(i=0; i<selectContainer.length; i++)
		selectContainer[i].style.visibility = "visible";
}
//End Left Nav

function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
