/////////////// Menu SDK,MFM /////////////////////////
function menuInterface()
{
	this.ret = ret;
	this.iret = iret;
	function ret(id) {	    
		return document.getElementById(id);
	}//ret
	function iret(iframe,id)
	{
	    var Iobj = eval(iframe);
	    if (Iobj.document)
	        return eval(iframe + ".document.getElementById('" + id + "')");
	    else
	        return eval(iframe + ".contentDocument.getElementById('" + id + "')");
	}
}//menuInterface

/** Menu **/
function mainMenu(myName)
{
	//member variables
	this.objName = myName;
	this.mainDiv = "slideMenuDiv";
	this.currentOpened = "";
	this.hideDelay = "500";
	this.effect = "none";
	this.mouseover = "";
	this.mouseout = "";
	this.onclick = "";
	this.imagePath = "";
	this.cssPath = "";
	n=navigator.appName
	this.IE5 = ((document.all)&&(document.getElementById)) ? true : false;
	this.NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
	if(this.IE5){this.mouseover="onmouseenter";this.mouseout="onmouseleave";this.onclick="onmousedown";}
	else{this.mouseover="onmouseover";this.mouseout="onmouseout";this.onclick="onclick";}
	//member objects
	this.menuItems = new Array();
	this.effects = new Array();
	//member functions
	this.renderItems = renderItems;
	this.addUpperItem = addUpperItem;
	this.getTDX = getTDX;
	this.getTDY = getTDY;
	this.clearTimeOutCurrent = clearTimeOutCurrent;
	filterPre = "filter:progid:DXImageTransform.Microsoft.";
	this.effects["none"] = "";
	this.effects["wipe"] = filterPre+"Wipe(GradientSize=1.0)";
	this.effects["fade"] = filterPre+"Fade(duration=0.5,overlap=0)";
	this.effects["dissolve"] = filterPre+"RandomDissolve(duration:0.3)";
	this.effects["stretch"] = filterPre+"Stretch(duration=0.3)";
	function addUpperItem(mainItem)
	{
		this.menuItems[this.menuItems.length] = mainItem;
	}//addMainMenuItem
	function renderItems()
	{
		//this.effect="wipe";
	    var menuDiv = this.ret(this.mainDiv);	    
		var str = "";
		str +="<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";
		for(i=0;i<this.menuItems.length;i++)
		{
			var mainItem = this.menuItems[i];
			mainItem.parentMenu = this;
			str += "<td id='td_"+mainItem.objName+"' background='"+this.imagePath+"upmenuback.gif'"+
					" align='center' style='cursor:hand;padding-bottom:2;' "+this.mouseover+"='"+mainItem.objName+
					".showMyChildren(this);' "+this.mouseout+"='"+mainItem.objName+".timeOut = setTimeout(\""+
					mainItem.objName+".hideMyChildren();\","+this.hideDelay+");'> <a href='"+mainItem.link+"' ";
			str +=" onclick='return false;' "
			str += "class='UpperBar'> "+mainItem.label+" </a><iframe id='mainDiv_"+mainItem.objName+"'"+
				" SCROLLING='no' FRAMEBORDER=0 marginWidth='0' marginHeight='0' "+
				" class='m0l1oout' style=';position:absolute;visibility:hidden;top:0;left:0;z-index:100;";
			//if(this.NS6)str+= "width:130px";
			str+= lang=="ar"?"width:130px":"width:165px";
			if(this.effects[this.effect]&&this.IE5)str +=this.effects[this.effect];
			str +="' ></iframe></td>";
			if(i<(this.menuItems.length-1))
				str += "<td bgcolor='black' width='1'><img src='"+this.imagePath+"MM.gif'"+
							" border='0'></td>";
		}//for
		str += "</tr></table>";
		menuDiv.innerHTML = str;
		for(i=0;i<this.menuItems.length;i++)
		{
			this.menuItems[i].renderMainItems();
		}//for
	}//renderMainItems
	function getTDX(TDObj)
	{
		var o = TDObj;
		var oLeft = o.offsetLeft;
		while(o.offsetParent!=null) 
		{   
			oParent = o.offsetParent;
			oLeft += oParent.offsetLeft;
			o = oParent;
		}//while
		return oLeft;
	}//getTDX
	function getTDY(TDObj)
	{
		var o = TDObj;
		var oTop = o.offsetTop;
		while(o.offsetParent!=null) 
		{ 
			oParent = o.offsetParent;
			oTop += oParent.offsetTop;
			o = oParent;
		}
		return oTop+28;
	}//getTDX
	function clearTimeOutCurrent()
	{
		if(eval(this.currentOpened) && eval(this.currentOpened).timeOut)
			{clearTimeout(eval(this.currentOpened).timeOut);}
	}//clearTimeOutCurrent
}//mainMenu
mainMenu.prototype = new menuInterface();

