var timeOn=null;
var numMenus=50;
var currentMenuNo=0;
var menuActive=new Array(numMenus);
var tier=new Array(numMenus);
var borderMod=new Array(numMenus);
var menuType=new Array(numMenus);
var menus=new Array(numMenus);

function menuOver(){clearTimeout(timeOn);}

function menuOut(){timeOn=setTimeout("hideAllMenus()",500);}

function showMenu(m_No,eventObj){
	hideAllMenusTier(tier[m_No]-1);
	var borderModSize=borderMod[m_No];
	menuActive[m_No]=true;
	if (menuType[m_No]!='blank'){
		labelObj='labelCell'+m_No;
		x=getElementLeft(labelObj)-borderModSize;
		y=getElementTop(labelObj)+getElementHeight(labelObj);
		if (menus[m_No].align=='right')x=x+((getElementWidth(labelObj)-getElementWidth('menu'+m_No)))+(borderModSize*2);
		moveXY('menu'+m_No,x,y);
		if(changeObjectVisibility('menu'+ m_No,'visible'))return true;
    else return false;
	}
}

function showMenuSide(m_No,eventObj,myTier){
	hideAllMenusTier(tier[m_No]-1);
	var borderModSize=borderMod[m_No];
	menuActive[m_No]=true;
	if (menuType[m_No]!='blank'){
		labelObj='labelCell'+m_No;
		if(mac_ie)labelObj='labelRow'+m_No;
		x=getElementLeft(labelObj);
		y=getElementTop(labelObj)-borderModSize;
		if(menus[m_No].align=='right')x=(x+getElementWidth(labelObj))-10;
		else x=x-getElementWidth('menu'+m_No)+10;
		moveXY('menu'+m_No,x,y);
		if(changeObjectVisibility('menu'+ m_No,'visible'))return true;
	  else return false;
	}
}

function hideAllMenus(){for(var i=1;i<(currentMenuNo+1); i++){if(menuActive[i]==true)hideMenu(i);}}

function hideAllMenusTier(myTier){for(var i=1;i<(currentMenuNo+1);i++){if(tier[i]>myTier&&menuActive[i]==true)hideMenu(i);}}

function hideMenu(m_No){
	menuActive[m_No]=false;
	if(changeObjectVisibility('menu'+m_No,'hidden'))return true;
  else return false;
}

function menuBar(){this.addLabel=function(menuNo){numLabels=1;tier[menuNo]=0;borderMod[menuNo]=0;}}

function menu(){
	currentMenuNo+=1;
	this.numItems=0;
	this.itemText=new Array();
	this.rowText=new Array();
	this.addItem=function(itemText,menuNo,itemURL){
		this.numItems+=1;
		var tempId=currentMenuNo+'_'+this.numItems;
		if(menuNo!=null){tier[menuNo]=tier[currentMenuNo]+1;borderMod[menuNo]=0;}
		temp=new String('');
		this.rowText[this.numItems]=new String('');
		temp+='<li id="labelCell'+menuNo+'" onclick="document.location.href=\''+itemURL+'\';" onmouseover="menuOver(); ';
		if(menuNo!=null){temp+='return !showMenuSide('+menuNo+',event,tier['+menuNo+']);"';}
		else{temp+='hideAllMenusTier(tier['+currentMenuNo+']);"';}
		temp+=' onmouseout="menuOut();">';
		temp+='<div id="menuLabel'+menuNo+'">';
		temp+='<a href="'+itemURL+'" id="menuLink'+menuNo+'">';
		if(menuNo!=null){temp+='<img src="/images/bg-navtop-li-level2-ar.gif" />';}
		temp+=itemText+'</a></div></li>';	
		this.itemText[this.numItems]=new String(temp);
	}
	this.writeMenu=function(){
		var menuStr=new String();
		if (this.numItems==0)menuType[currentMenuNo]='blank';
		else menuType[currentMenuNo]='default';
		menuStr+='<div id="menu'+currentMenuNo+'" name="menu'+currentMenuNo+'" class="submenu">';
		menuStr+='<ul>';
		for (var count=0;count<this.numItems;count++){
			menuStr+=this.rowText[count+1];
			menuStr+=this.itemText[count+1];
		}
		menuStr+='</ul><!--[if lte IE 6.5]><iframe></iframe><![endif]--></div>';
		document.write(menuStr);
	}
}
//The root main menus
myTest=new menuBar();
myTest.addLabel(1);
myTest.addLabel(2);
myTest.addLabel(3);
myTest.addLabel(4);
myTest.addLabel(5);

