/////////////// Menu SDK,MFM /////////////////////////
function menuInterface()
{
	this.ret = ret;
	this.iret = iret;
	function ret(id)
	{
		return document.getElementById(id);
	}//ret
	function iret(iframe,id)
	{
		if(IsIE())
		    return eval(iframe + ".document.getElementById('" + id + "')");
		else
		    return eval(iframe + ".contentWindow.document.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 = "";
	this.menuItemHeight=21;
	this.menuItemWidth=122;
	this.separatorName = "MM.gif";
	this.id = "";
	this.IE8Flag = "";
	this.topCorrection = 0;
	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 = '<link rel=\"stylesheet\" type=\"text/css\" href=\"'+this.cssPath+'\"> ';
		str +="<table border='0' cellpadding='0' width='100%' cellspacing='0'><tr>";
		for(i=0;i<this.menuItems.length;i++)
		{
			var mainItem = this.menuItems[i];
			mainItem.parentMenu = this;
			str += "<td nowrap class='" + this.id + "UpperBarTD' id='td_" + mainItem.objName + "' " +
					" align='center' style='cursor:hand;' "+this.mouseover+"='"+mainItem.objName+
					".showMyChildren(this);' "+this.mouseout+"='"+mainItem.objName+".timeOut = setTimeout(\""+
					mainItem.objName+".hideMyChildren();\","+this.hideDelay+");'><a href='"+mainItem.link+"' ";
			if(mainItem.link=="")
			    str += " onclick='return false;' ";
			var _objectType = IsIE() && !IsNewerThanIE6() ? "iframe" : "div";
			str += "class='" + this.id + "UpperBar'> " + mainItem.label + " </a><" + _objectType + " src='javascript: ;' id='mainDiv_" + mainItem.objName + "'" +
				" SCROLLING='no' FRAMEBORDER=0 marginWidth='0' marginHeight='0' "+
				" class='" + this.id + "IFrameStyle' style='position:absolute;visibility:hidden;top:0;left:0;z-index:100;";
			str+= "width:"+this.menuItemWidth+"px;";
			if(this.effects[this.effect]&&this.IE5)str +=this.effects[this.effect];
			str += "' ></" + _objectType + "></td>";
			var _imgHTML = this.separatorName!=""?"<img src='"+this.imagePath+this.separatorName+"'"+
							" border='0'>":"";
			
			if(i<(this.menuItems.length-1))
			    str += "<td width='1' class='" + this.id + "SeparatorTD'></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 + this.menuItemHeight + 3 + this.topCorrection;
	}//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)+"px";
		targetDiv.style.top = this.parentMenu.getTDY(targetTD) + "px";
		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 += "<div style='width:100%;height:100%;'><table height='100%' id='tabl_" + this.objName + "' width='100%' border='0' cellpadding='0' cellspacing='0'>";
		for(j=0;j<this.menuItems.length;j++)
		{
			var mainItem = this.menuItems[j];
			var bottom = "";
			str += "<tr><td id='td_" + mainItem.objName + "' class='" + this.parentMenu.id + "MenuItemOut" + this.parentMenu.IE8Flag + "' onmouseover='this.className" +
						"=\"" + this.parentMenu.id + "MenuItemOver" + this.parentMenu.IE8Flag + "\";'" +
						" onmouseout='this.className=\"" + this.parentMenu.id + "MenuItemOut" + this.parentMenu.IE8Flag + "\";'";
			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;' nowrap>";
			if(mainItem.menuItems.length>0)str+=' &nbsp; <img src="'+this.parentMenu.imagePath+'marr.gif">';
			str += "<a href='"+mainItem.link+"' target='_top' "+
			 " class='" + this.parentMenu.id + "MenuItemlink'>" + mainItem.label + "</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></div>";
		try
		{
		    var _iFrameDocument = null;
		    if (IsIE() && !IsNewerThanIE6()) 
		    {
		        var _iFrameDocument = IsIE() ? eval("mainDiv_" + this.objName + ".document") : ret("mainDiv_" + this.objName).contentWindow.document;
		        _iFrameDocument.open();
		        _iFrameDocument.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"' + this.parentMenu.cssPath + '\"> ');
		        _iFrameDocument.write("<html><body id='ifBody'></body></html>");
		        var _iFrameDocumentBody = _iFrameDocument.getElementById('ifBody');
		        _iFrameDocumentBody.padding = '0px';
		        _iFrameDocumentBody.borderStyle = 'none';
		        _iFrameDocumentBody.scroll = 'no';
		        var lang = "en";
		        var dirStr = lang == "ar" ? "rtl" : "ltr";
		        _iFrameDocument.body.dir = dirStr;
		        _iFrameDocument.write(str);
		        _iFrameDocument.close();
		        var rnum = this.menuItems.length;
		        this.ret("mainDiv_" + this.objName).style.height = ((rnum * (this.parentMenu.menuItemHeight + 4)) - 0) + "px";
		    }//if
		    else
		        ret("mainDiv_" + this.objName).innerHTML = str;			
		}//try
		catch(ex)
		{
			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='" + this.id + "MenuSubItemlink' " +
				"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





