var g_dhtml_started=false;
var g_bMenuOn;
var g_objSource=null;
var g_objSubSource=null;
var isIE=(document.all?true:false);

function fPopulateMenu(nMenuID, nSourceWidth){
	var sContent = '';
	sContent = '<div ><ul class="ulMenu2" dir="'+p_Menu_Dir+'" ><li style="height:0px;"><img src="/images/null.gif" style="width:' + (nSourceWidth-4) + 'px;height:0px;"/></li>';
	for(var a = 0; a < dhtmlMenu[nMenuID].length; a++){
		sContent += '<li>';
		if(dhtmlMenu[nMenuID][a][0].length!=0)
			sContent += '<a href="' + dhtmlMenu[nMenuID][a][0] +'"';
		else
			sContent += '<a href="#" onclick="return false"';
		if(dhtmlMenu[nMenuID][a][2]){
			sContent += ' class="sub"';
		}
		sContent += ' onmouseover="fShowSubMenu(this, ' + nMenuID + ', ' + a + ');">';
		sContent +=  dhtmlMenu[nMenuID][a][1]+'</a></li>';
	}
	sContent += '</ul><div>';
	return sContent;
}

function fPopulateSubMenu(oSource, nMenuID, nOptionID){
	var sContent = '';
	if(dhtmlMenu[nMenuID][nOptionID][2]){
		sContent = '<ul class="ulMenu2" dir="'+p_Menu_Dir+'"><li style="height:0px;"><img src="/images/null.gif" style="width:100px;height:0px;"/></li>';
		for(var a = 0; a < dhtmlMenu[nMenuID][nOptionID][2].length; a++){
			sContent += '<li>'
			if(dhtmlMenu[nMenuID][nOptionID][2][a][0].length!=0)
				sContent += '<a href="' + dhtmlMenu[nMenuID][nOptionID][2][a][0] +'">';
			else
				sContent += '<a href="#" onclick="return false">';
			sContent += dhtmlMenu[nMenuID][nOptionID][2][a][1] + '</a></li>\n';
		}
		sContent += '</ul>';
	}
	return sContent;
}

function fShowMenu(oSource, nMenuID){
	if(!g_dhtml_started)return;
	g_bMenuOn = false;
	fHideMenu();
	if(g_objSource && g_objSource!=oSource)g_objSource.className='';
	g_objSource=oSource;

	//HideAllSelects();
	dhtmlMainMenu.style.display = 'none';
	if(dhtmlMenu[nMenuID].length > 0){
		dhtmlMainMenu.innerHTML = fPopulateMenu(nMenuID, oSource.offsetWidth);


		if(isIE){
			var __left=fGetLeft(oSource);
			if(p_Menu_Dir=="rtl"){
				//document.getElementById('tblMain').style.direction="ltr";
				//__left=fGetLeft(oSource) + oSource.offsetWidth - 8;
				//document.getElementById('tblMain').style.direction="rtl";
				dhtmlMainMenu.style.right = __left - oSource.offsetWidth + 'px';
			}else{
				dhtmlMainMenu.style.left = __left + 'px';
			}
			dhtmlMainMenu.style.top = fGetTop(oSource) + (oSource.offsetHeight+2)+'px';
		}else{
			dhtmlMainMenu.style.left = fGetLeft(oSource) + 'px';
			dhtmlMainMenu.style.top = fGetTop(oSource) + (oSource.offsetHeight+2)+'px';
		}

		dhtmlMainMenu.style.zIndex='101';
		dhtmlMainMenu.style.display = 'inline';
		g_bMenuOn = true;
	}
}

function fShowSubMenu(oSource, nMenuID, nOptionID){
	if(!g_dhtml_started)return;
	g_bMenuOn = true;
	//fHideMenu();

	dhtmlSubMenu.style.display = 'none';
	if(dhtmlMenu[nMenuID][nOptionID][2]){
		dhtmlSubMenu.innerHTML = fPopulateSubMenu(oSource, nMenuID, nOptionID);
		dhtmlSubMenu.style.left = fGetLeft(oSource)+oSource.offsetWidth+'px';
		dhtmlSubMenu.style.top = fGetTop(oSource)+'px';
		dhtmlSubMenu.style.display = 'inline';
	}
}

function fHideMenu(){
	if(!g_bMenuOn){
		//DisplayAllSelects();
		if(g_objSource)g_objSource.className='';
		dhtmlMainMenu.style.display = 'none';
		dhtmlSubMenu.style.display = 'none';
	}else{
		if(g_objSource)g_objSource.className='onn';
		//if(g_objSubSource)g_objSubSource.className='onn';
	}
}

function fDelayedHide(){
//	g_bMenuOn=false;
	setTimeout('fHideMenu()', 1000);
}

function fGetLeft(obj){
   return(obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+fGetLeft(obj.offsetParent));
}

function fGetTop(obj){
   return(obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+fGetTop(obj.offsetParent));
}


document.write('<div id="dhtmlMainMenu" class="dhtmlMenuStyle" style="z-index:100;display: none; POSITION: absolute;" onmouseover="g_bMenuOn = true; " onmouseout="g_bMenuOn = false; fDelayedHide();"></div>')
document.write('<div id="dhtmlSubMenu" class="dhtmlMenuStyle" style="z-index:100;display: none; POSITION: absolute;" onmouseover="g_bMenuOn = true;" onmouseout="g_bMenuOn = false; fDelayedHide();"></div>')
var dhtmlMainMenu = document.getElementById('dhtmlMainMenu');
var dhtmlSubMenu = document.getElementById('dhtmlSubMenu');

var objSelect=document.getElementsByTagName('select');
function HideAllSelects(){
	for(var i=0;i<objSelect.length;i++){
		objSelect[i].style.visibility="hidden";
	}
}
function DisplayAllSelects(){
	for(var i=0;i<objSelect.length;i++){
		objSelect[i].style.visibility="visible";
	}
}

addEvent("onload",start_g_dhtml_started);
function start_g_dhtml_started(){
	g_dhtml_started=true;
}

function addEvent(name,evf){
	try{
		if (window.addEventListener)
		{
			//alert("1");
			if(eval("window.addEventListener(name, evf, false);"))
				window.addEventListener(name, evf, false);
			else if(document.getElementById)
				eval("window."+name+"="+evf);
		}
		else if (window.attachEvent)
		{
			//alert("2");
			window.attachEvent(name, evf);
		}
		else if (document.getElementById)
		{
			//alert("3");
			eval("window."+name+"="+evf);
		}
	}catch(err){;}
}