//BOOKINGS
menus[1]=new menu();
menus[1].addItem('&#1580;&#1583;&#1608;&#1604;&#32;&#1575;&#1604;&#1605;&#1608;&#1575;&#1593;&#1610;&#1583;',null,'http://booking.qatarairways.com/qribe-web/public/showSearch.do?L=ar&hdnFrom=TIMETABLE');
menus[1].writeMenu();

//THE EXPERIENCE
menus[2]=new menu();
menus[2].addItem('&#1601;&#1610;&#32;&#1575;&#1604;&#1605;&#1591;&#1575;&#1585;',null,'/global/ar/at-the-airport.html');
menus[2].addItem('&#1575;&#1604;&#1571;&#1605;&#1578;&#1593;&#1577;',null,'/global/ar/baggage.html');
menus[2].addItem('&#1578;&#1587;&#1580;&#1610;&#1604; &#1575;&#1604;&#1583;&#1582;&#1608;&#1604; &#1575;&#1604;&#1573;&#1604;&#1603;&#1578;&#1585;&#1608;&#1606;&#1610;',null,'/global/ar/online-checkin.html');
menus[2].addItem('&#1575;&#1604;&#1578;&#1608;&#1602;&#1601; &#1575;&#1604;&#1591;&#1608;&#1610;&#1604;',null,'/global/ar/stopovers.html');
menus[2].addItem('&#1576;&#1610;&#1575;&#1606;&#1575;&#1578; &#1575;&#1604;&#1605;&#1587;&#1575;&#1601;&#1585;',null,'/global/ar/apis.html');
menus[2].addItem('&#1593;&#1604;&#1609; &#1605;&#1578;&#1606; &#1575;&#1604;&#1591;&#1575;&#1574;&#1585;&#1577;',6,'/global/ar/onboard-ar.html');
menus[2].addItem('&#1578;&#1606;&#1576;&#1610;&#1607;&#1575;&#1578; &#1605;&#1578;&#1593;&#1604;&#1602;&#1577; &#1576;&#1575;&#1604;&#1587;&#1601;&#1585;',7,'/global/ar/travel-alert.html');

menus[2].writeMenu();

//SPECIAL OFFERS
menus[3]=new menu();
menus[3].addItem('&#1575;&#1604;&#1606;&#1588;&#1585;&#1577;&#32;&#1575;&#1604;&#1573;&#1582;&#1576;&#1575;&#1585;&#1610;&#1577;&#32;&#1575;&#1604;&#1573;&#1604;&#1603;&#1578;&#1585;&#1608;&#1606;&#1610;&#1577;',null,'/global/ar/newsletter.html');
menus[3].addItem('&#1571;&#1576;&#1608; &#1592;&#1576;&#1610;',null,'/global/ar/special-offers-abudhabi.html');
menus[3].addItem('&#1575;&#1604;&#1583;&#1605;&#1617;&#1575;&#1605;',null,'/global/ar/special-offers-dammam.html');
menus[3].addItem('&#1575;&#1604;&#1583;&#1608;&#1581;&#1577;',null,'/global/ar/special-offers-doha.html');
menus[3].addItem('&#1583;&#1576;&#1610;',null,'/global/ar/special-offers-dubai.html');
menus[3].writeMenu();

//PRIVILEGE CLUB
menus[4]=new menu();
menus[4].addItem('&#1606;&#1575;&#1583;&#1610;&#32;&#1575;&#1604;&#1573;&#1605;&#1578;&#1610;&#1575;&#1586;',null,'http://www.qmiles.com/');
menus[4].writeMenu();

