//IRNA MENU              //
//LAST UPDATE:2001-01-05//
function mainMenu(name,caption,x,y,width,bColor,fColor)
	{
	this.name=name;
	this.caption=caption;
	this.x=x;
	this.y=y;
	this.width=width;
	this.bColor=bColor;
	this.fColor=fColor;
	this.items= new Array;
	this.activeSubMenu=0;
	this.active=false;
	this.addItem=mainMenuAddItem;
	this.showMenu=mainMenuShow;
	}
//------------------------
function mainMenuAddItem(item)
	{
	//this.items.push(item);
	this.items[this.items.length]=item;
	this.items[this.items.length -1].init(this.x,this.y,this.width,this.bColor,this.fColor);
	}
//-----------------------
function mainMenuShow()
	{
	if(document.all){
		this.items[0].subMenuLayer.style.pixelTop = this.y;
		for(n=1;n<this.items.length;n++){
			this.items[n].subMenuLayer.style.pixelTop = this.items[n-1].subMenuLayer.style.pixelTop + this.items[n-1].subMenuLayer.style.pixelHeight;
			}
		}
	else{
		this.items[0].subMenuLayer.top=this.y;
		for(n=1;n<this.items.length;n++){
			this.items[n].subMenuLayer.top=this.items[n-1].subMenuLayer.top + this.items[n-1].subMenuLayer.clip.height;
			}
		}
	}
//==============================
function subMenu(index,name,caption)
	{
	this.index=index;
	this.name=name;
	this.caption=caption;
	this.height=0;
	this.subItems = new Array;
	this.status = "hide";
	this.addItem = subMenuAddItem;
	this.subMenuLayer = null;
	this.init=subMenuInit;
	this.showItems=subMenuShowItems;
	this.hideItems=subMenuHideItems;
	}
//--------------------
function subMenuAddItem(item)
	{
	//this.subItems.push(item);
	this.subItems[this.subItems.length]=item;
	}
//--------------------
function subMenuInit(_x,_y,_width,_bColor,_fColor)
	{
	str='';
	str+='<table border="0" width=' + _width + ' cellspacing="0" cellpadding="0" bgcolor=' + _bColor + '> \n <tr><td width="100%" colspan="3"><img border="0" src="/en/images/sep-menu.gif" width='+ _width + ' height="1"></td></tr> \n <tr><td  align="center" width="14"><img border="0" src="/en/images/blank-men.gif" name='+this.name+'></td> \n <td width="110" colspan="2"><b><a href="#" onClick="menuClick('+ this.index +');return false;"><font color='+_fColor+' size="2" face="Arial">'+this.caption+'</font></a></b></td></tr>';
	if(this.subItems.length > 0){
		for(m=0;m<this.subItems.length;m++){
			str+='<tr><td width="14">&nbsp;</td><td align="center" width="14"><img border="0" src="/en/images/blank-men.gif" name='+this.subItems[m].name+'></td> \n<td width="96"><a href='+this.subItems[m].url+'><font color='+_fColor+' size="2" face="Arial">'+this.subItems[m].caption+'</font></a></td></tr>';
			}
		}
	str+='</table>';
	
	if(document.all){
		strDiv='';
		strDiv='<div id='+ this.name +' style="position: absolute; top: '+ _y +'; left: '+ _x +'; width: '+ _width +'; background-color: '+ _bColor +'">';
		strDiv+=str;
		strDiv+='</div>';
		document.body.insertAdjacentHTML("beforeEnd",strDiv);
		this.subMenuLayer = document.all(this.name)[0];
		this.subMenuLayer.style.pixelWidth= this.subMenuLayer.offsetWidth;
		this.subMenuLayer.style.pixelHeight= this.subMenuLayer.offsetHeight;
		this.height = this.subMenuLayer.style.pixelHeight;
		this.subMenuLayer.style.posHeight=20;
		this.subMenuLayer.style.clip = "rect(0 124 20 0)";
		}
	else{
		this.subMenuLayer = new Layer(_width);
		this.subMenuLayer.name=this.name;
		this.subMenuLayer.zIndex=this.index;
		this.subMenuLayer.top=_y;
		this.subMenuLayer.left=_x;
		this.subMenuLayer.bgColor=_bColor;
		this.subMenuLayer.document.open();
		this.subMenuLayer.document.write(str);
		this.subMenuLayer.document.close();
		this.subMenuLayer.visibility="show";
		this.status="hide";
		this.height = this.subMenuLayer.clip.height;
		this.subMenuLayer.clip.height=20;
		}
	}
//--------------------
function subMenuShowItems()
	{
	if(document.all){
		this.subMenuLayer.style.posHeight=this.height;
		eval('this.subMenuLayer.style.clip = "rect(0 124 '+ this.height +' 0)";');
		}
	else{
		this.subMenuLayer.clip.height = this.height;
		}
	this.status ="show";
	}
//--------------------
function subMenuHideItems()
	{
	if(document.all){
		this.subMenuLayer.style.posHeight=20;
		this.subMenuLayer.style.clip = "rect(0 124 20 0)";
		}
	else{
		this.subMenuLayer.clip.height = 20;
		}
	this.status ="hide";
	}
//============================
function subItem(name,caption,url)
	{
	this.name=name;
	this.caption=caption;
	this.url=url;
	}
