/*BETA - Databasewatch menu system version 0.8.4

* written by Andy Woolley

* Copyright 2001 Andy Woolley. All Rights Reserved.

*

* Please feel free to use this code on your own website free of charge.

* You can also distribute and modify this source code as long as this 

* Copyright notice remains intact and you send me notice that you 

* intend to use this code on your website. I can only support this product

* if you let me know.

* dbmenu@milonic.com

*/

document.write("<div>");

mdom=(document.getElementById) ? true : false;

mie=(navigator.appVersion.indexOf("MSIE") != -1)  ? true : false;

mns6=(navigator.vendor == ("Netscape6") != -1) ? true : false;

NS=(document.layers) ? true : false;

mopera=(navigator.userAgent.indexOf("Opera") != -1)  ? true : false;



arraycorrect=10; 

timer=0; 



selmenu="";

selitem="";

closestr="";



openmenus=new Array();

oldcount=0;



function getmenuobj(menutext) {

	if (document.getElementById) {menui=document.getElementById(menutext).style;} else if (document.all) {menui = document.all[menutext].style;} else if (document.layers) {menui=document.layers.eval(menutext);}

	return menui;

}



function closeallmenus() {

	for (a=0; a<openmenus.length; a++) {

		menutexta=openmenus[a];

		menitema=getmenuobj(menutexta);

		menitema.visibility='hidden';

	}

}

	

function closemenu() {

	timer=setTimeout("closeallmenus()",timegap)

}



function popup(menunum) {

	clearTimeout(timer);   	

	menutext='menu'+menunum;

	menitem=getmenuobj(menutext);

	closeallmenus();

	delete(openmenus);

	openmenus=new Array();	

	openmenus[openmenus.length]=menutext;

	menitem.visibility='visible';	

}



function showel(lyr, el, show, menuname, menustr) {	

	clearTimeout(timer);

	menutext='el'+el;

	

	if (document.getElementById) {menitem=document.getElementById(menutext).style;} 

	else if (document.all) {menitem=document.all[menutext].style;} 

	else if (NS) {menitem=document.layers[lyr-1].document.layers[el-1].document.layers[0];}

	

	if (show) {

		menitem.visibility="visible";

		popup(lyr);

	} else {

		menitem.visibility="hidden";

		closemenu();

	}

}



function dc() { location.href=window.status; }



menus=1;

mentext="";

menarr="";

while(eval("window.menu"+menus)) {

	menarr+="menu"+menus+",";

	submenus=1;

	while(eval("window.menu"+menus+"_"+submenus))	{

		menarr+="menu"+menus+"_"+submenus+",";

		submenus++;

	}

	tmenu=eval("menu"+menus);

	menus++;

}



menuarray=menarr.split("\,");

menus=menuarray.length;

elcount=0;



stxt="<style type=\"text/css\"> ";

stxt+="DIV.minimenu{padding-left:"+mpadding+";padding-right:"+(mpadding)+";padding-top:"+mpadding+";padding-bottom:"+mpadding+";font-weight:"+fontweight+";font-family:"+font+";font-size:"+fontsize+"px;color:#"+menufgcolor+";background-color:#"+menubgcolor+"}";

stxt+="TD.minimenu {font-family:"+font+";font-size:"+fontsize+"px; font-weight:"+fontweight+";}";

stxt+="A.minimenu  {font-family:"+font+";font-size:"+fontsize+"px; font-weight:"+fontweight+";color:#"+menuonfgcolor+";text-decoration:none;}";

stxt+="</style>";

document.write(stxt);



lh=mpadding+fontsize;

for (a=1; a<menus; a++)

