n=0;ie=1;ns6=0;fShow="visible";fHide="hidden";
var keepstatic=1; 
var menucolor="#c8d7e3" 
var submenuwidth=120 
var mtop=61;


window.onerror=new Function("return true")
rightX = 0;
function Menu()
{	this.bgColor     = menucolor;
	this.menuFont = "bold 12px Arial"; //default font settings. Don't change. Instead, modify stylesheet in sample.htm
	this.fontColor   = "black";
	this.addItem    = addItem;
	this.addSubItem = addSubItem;
	this.showMenu   = showMenu;
	this.mainPaneBorder = 0;
	this.subMenuPaneBorder = 0;
	this.subMenuPaneWidth = submenuwidth;
	lastMenu = null;	rightY = 0;	leftY = 0;leftX = 0;
	HTMLstr ="<!-- MENU PANE DECLARATION BEGINS -->\n\n<div id='MainTable' style='position:absolute;top:"+mtop+";left:0;'>\n<table width='100%' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
	HTMLstr += "<tr><!-- MAIN MENU STARTS -->\n<!-- MAIN_MENU -->\n<!-- MAIN MENU ENDS -->\n</tr>\n</table>\n\n<!-- SUB MENU STARTS -->\n<!-- SUB_MENU -->\n<!-- SUB MENU ENDS -->\n\n</div>\n<!-- MENU PANE DECALARATION ENDS -->\n";
}
function addItem(idItem, text, hint, location, altLocation)
{	var Lookup = "<!-- ITEM "+idItem+" -->";
	if (HTMLstr.indexOf(Lookup) != -1){	alert(idParent + " already exist");	return;}
	var MENUitem = "\n<!-- ITEM "+idItem+" -->\n<td>\n<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";'>\n<a class=menu ";
	if (hint != null)	MENUitem += "title='"+hint+"' ";
	if (location != null)
	{	//MENUitem += "href='"+location+"' onmouseover=\"hideAll()\" ";
		MENUitem += "href='"+location+"' onmouseover=\"displaySubMenu('"+idItem+"')\" ";
	}
	else
	{	if (altLocation != null)	MENUitem += "href='"+altLocation+"' ";
		else MENUitem += "href='.' ";
		MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"')\" onclick=\"return false;\" "
	}
	MENUitem += "><font face=Webdings color=#C0C0C0>;</font>&nbsp;\n"+text+"</a>\n</div>\n</td>\n<!-- END OF ITEM "+idItem+" -->\n\n<!-- MAIN_MENU -->\n";
	HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}
function addSubItem(idParent, text, hint, location, linktarget)
{	var MENUitem = "";
    text="&nbsp;<font face=Wingdings color=#808080>w</font>&nbsp;"+text;
	Lookup = "<!-- ITEM "+idParent+" -->";
	if (HTMLstr.indexOf(Lookup) == -1)	{	alert(idParent + " not found");return;}
	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{	MENUitem += "\n<div id='"+idParent+"submenu' onmouseout=operahide() style='position:absolute; visibility: hidden; z-index:100; width: "+this.subMenuPaneWidth+"; font: "+this.menuFont+"; top: -300;'>\n<table border='"+this.subMenuPaneBorder+"' bgcolor='"+"#ced1e6"+"' width="+this.subMenuPaneWidth+">\n";
		MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n</table>\n</div>\n\n<!-- SUB_MENU -->\n";
		HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
	}
	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
	MENUitem = "<tr><td><a class=menu1 title='"+hint+"' href='"+location+"' target='"+linktarget+"'>"+text+"</a><br></td></tr>\n";
	MENUitem += Lookup;
	HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}
function showMenu()
{	document.writeln(HTMLstr);
}
function displaySubMenu(idMainMenu)
{	var menu;
	var submenu;
		menu = eval(idMainMenu) ;
		submenu =eval(idMainMenu+"submenu.style") ;
		submenu.left = calculateSumOffset(menu, 'offsetLeft');
		submenu.top  = menu.style.top+28;
		submenu.visibility = fShow;
		if (lastMenu != null && lastMenu != submenu) hideAll();
		leftX  = document.all[idMainMenu+"submenu"].style.posLeft ;
		rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth ;
		leftY  = document.all[idMainMenu+"submenu"].style.posTop+document.all[idMainMenu+"submenu"].offsetHeight +mtop-window.document.body.scrollTop;
		rightY = leftY;
	lastMenu = submenu;
}
function hideAll()
{	if (lastMenu != null) {lastMenu.visibility = fHide;lastMenu.left = 0;}
}
function calculateSumOffset(idItem, offsetName)
{	var totalOffset = 0;
	var item = eval('idItem');
	do
	{	totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}
function updateIt(e)
{	var x = window.event.clientX;
	var y = window.event.clientY;
	if (x > rightX || x < leftX) hideAll();
	else if (y > rightY) hideAll();
}
document.body.onclick=hideAll;
document.body.onscroll=hideAll;
document.body.onmousemove=updateIt;