/**Upper**/
function upperItem(label,link,oName)
{
	//member variables
	this.objName = oName;
	this.label = label;
	this.link = link;
	this.parentMenu = null;
	this.timeOut = null;
	//member objects
	this.menuItems = new Array();
	//member functions
	this.showMyChildren = showMyChildren;
	this.hideMyChildren = hideMyChildren;
	this.renderMainItems = renderMainItems;
	this.addMainItem = addMainItem;
	function addMainItem(mainItem)
	{
		this.menuItems[this.menuItems.length] = mainItem;
	}//addMainMenuItem
	function showMyChildren()
	{
		this.parentMenu.clearTimeOutCurrent();
		var targetDiv = this.ret("mainDiv_" + this.objName);
		var targetTD = this.ret("td_" + this.objName);
		
		var current = this.parentMenu.currentOpened;
		if(this.ret("mainDiv_"+current) && current!=this.objName)
		{
			this.ret("mainDiv_"+current).style.visibility = 'hidden';
		}//if
		this.parentMenu.currentOpened = this.objName;
		targetDiv.style.left = this.parentMenu.getTDX(targetTD);
		targetDiv.style.top = this.parentMenu.getTDY(targetTD);
		
		if(this.parentMenu.IE5 && targetDiv.filters[0])
		{
			targetDiv.filters[0].apply();
			targetDiv.filters[0].play();	
		}//if
		targetDiv.style.visibility = 'visible';
		
	}//showMyChildren
	function hideMyChildren()
	{
		var targetDiv = this.ret("mainDiv_"+this.objName);
		this.parentMenu.currentOpened = "";
		targetDiv.style.visibility = 'hidden';	
		clearTimeout(this.timeOut);
	}//showMyChildren
	function renderMainItems()
	{
		var str="";
		str +="<table height='100%' id='tabl_"+this.objName+"' width='100%' border='0' cellpadding='2' cellspacing='0'>";
		for(j=0;j<this.menuItems.length;j++)
		{
			var mainItem = this.menuItems[j];
			var bottom = "border-bottom-width:1;";
			str += "<tr><td id='td_"+mainItem.objName+"' class='m0l1oout' onmouseover='this.className"+
						"=\"m0l1oover\";window.parent."+this.objName+".ret(\"mainDiv_"+this.objName+"\").className=\"m0l1oover\";'"+
						" onmouseout='this.className=\"m0l1oout\";window.parent."+this.objName+".ret(\""+"mainDiv_"+this.objName+"\").className=\"m0l1oout\";'";
			if(mainItem.menuItems.length>0)
			{
				if(this.parentMenu.IE5)str +=" onclick='return false;'";
				str += " "+this.parentMenu.onclick+"='window.parent."+mainItem.objName+".showMyChildren();return false;' ";
			}//if
			if(j==(this.menuItems.length-1)){bottom ="";}
			str += " style='cursor:hand;border-width:0;"+bottom+"border-left-width:0;border-right-width:0;' nowrap>";
			if(mainItem.menuItems.length>0)str+='<img src="'+this.parentMenu.imagePath+'marr.gif">';
			str += "<a href='"+mainItem.link+"' target='_top' "+
			 " class='m0l1iout'><b>"+mainItem.label+"</b></a><br/><div id='mainDiv_"+mainItem.objName+"'"+
			 " style='display:none;width:100%'>";
			 str += "<table width='100' border='0'>"+mainItem.renderSubItems()+"</table>";
			 str +="</div></td></tr>";
			 mainItem.parentMenu = this;			 
		}//for
		str += "</table>";
		
		//try
		//{
		var dirStr = lang == "ar" ? "rtl" : "ltr";
		var obj1 = eval("mainDiv_" + this.objName);
		if (obj1.contentDocument) {
		    eval("mainDiv_" + this.objName + ".contentDocument.open()");
		    eval("mainDiv_" + this.objName + ".contentDocument.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"'+this.parentMenu.cssPath+'\"> ');");
		    eval("mainDiv_" + this.objName + ".contentDocument.write(str);");
		    eval("mainDiv_" + this.objName + ".contentDocument.close()");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.topMargin='0';");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.leftMargin='0';");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.rightMargin='0';");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.bottomMargin='0';");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.borderStyle ='none';");
		    eval("mainDiv_" + this.objName + ".contentDocument.body.scroll ='no';");

		    eval("mainDiv_" + this.objName + ".contentDocument.body.dir ='" + dirStr + "';");
		}
		else {
		    eval("mainDiv_" + this.objName + ".document.open()");
		    eval("mainDiv_" + this.objName + ".document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"'+this.parentMenu.cssPath+'\"> ');");
		    eval("mainDiv_" + this.objName + ".document.write(str);");
		    eval("mainDiv_" + this.objName + ".document.close()");
		    eval("mainDiv_" + this.objName + ".document.body.topMargin='0';");
		    eval("mainDiv_" + this.objName + ".document.body.leftMargin='0';");
		    eval("mainDiv_" + this.objName + ".document.body.rightMargin='0';");
		    eval("mainDiv_" + this.objName + ".document.body.bottomMargin='0';");
		    eval("mainDiv_" + this.objName + ".document.body.borderStyle ='none';");
		    eval("mainDiv_" + this.objName + ".document.body.scroll ='no';");

		    eval("mainDiv_" + this.objName + ".document.body.dir ='" + dirStr + "';");
		}
			//eval("mainDiv_"+this.objName+".document.body.dir ='"+document.dir+"';");
			var rnum = this.iret("mainDiv_"+this.objName,"tabl_"+this.objName).rows.length;
			var itemHeight =lang=="ar"?"17":"19"; 
			this.ret("mainDiv_"+this.objName).style.height = rnum*itemHeight;
		//}//try
		//catch
		//{
		//	alert("For your browser settings, Menu Couldn't be loaded this time.");
		//}//catch
	}//renderMainItems
}//mainMenuItem
upperItem.prototype = new menuInterface();
/**Main**/
function mainItem(label,link,oName)
{
	//member variables
	this.objName = oName;
	this.label = label;
	this.link = link;
	this.parentMenu = null;
	//member objects
	this.menuItems = new Array();
	//member functions
	this.showMyChildren = showMyChildren;
	this.renderSubItems = renderSubItems;
	this.addSubItem = addSubItem;
	function renderSubItems()
	{
		str="";
		for (k=0;k<this.menuItems.length;k++)
		{
		    var item = this.menuItems[k];			
			str+="<tr><td nowrap heigth='14'><a onmousedown='window.parent.location=\""+item.link+"\"' "+
				"class='m0l2iover' "+
				"href='"+item.link+"' target='_top'>"+item.label+"</a></td></tr>";
		}//for
		return str;
	}//renderSubItems
	function addSubItem(item)
	{
		this.menuItems[this.menuItems.length] = item;
	}//addMainMenuItem
	function showMyChildren()
	{
		if(this.parentMenu.parentMenu.IE5 && eval("mainDiv_"+this.parentMenu.objName).event.srcElement.tagName=="A")
			return;
		var targetDiv = this.iret("mainDiv_"+this.parentMenu.objName,"mainDiv_"+this.objName);
		var curH = this.ret("mainDiv_"+this.parentMenu.objName).style.height;
		if(targetDiv.style.display=='none')
		{
			targetDiv.style.display = 'inline';
			this.ret("mainDiv_"+this.parentMenu.objName).style.height = parseInt(curH)+parseInt(this.menuItems.length*17);
		}
		else
		{
			targetDiv.style.display = 'none';
			this.ret("mainDiv_"+this.parentMenu.objName).style.height = parseInt(curH)-parseInt(this.menuItems.length*17);
		}
	}
}//mainMenuItem
mainItem.prototype = new menuInterface();
/**Sub**/
function subItem(label,link,oName)
{
	//member variables
	this.objName = oName;
	this.label = label;
	this.link = link;
	//this.parentMenu = null;
}//mainMenuItem





