﻿// JavaScript Functions for Mega e-Business Group web site. developer: Hossein Mirzapour MA
function FaNumber(num)
{//  Hossein Mirzapour MA 11 June 2003
	var op = "";
	var FaNo = new Array(10);
	for( i=0; i < FaNo.length ; ++i )
	{	
		FaNo[i] = ("0x06F"+i).toString();
	}
	for ( i = 0; i < num.length ; i++ ) 
	{
		c = num.substring( i, i+1); 
		key = c.charCodeAt(0);
		if ((key - 0x0020)>15 && (key - 0x0020)<26)
		{	
			op += String.fromCharCode(FaNo[key - 0x0030]);
		}
		else
		{// if key is not Number
			op += String.fromCharCode(( key==46 )? 47 : key);
		}
	 }
	return op;      
}
//
mnuItems = new Array("صفحه اصلی", "فناوری اطلاعات و ارتباطات", "مشاوره اقتصادی و سرمایه گذاری", "فناوری های نوین", "دربـاره ما", "English");//, "فارسی"
en_mnuItems = new Array("Home", "ICT", "Economic Consulting & Investment", "New Technologies", "About us", "فارسی");
mnuURL	 = new Array("index", "ict", "eci", "newTech", "aboutUs", "" );
ictItems = new Array("برنامه ریزی فناوری اطلاعات", "تجارت الکترونیک", "سیستم جامع اطلاعات", "خدمات شبکه و اینترنت", "ژئو ماتیک");
en_ictItems = new Array("Information Technologies", "e-Business", "Enterprise Resource Planning", "Networking & Internet", "Geomatic");//Planning of Information Technologies
ictURL   = new Array("it", "ebusiness", "erp", "comunication", "geomatic" );

//
function writeMenu(state, lang, subMnu,ictDet)
{
	mnuHTML='';
	_color="";
	if ( state==3 ) _color="_blue";
	if ( state==2 ) _color="_gray";
	if ( state==1 ) _color="_orng";
	for ( i=0; i<mnuItems.length; i++ )
	{
		img=(i==state.toString())?'menu_btn_selected'+_color+'.gif':'menu_button'+_color+'.gif';/// image
		mnuURL[mnuURL.length-1] = (lang.toUpperCase()=="FA")?"en/"+mnuURL[state]:"../"+mnuURL[state];
		if(ictDet)
		{
			mnuURL[mnuURL.length-1] = (lang.toUpperCase()=="FA")?"en/"+ictDet:"../"+ictDet;
			
		}
		if( i==2 )
		{
			for ( j=0; j<ictItems.length; j++ )
			{
				if(j==subMnu) subMnuBG="_selected_orng"; else subMnuBG=_color;
				ictItem =(lang.toUpperCase()=="EN")? en_ictItems[j]:ictItems[j];
				mnuHTML+='<tr> ';
				mnuHTML+='  <td WIDTH=170 height=20 dir="rtl" align="center" valign="bottom" background="images/subMenu'+subMnuBG+'.gif">';/// image
				mnuHTML+='	<table cellpadding="0" cellspacing="0">';
				mnuHTML+='	  <tr> ';
				mnuHTML+='		<td abbr="113" align="right" class="normText1"><a href="';
				mnuHTML+= ictURL[j] +'.html" title="' +ictItem+'">' +ictItem;
				mnuHTML+='		</a></td>';
				mnuHTML+='	  </tr>';
				mnuHTML+='	  <tr> ';
				mnuHTML+='		<td height="5"></td>';
				mnuHTML+='	  </tr>';
				mnuHTML+='	</table></td>';
				mnuHTML+='</tr>';
			}
		}
		if (lang.toUpperCase()=="EN")
		{			
			menuItem = en_mnuItems[i];
			menuTitle = en_mnuItems[i];
			if( i==2 )
			{
				menuItem = "..."+menuItem.substring(0,20);
			}
		}
		else
		{
			menuItem = mnuItems[i];
			menuTitle = mnuItems[i];
		}
		
		mnuHTML+='        <tr> ';
		mnuHTML+='          <td  WIDTH=170 height=28 background="images/'+img+'" dir="rtl" align="center" valign="bottom"> ';
		mnuHTML+='            <table cellpadding="0" cellspacing="0">';
		mnuHTML+='              <tr> ';
		mnuHTML+='                <td abbr="113" align="right" class="boldText"><a href="';
		mnuHTML+= mnuURL[i]+'.html" title="'+menuTitle+'">';
		mnuHTML+= menuItem+'</a></td>';
		mnuHTML+='              </tr>';
		mnuHTML+='              <tr> ';
		mnuHTML+='                <td height="5"></td>';
		mnuHTML+='              </tr>';
		mnuHTML+='            </table></td>';
		mnuHTML+='        </tr>';
	}
	document.write(mnuHTML);
}