var over_submenu = new Array();  
var over_submenu_submenu = new Array();
for (i=0; i< subbmenusText.length; i++){
	html="";
	html=html+"<div id=\"submenu"+i+"\" onMouseOver=\"over_submenu["+i+"]=true;\" onMouseOut=\"over_submenu["+i+"]=false; deactivateAllDelay();\" style=\"position:absolute;cursor:hand; width:"+submenu_width+"px; z-index:10; visibility: hidden;   border: 1px none #000000\">";   
	if (subbmenusText[i].length>0){
		html=html+"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >";   
		for (j=0; j< subbmenusText[i].length; j++){
			if(j > 1 && submenu_item_spacing > 0) {
				html=html+"<tr><td><img src=\"spacer.gif\" width=\"1\" height=\""+submenu_item_spacing+"\"></td></tr>";
			}	
			html=html+"<tr><td><div id=\"submenu"+i+"_"+j+"\" onClick=\"link('"+subbmenusLink[i][j]+"','"+submenu_url_target+"');\" onMouseOver=\"over_submenu["+i+"]=true; setItemColor('submenu"+i+"_"+j+"','"+submenu_highlight_color+"','"+submenu_font_highlight_color+"');\" onMouseOut=\"over_submenu["+i+"]=false; deactivateAllDelay(); setItemColor('submenu"+i+"_"+j+"','"+submenu_background_color+"','"+submenu_font_color+"');\" style=\"position:relative; width:"+submenu_width+"px; height: "+submenu_item_height+"; z-index:10; left: 0px; top: 0px;   visibility: inherit;  background-color: "+submenu_background_color+"; layer-background-color: "+submenu_background_color+"; color: "+submenu_font_color+"\"><table border='0' cellspacing='0' cellpadding='0' background='images/public/subbutton.jpg' width='136 height='31'><tr><td align='right' class='menu' valign='center' width='136'>	<a id=\"submenu"+i+"_"+j+"a\" href='"+subbmenusLink[i][j]+"' target='"+submenu_url_target+"' style=\"cursor : hand;\" class=\"submenu\"><img src=\"spacer.gif\" width=\""+submenu_item_indent+"\" height=\"1\" border=\"0\">"+subbmenusText[i][j]+"</a></td><td width='1'><img src='spacer.gif' width='1' height='31' border='0' align='right'>	</td></tr></table></div></td></tr>"; 
		}   
		html=html+"</table>";  
	}
	html=html+"</div>";
	document.write(html);
	//alert(html);
}

function activate(id) {   
	over_submenu[id] = true;   
	deactivateAll();   
	showSubMenu(id); 
	}  ;
	
function deactivate(id) {   
	over_submenu[id] = false;   
	deactivateAllDelay(); 
}  ;
function deactivateAllDelay() {   
	setTimeout("deactivateAll()",200); 
}  ;

function deactivateAll() {   
	var id = 0; 
	while(eval("document.getElementById(\"link"+id+"\")")) {  
	
		if(!over_submenu[id]) { 
			//alert("hiding submenu"+id);		
			hideSubMenu(id);       
		}     
		id++;   
	} 
}  ;

function setImageSrc(theImageName,theImageSrc) {   
	if(document.images) {     
		document.images[theImageName].src=theImageSrc;   
	} 
}  ;

function link(url, target) {   
	if(target == "_self") {     
		window.location.href=url;   
	}   else {     
		window.open(url, target);   
	} 
}  ;

function showSubMenu(id) {   
	var theLinkName = "link" + id;   
	var theLink = document.getElementById(theLinkName);   
  	var theSubMenu = eval("submenu"+id);   
	//alert(eval("document.getElementById(\""+theLinkName+"\").offsetTop"));
	theSubMenu.style.top = getCoordinates(theLink).y + submenu_y;   
	theSubMenu.style.left = getCoordinates(theLink).x + submenu_x;  
	theSubMenu.style.visibility = 'visible'; 
}  ;

function getCoordinates(obj) { 
	var newObj = new Object();   
	newObj.x = obj.offsetLeft;   
	newObj.y = obj.offsetTop;   
	theParent = obj.offsetParent;   
	while(theParent != null){     
		newObj.y += theParent.offsetTop;     
		newObj.x += theParent.offsetLeft;     
		theParent = theParent.offsetParent;   
	}   
	return newObj;  
}  ;

function setItemColor(theItemName,theItemBgColor,theItemColor) {   
	document.getElementById(theItemName).style.backgroundColor=theItemBgColor;  
	//document.getElementById(theItemName+"a").style.color=theItemColor;
}  ;

function hideSubMenu(id) {   
	var theSubMenu = eval("submenu"+id);  
	if (theSubMenu!=null){
	//alert(id)	;
		theSubMenu.style.visibility='hidden'; 
	}
} 