//================================
function menuClick(item)
	{
	if(eMenu.items[item].subItems.length <2){
		document.location=eMenu.items[item].subItems[0].url;
		}
	else
		{
		if((eMenu.activeSubMenu >= 0)&&(eMenu.items[eMenu.activeSubMenu].status == "show")&&(eMenu.activeSubMenu != item)){//if one item is active item and its show
			eMenu.items[eMenu.activeSubMenu].hideItems();
			}
		if(eMenu.items[item].status == "show"){
			eMenu.items[item].hideItems();
			}
		else{
			eMenu.items[item].showItems();
			}
		eMenu.activeSubMenu = item;
		eMenu.showMenu();
		}
	}
//------------------------
function activeSubItem(item,subItem)
	{
	if(document.all){
		eMenu.items[item].subMenuLayer.all[subItem].src = "/en/images/arrow-menu.gif";
		}
	else{
		eMenu.items[item].subMenuLayer.document[subItem].src="/en/images/arrow-menu.gif";
		}
	}
//------------------------
var xOfMenu=8;
var yOfMenu=133;
var sOfMenu=20;
var wOfMenu=125;
var	eMenu = new  mainMenu("IRNAeMENU","main menu",xOfMenu,yOfMenu,wOfMenu,"#E2E2E2","#003366");

function init_menu()
	{
	var subMenuHome = new subMenu(0,"home","Home");
	subMenuHome.addItem(new subItem("home1","Home","/en/index.shtml"));
	eMenu.addItem(subMenuHome);

	var subMenuNews = new subMenu(1,"news","News");
	subMenuNews.addItem(new subItem("news1","HeadLines","/en/head/index.shtml"));
	subMenuNews.addItem(new subItem("news2","General News","/en/general/index.shtml"));
	subMenuNews.addItem(new subItem("news3","World","/en/world/index.shtml"));
	subMenuNews.addItem(new subItem("news4","Politics","/en/politic/index.shtml"));
	subMenuNews.addItem(new subItem("news5","Economy","/en/economic/index.shtml"));
	subMenuNews.addItem(new subItem("news6","Sports","/en/sport/index.shtml"));
	eMenu.addItem(subMenuNews);
	
//	var subMenuNewsBank = new subMenu(2,"bank","News Bank");
//	subMenuNewsBank.addItem(new subItem("bank1","News Bank","http://news.irna.com"));
//	eMenu.addItem(subMenuNewsBank);
	
	var subMenuPress = new subMenu(2,"press","Local Press");
	subMenuPress.addItem(new subItem("press1","Iran","/en/press/iran.shtml"));
	subMenuPress.addItem(new subItem("press2","Iran-e Varzeshi","/en/press/varzeshi.shtml"));
	subMenuPress.addItem(new subItem("press3","Iran-e Javan","/en/press/javan.shtml"));
	subMenuPress.addItem(new subItem("press4","Iran Daily","/en/press/daily.shtml"));
	subMenuPress.addItem(new subItem("press5","Al Vefagh","/en/press/vefagh.shtml"));
	subMenuPress.addItem(new subItem("press6","Iran-e Azin","/en/press/azin.shtml"));
	subMenuPress.addItem(new subItem("press7","Other Press","/en/press/other.shtml"));
	subMenuPress.addItem(new subItem("press8","Quick View","/en/press/qview.shtml"));
	eMenu.addItem(subMenuPress);

	var subMenuPhotos = new subMenu(3,"photos","Photos");
	subMenuPhotos.addItem(new subItem("Photos1","Photos","/en/photo/index.shtml"));
	eMenu.addItem(subMenuPhotos);

	var subMenuOccasions = new subMenu(4,"occasions","Occasions");
	subMenuOccasions.addItem(new subItem("occasions1","News Events","/en/occasion/news.shtml"));
	subMenuOccasions.addItem(new subItem("occasions2","National Events","/en/occasion/national.shtml"));
	subMenuOccasions.addItem(new subItem("occasions3","Religious Events","/en/occasion/religious.shtml"));
	//subMenuOccasions.addItem(new subItem("occasions4","Calendar","/en/occasion/calendar.shtml"));
	eMenu.addItem(subMenuOccasions);

	var subMenuMedia = new subMenu(5,"RadioTV","Radio & TV");
	subMenuMedia.addItem(new subItem("RadioTV1","On-Line","/en/radio/radiotv.shtml"));
	eMenu.addItem(subMenuMedia);

        var subMenuMail = new subMenu(6,"OANANews","OANA News");
	subMenuMail.addItem(new subItem("OANANEWS1","OANANEWS","http://www.oananews.com"));
	eMenu.addItem(subMenuMail);

        var subMenuMail = new subMenu(7,"E-mail","E-mail");
	subMenuMail.addItem(new subItem("E-mail1","E-mail","mailto:irna@irna.com"));
	eMenu.addItem(subMenuMail);


		
	window.onresize=reloadMenu;
	}
//----------------------
function reloadMenu()
	{
	if(document.all){
		setTimeout('window.location.href = window.location.href',2000);
		//alert("ie is resize");
		}
	else{ 
		window.location.href=window.location.href;
		//alert("ns is resize");
		}
	}
//------------------------
  

