//	Modify following four lines to customize your menu
var tdColor="#000000";		// menu item text color
var tdBgColor="#BBDDFF";	// menu item background color
var hlColor="#000000";		// highlight text color
var hlBgColor="#FFFFFF";	// highlight background color
//	After change, modify same values in your DropDown.css file

////////////////////DO NOT MODIFY BELOW HERE//////////////////////
var md=250; 				// The amount of time it takes to timeout
var ti=-1;
var oTd=new Object;
oTd=null;
var tt="";
var sT="";
var pT=new Array();
var tA=new Array();

function doMenu(td){
	clearTimeout(ti);
	td.style.backgroundColor=hlBgColor;
	td.style.color=hlColor;
	var i;
	var sT="";
	var tda=new Array();
	tda=td.id.split("_");
	if(oTd!=null){
		var tdo=new Array();
		tdo=oTd.id.split("_");
		for(i=1;i<tdo.length;i++){
			sT+="_"+tdo[i];
			if(tdo[i]!=tda[i]){
				document.getElementById("td"+sT).style.backgroundColor=tdBgColor;
				document.getElementById("td"+sT).style.color=tdColor;
				if(document.getElementById("tbl"+sT)!=null)
					document.getElementById("tbl"+sT).style.visibility="hidden";
			}
		}			
	}
	oTd=td;
	sT="tbl";
	for(i=1;i<tda.length;i++)
		sT+="_"+tda[i];
	if(document.getElementById(sT)!=null)
		document.getElementById(sT).style.visibility="visible";

}

function clearMenu(){
	if(oTd!=null){
		var tdo=new Array();
		tdo=oTd.id.split("_");
		var sT="";
		for(var i=1;i<tdo.length;i++){
			sT+="_"+tdo[i];
			document.getElementById("td"+sT).style.backgroundColor=tdBgColor;
			document.getElementById("td"+sT).style.color=tdColor;
			if(document.getElementById("tbl"+sT)!=null)
				document.getElementById("tbl"+sT).style.visibility="hidden";
		}
		oTd=null;			
	}
}

function runMenu(strURL){
	location.href=strURL;
}

function getCoord(st){
	tA=st.split("_");
	if(tA.length>2){
		tA=tA.slice(0,-1);
		tt=tA.join("_");
		return (document.getElementById("tbl"+tt).offsetTop+document.getElementById("td"+st).offsetTop-5)+"px;left:"+
			(document.getElementById("tbl"+tt).offsetLeft+document.getElementById("td"+st).offsetWidth-5)+"px\">";
	}
	return (document.getElementById("mainmenu").offsetTop+document.getElementById("td"+st).offsetTop-5)+"px;left:"+
		  (document.getElementById("mainmenu").offsetLeft+document.getElementById("td"+st).offsetWidth-5)+"px\">";
}
var wd = 200;
var ht = 20;
var ct = 0;
function createMenu(){
	//var mydiv = element = document.getElementById(divid);
	var rtn = "";
	var sH="<div class=\"menu\" id=\"mainmenu\" cellspacing=\"0\">";
	var p=0;
	var j=0;
	
	// If the next j exists as a table row
	while(eval("typeof(td_"+ ++j +")!=\"undefined\"")){
		ct++;
		// create it
		sH+="<div "+
		"style=\"border: 1px solid black; left: 0px; top: "+(j*ht)+"px; width: "+wd+"px; height: "+ht+"px;\" "+
		"id=\"td_"+j+"\" onmouseover=\"doMenu(this)\" onmouseout=\"ti=setTimeout('clearMenu()',md)\"";
		// If there is a url create a click through
		sH+=(eval("typeof(url_"+j+")!=\"undefined\""))?" onclick=\"runMenu('"+eval("url_"+j)+"')\">":">";
		// print the text and end row
		sH+=eval("td_"+j)+"</div>";
		// If there is a child add it to the child loop array
		if (eval("typeof(td_"+j+"_1)!=\"undefined\""))
			pT[p++]="_"+j;
	}
	sH+="</div>";
	rtn = sH;
	//mydiv.innerHTML=rtn;
	document.write(rtn);
	//return;
	// Sort Of Recursive Because Its a loop that adds to itself
	// Loop Until we have written all the child tables
	// Checks for the existance of the variable is not undefined
	for(var q=0;typeof(pT[q])!="undefined";q++){
		// The numeric ID of the parent table row 
		sT=pT[q];
		// The print variable
		sH="";
		// The count variable the same as before
		j=0;
		// The print variable now with position	
		sH+="<div class=\"menu\" id=\"tbl"+sT+"\" cellspacing=\"0\" style=\"top:"+getCoord(sT);
		// If the next j exists as a table row		
		while (eval("typeof(td"+sT+"_"+ ++j +")!=\"undefined\"")){
			ct++;
			// create it			
			sH+="<div "+
			"style=\"border: 1px solid black; left: 0px; top: "+(j*ht)+"px; width: "+wd+"px; height: "+ht+"px;\" "+			
			"id=\"td"+sT+"_"+j+"\" onmouseover=\"doMenu(this)\" onmouseout=\"ti=setTimeout('clearMenu()',md)\"";
			// If there is a url create a click through			
			sH+=(eval("typeof(url"+sT+"_"+j+")!=\"undefined\""))?" onclick=\"runMenu('"+eval("url"+sT+"_"+j)+"')\">":">";
			// print the text and end row			
			sH+=eval("td"+sT+"_"+j)+"</div>";
			// If there is a child add it to the child loop array			
			if (eval("typeof(td"+sT+"_"+j+"_1)!=\"undefined\""))
				pT[p++]=sT+"_"+j;
		}
		sH+="</div>";
		rtn = sH;
		//mydiv.innerHTML=rtn;
		document.write(rtn);
	}
	document.getElementById("mainmenu").style.visibility="visible";
}