{	

	mentext="";

	menu=eval(menuarray[a-1]);	

	

	if (mie) {

		divwidth=" style='width:100%;' ";

		divcol="";

	} else if (mdom) {

		divwidth="style='width:"+(menu[3]-(mpadding*2))+";'";

		divcol="background-color:"+bordercolor+";";

	}

	

	if (NS)	{

		mentext+="<layer visibility=hidden bgcolor=#"+bordercolor+" name=\""+menuarray[a-1]+"\" left=\""+menu[1]+"\" top=\""+menu[0]+"\" width=\""+menu[3]+"\">";

	} else {

		mentext+="<div width="+menu[3]+" id=\""+menuarray[a-1]+"\" style=\""+divcol+";z-index:99;visibility:hidden; position:absolute;top:"+menu[0]+"px;left:"+menu[1]+"px\">";

	}

	mentext+="<table bgcolor=#"+bordercolor+" width="+menu[3]+" cellpadding=0 cellspacing="+menu[4]+" border=0>\n";

	acount= 0;

	divwidth="";

	if (mie) {

		divwidth=" style='width:100%;' ";

	} else if (mdom) {

		divwidth="style='width:"+(menu[3]-(mpadding*2))+";'";

	}

	

	atop=parseInt(menu[4]);

	for (b=arraycorrect; b<menu.length; b++) {		

		b=b+2;

		borderwidth=parseInt(menu[4]);

		bw=borderwidth*2;

		elcount++;

		acount++;



		if (NS) {			

			mentext+="<tr><td width="+menu[3]+">";

			mentext+="<layer bgcolor=#"+menubgcolor+" width="+(menu[3]-bw)+" name=mel"+elcount+" top="+(atop)+" left="+borderwidth+" onMouseOver=\"showel("+a+", "+acount+",1, '"+menu[b-1]+ "', '"+menuarray[a-1]+"')\" onMouseOut=\"showel("+a+","+acount+",0, '"+menu[b-1]+"', '"+menuarray[a-1]+"')\">\n";

			mentext+="<layer onmouseover=\"window.status='" + menu[b - 1] + "'; this.captureEvents(Event.CLICK); this.onclick=dc\" onmouseout=\"window.status=''\" width=" + (menu[3] - bw) + " name=el" + elcount + "  visibility=hidden bgcolor=#" + menuonbgcolor + ">";

			mentext+="<table><tr><td height="+lh+" class=minimenu bgcolor=#"+menuonbgcolor+" valign=middle>";

			mentext+="<a class=minimenu href='"+menu[b-1]+"' style='color:#"+menuonfgcolor+";text-decoration:none;'>"+menu[b-2]+"</a>";

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

			mentext+="</layer>";			

			mentext+="<table><tr><td height="+lh+" class=minimenu bgcolor=#"+menubgcolor+" valign=middle><font color=#"+menufgcolor+">"+menu[b-2]+"</font></td></tr></table>";

			mentext+="</layer>";

		} else if (mopera) {		

			mentext+="<tr><td style=\"color:#" + menufgcolor + ";background-color:#" + menubgcolor + ";\" class=minimenu onMouseOver=\"showel(" + a + ", " + elcount + ",1, '" + menu[b - 1] + "', '" + menuarray[a - 1] + "')\" onMouseOut=\"showel(" + a + "," + elcount + ",0, '" + menu[b - 1] + "', '" + menuarray[a - 1] + "')\">";

			mentext+="<a id=ophlid" + elcount + " href='" + menu[b - 1] + "' style=\"left:" + borderwidth + ";position:absolute;width:" + (menu[3] - bw) + ";text-decoration:none\">";

			mentext+="<div class=minimenu name=el" + elcount + " id=el" + elcount + " style=\"z-index:99;top:" + borderwidth + ";color:#" + menuonfgcolor + ";background-color:#" + menuonbgcolor + ";visibility:hidden\">" + menu[b - 2] + "</div>";

			mentext+="</a><div class=minimenu>" + menu[b - 2] + "</div>";		

		} else {

			mentext+="<tr><td width=" + menu[3] + ">";

			mentext+="<a href='" + menu[b - 1] + "' style='text-decoration:none;'>";			

			mentext+="<div class=minimenu " + divwidth;

			mentext+=" onMouseOver=\"popup(" + a +",1);this.style.cursor='hand';this.style.backgroundColor='#" + menuonbgcolor + "';this.style.color='#" + menuonfgcolor + "';\" ";

			mentext+=" onMouseOut=\"closemenu(" + a +");this.style.backgroundColor='#" + menubgcolor + "'; this.style.color='#" + menufgcolor + "';\">";

			mentext+=menu[b - 2] + "</div></a>";

		}



		mentext+="</td></tr>\n\n";

		document.write(mentext);

		mentext="";

		

		if (NS)	{

			mt=document.layers[a-1].document.layers[acount-1].document.layers[0];

			atop+=mt.clip.height+parseInt(menu[4]);

		}

	}

	if (NS) {mentext+="<tr><td><layer top="+(atop)+"></layer></td></tr>"}

	mentext+="</table>";

	if (NS) {mentext+="</layer>"} else {mentext+="</div>"}

	document.write(mentext);

			

	if (mopera)	{

		oh=0;

		optop=borderwidth;

		icount=elcount-oldcount;

		ecount=elcount-icount;

		for (x=1; x<=icount; x++) {

			cnt=ecount+x;

			mi=getmenuobj('el'+cnt)

			mia=getmenuobj('ophlid'+cnt)

			mia.top=optop;

			optop+=mi.pixelHeight+borderwidth;

		}

	oldcount=elcount;

	}

}

if (NS) {document.write("</layer>")} else {document.write("</div>")}
