
var agt = navigator.userAgent.toLowerCase();

var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up	= (is_nav && (is_major >= 4));
var is_navonly	= (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_nav6		= (is_nav && (is_major == 5));
var is_nav6up	= (is_nav && (is_major >= 5));
var is_gecko	= (agt.indexOf('gecko') != -1);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

var is_opera  =  (agt.indexOf("opera") != -1);
/*
	document.write("nav:" + is_nav + "<BR>");
	document.write("nav2:" + is_nav2 + "<BR>");
	document.write("nav3:" + is_nav3 + "<BR>");
	document.write("nav4:" + is_nav4 + "<BR>");
	document.write("nav4up:" + is_nav4up + "<BR>");
	document.write("nav6:" + is_nav6 + "<BR>");
	document.write("nav6up:" + is_nav6up + "<BR>");
	document.write("gecko:" + is_gecko + "<BR>");
	document.write("navonly:" + is_navonly + "<BR>");
	document.write("<P>" + "ie:" + is_ie + "<BR>");
	document.write("is_opera:" + is_opera + "<br>");
	document.write("ie3:" + is_ie3 + "<BR>");
	document.write("ie4:" + is_ie4 + "<BR>");
	document.write("ie4up:" + is_ie4up + "<BR>");
	document.write("ie5:" + is_ie5 + "<BR>");
	document.write("ie5up:" + is_ie5up + "<BR>");
	document.write("ie5_5:" + is_ie5_5 + "<BR>");
	document.write("ie5_5up:" + is_ie5_5up + "<BR>");
	document.write("ie6:" + is_ie6 + "<BR>");
	document.write("ie6up:" + is_ie6up + "<BR>");
*/

var over;
var timer;
var curImg = "";

ok = (is_ie4up || is_opera || is_nav4up);

// Menu

if(is_ie4up || is_nav6up || is_gecko || is_opera)
{
	document.write("<div id=\"popup\" style=\"position:absolute; visibility:hide; z-index: 1;\" onMouseOver=\"TimerStop(); return true;\" onMouseOut=\"TimerHide(200); return true;\"></div>\r\n");
}
else if(is_nav4)
{
	document.write("<layer id=\"popup\" z-index=1 visibility=hide onMouseOver=\"TimerStop(); return true;\" onMouseOut=\"TimerHide(200); return true;\"></layer>\r\n");
}

if(is_nav4)
	over = document.popup;
if(is_ie4up || is_opera)
	over = document.all['popup'];
if(is_nav6up || is_gecko)
	over = document.getElementById('popup');


// Functions

function TimerStop()
{
	if(timer)
		clearTimeout(timer);
}

function Show(x, y)
{
	TimerStop();

	if(is_nav4)
	{
		over.left = x;
		over.top = y;
		over.visibility = "show";
	}
	else if(ok)
	{
		over.style.left = x;
		over.style.top = y;
		over.style.visibility = "visible";
	}
}

function Hide()
{
	if(is_nav4)
	{
		over.visibility = "hide";
	}
	else if(ok)
	{
		over.style.visibility = "hidden";
	}
}

function HidePopup()
{
	Hide();

	curImg = "";
}

function TimerHide(timeout)
{
	timer = setTimeout('HidePopup()', timeout);
}

function ShowPopup(menu_id)
{
	outer_cell_style  = "background-color: " + menu_bg_color_off + ";";
	outer_cell_style += "border-style: solid;";
	outer_cell_style += "border-color: #000000;";
	outer_cell_style += "border-width: 1px;";
	
	inner_cell_style  = "background-color: " + menu_bg_color_off + ";";
	inner_cell_style += "border-style: solid;";
	inner_cell_style += "border-color: " + menu_border_color_off + ";";
	inner_cell_style += "border-width: 1px;";
	inner_cell_style += "font-size: 12px;";
	inner_cell_style += "font-family: Comic Sans MS, Verdana, Arial, Helvetica;";
	inner_cell_style += "padding-left: 6px;";
	inner_cell_style += "padding-right: 6px;";
	inner_cell_style += "padding-top: 1px;";
	inner_cell_style += "cursor: hand;";

	linkstyle  = "color: " + link_color_off + ";";
	linkstyle += "font-family: Comic Sans MS, Veranda, Arial;";
	linkstyle += "font-size: 14px;";
	linkstyle += "font-weight: bold;";

	txt  = "<table border=0 cellpadding=0 cellspacing=0 style=\""+outer_cell_style+"\">";
	txt += "<tr>";
	txt += "	<td>";
	txt += "	<table width=100% border=0 cellpadding=2 cellspacing=1>";

	for(i = 0; i < menudata[menu_id][2]; i++)
	{
		txt += "<tr>";
		txt += "<td style=\""+inner_cell_style+"\" onmouseover=\"this.style.backgroundColor='"+menu_bg_color_on+"';this.style.borderColor='"+menu_border_color_on+"';\" onmouseout=\"this.style.backgroundColor='"+menu_bg_color_off+"';this.style.borderColor='"+menu_border_color_off+"';\">";
		txt += "<a href=\"" + menudata[menu_id][4 + (i*2)] + "\" style=\""+linkstyle+"\" onmouseover=\"this.style.color='"+link_color_on+"';\" onmouseout=\"this.style.color='"+link_color_off+"';\">" + menudata[menu_id][3 + (i*2)] + "</a>";
		txt += "</td>";
		txt += "</tr>";
	}

	txt += "	</table>";
	txt += "	</td>";
	txt += "</tr>";
	txt += "</table>";

	if(is_nav4)
	{
		clientWidth = window.innerWidth;

		over.document.write(txt);
		over.document.close();
	}
	else if(ok)
	{
		clientWidth = document.body.clientWidth;

		over.innerHTML = txt;
	}

	if(ok)
	{
		x = menudata[menu_id][0];
		y = menudata[menu_id][1];
		
		if(alignToCenter && (clientWidth > contentWidth))
			x = ((clientWidth-contentWidth)/2) + x;

		Show(x, y);
	}
}