//ABOUT US
menus[5]=new menu();
menus[5].addItem('&#1585;&#1587;&#1575;&#1604;&#1577; &#1575;&#1604;&#1585;&#1574;&#1610;&#1587; &#1575;&#1604;&#1578;&#1606;&#1601;&#1610;&#1584;&#1610;',null,'/global/ar/ceo-message.html');
//menus[5].addItem('&#1575;&#1604;&#1582;&#1591;&#1608;&#1591;&#32;&#1575;&#1604;&#1580;&#1608;&#1610;&#1577;&#32;&#1575;&#1604;&#1602;&#1591;&#1585;&#1610;&#1577;&#32;&#1601;&#1610;&#32;&#1602;&#1591;&#1585;',null,'/global/ar/qatar-airways.html');
menus[5].addItem('&#1571;&#1587;&#1591;&#1608;&#1604;&#1606;&#1575;', null,'/global/ar/our-fleet.html');
menus[5].addItem('&#1587;&#1610;&#1575;&#1587;&#1577; &#1575;&#1604;&#1582;&#1589;&#1608;&#1589;&#1610;&#1577;', null,'/global/ar/privacy-policy.html');
menus[5].writeMenu();


//THE EXPERIENCE > ON BOARD  
menus[6]=new menu();
menus[6].addItem('&#1575;&#1604;&#1583;&#1585;&#1580;&#1577; &#1575;&#1604;&#1571;&#1608;&#1604;&#1609;',null,'/global/ar/first-class-ar.html');
menus[6].addItem('&#1583;&#1585;&#1580;&#1577; &#1585;&#1580;&#1575;&#1604; &#1575;&#1604;&#1571;&#1593;&#1605;&#1575;&#1604;',null,'/global/ar/business-class-ar.html');
menus[6].addItem('&#1575;&#1604;&#1583;&#1585;&#1580;&#1577; &#1575;&#1604;&#1587;&#1610;&#1575;&#1581;&#1610;&#1577;',null,'/global/ar/economy-class-ar.html');
menus[6].addItem('&#1575;&#1604;&#1605;&#1571;&#1603;&#1608;&#1604;&#1575;&#1578;',null,'/global/ar/cuisine-ar.html');
menus[6].addItem('&#1608;&#1580;&#1576;&#1575;&#1578; &#1582;&#1575;&#1589;&#1577; &#1576;&#1575;&#1604;&#1581;&#1605;&#1610;&#1577;',null,'/global/ar/specialdiet-ar.html');
menus[6].addItem('&#1575;&#1604;&#1578;&#1585;&#1601;&#1610;&#1607;',null,'/global/ar/entertainment-ar.html');
menus[6].addItem('&#1575;&#1604;&#1587;&#1608;&#1602; &#1575;&#1604;&#1581;&#1585;&#1577;',null,'/global/ar/dutyfree-ar.html');
menus[6].addItem('&#1587;&#1575;&#1601;&#1585; &#1580;&#1608;&#1575;&#1611;&#1548; &#1608;&#1571;&#1606;&#1578; &#1601;&#1610; &#1603;&#1575;&#1605;&#1604; &#1575;&#1604;&#1589;&#1581;&#1577;   &#1608;&#1575;&#1604;&#1604;&#1610;&#1575;&#1602;&#1577;',null,'/global/ar/flyhealthy-ar.html');
menus[6].writeMenu();

//TRAVEL ALERTS
menus[7]=new menu();
menus[7].addItem('&#1575;&#1606;&#1601;&#1604;&#1608;&#1606;&#1586;&#1575; &#1575;&#1604;&#1582;&#1606;&#1575;&#1586;&#1610;&#1585; &#1573;&#1610;&#1607; (&#1573;&#1578;&#1588; 1 &#1573;&#1606;1)',null,'/global/ar/travel-alert.html');
menus[7].writeMenu();

//Align the menus tab
menus[1].align='right';
menus[2].align='right';
menus[3].align='right';
menus[4].align='right';
menus[5].align='right';
menus[6].align='left';
menus[7].align='left';