	//return to defualt
	var counter = 0;
	timeDisplay = null;
	function getTheLinks( lang, IndexOfLinks, obj , flag ) {
		if( !document.getElementById('subHeaderDis') ) {
			return;
		}
		mainLenght = 10
		subLength  = 15;
		//remove the classes from sub and main tabs
		for( i= 0 ; i < mainLenght ; i++ ) {
			if( !document.getElementById('main'+i) )
				break;
			document.getElementById('main'+i).className  = '';	
		}
		
		//time the header showing
		/*
		if( flag == '1' ) {
			clearTimeout( timeDisplay );
			document.getElementById( 'tabsCountForHead' ).value = 0;
			timeTest();
		}
		*/		
		//make the selected tab white
		obj.className  = 'mbs-portal-book-root-menu-item-active';

		for( i= 0 ; i < subLength ; i++ ) {
			if( !document.getElementById('sub'+i) )
				break;
			document.getElementById('sub'+i).className  = '';	
		}
				
		indexForText = 1;
		if( lang == 'En' ) {
			indexForText = 0;
		}
		LinksToDisplay = enLinks( IndexOfLinks );
		linksLength = LinksToDisplay.length;
		subHeaderHtml = '';
		for( i=0 ; i<linksLength; i++ ) {
			subHeaderHtml += '<li id="sub'+i+'"><a href="'+LinksToDisplay[i][2]+'.php?Lang='+lang+'">';
			subHeaderHtml += LinksToDisplay[i][indexForText]+'</a></li>';
		}

		document.getElementById('subHeaderDis').innerHTML = subHeaderHtml;
	}
	

	function enLinks( IndexOfLinks ) {
		//Reseller user
				if( document.getElementById('resRegUser') && 
				document.getElementById( 'resRegUser' ).value == 1 ) {
					Links = new Array();
					Links[0] = new Array(); 
					Links[0][0] = new Array('My Profit','أرباحي','resellerProfile');
					return Links[0] ;
				}
				Links = new Array();
				Links[0] = new Array(); 
				Links[1] = new Array(); 
				Links[2] = new Array(); 
				Links[3] = new Array(); 
				Links[4] = new Array(); 
				Links[5] = new Array(); 
				Links[7] = new Array(); 
				Links[8] = new Array();
				ipCountry = '';
				userCountry = '';
				if( document.getElementById('userIpCountryForCheck') && document.getElementById('userIpCountryForCheck') ) {
					ipCountry = document.getElementById('userIpCountryForCheck').value;
					userCountry = document.getElementById('userCountryForCheck').value;
				}
				/*
				if( IndexOfLinks == 4 ) {
					if ( 	(userCountry == "JO" && ipCountry == "JO") ||
							(userCountry =="MA" && ipCountry == "MA" ) ||
							(userCountry == "DZ" && ipCountry == "DZ" ) ||
							(userCountry =="IQ" && ipCountry == "IQ" )
							){
								IndexOfLinks	= 7;
							}
				}
				*/
				/*
				if( userCountry=="SA" && ipCountry == "SA"  ) {
					IndexOfLinks	= 8;	
				}
				*/
				Links[0][0] = new Array('My home','صفحتي','landing')
				Links[0][1] = new Array('My Profit','أرباحي','resellerProfile')
				Links[0][2] = new Array('About Me','بياناتي الشخصية','my_profile')
				Links[0][3] = new Array('Style me<sup><img alt="" src="http://i1.makcdn.com/bentelhalal/bentelhalal/Images/new_en.gif"/></sup>','ستايلي<sup><img alt="" src="http://i1.makcdn.com/bentelhalal/bentelhalal/Images/new_ar.gif"/></sup>','style_landing')
				Links[0][4] = new Array('My account','حسابي','my_account')
				Links[0][5] = new Array('My mobile','موبايلي','my_mobile')
				Links[0][6] = new Array('Invite friends','ادعو اصدقائك','invite_friends')	
				Links[0][7] = new Array('Photo album<sup><img alt="" src="http://i1.makcdn.com/bentelhalal/bentelhalal/Images/new_en.gif"/></sup>','ألبوم الصور<sup><img alt="" src="http://i1.makcdn.com/bentelhalal/bentelhalal/Images/new_ar.gif"/></sup>','photo_album')
				
				Links[1][0] = new Array('My search','بحثي','search_quick')  
				Links[1][1] = new Array('Who is online?','من بالموقع؟','list_online') 
				Links[1][2] = new Array('Who Visited My Profile?','من زار صفحتي؟','list_visited')  
				Links[1][3] = new Array('Important Visits','زيارات مهمة','vip_visits')  
				Links[1][4] = new Array('Newest Members','أعضاء جدد','list_new') 
				Links[1][5] = new Array('Search By Tags','البحث بالسمات','more_tags') 
				Links[1][6] = new Array('Search By Country','البحث حسب الدولة','searchByCountry') 

				
				Links[2][0] = new Array('Inbox','البريد الوارد','inbox')
				Links[2][1] = new Array('Outbox','البريدالصادر','outbox')
				Links[2][2] = new Array('Voice Messages','رسائل صوتية','inbox_voice')
				//Links[2][3] = new Array('Archieved messages','رسائل مؤرشفة','inboxArch')
				Links[2][3] = new Array('Users Invitations','دعوات إعجاب','freeCards')
				Links[2][4] = new Array('Sent Invitations','دعوات إعجاب مرسلة','cardsSent')
				Links[2][5] = new Array('Chat Invitations','دعوات دردشة','messengerInvitations')

				Links[3][0] = new Array('Matchmaker','نتائج الخاطبة','my_match_results')
				Links[3][1] = new Array('Who interested in me?','من يهتم بي؟','list_inter')
				Links[3][2] = new Array('My hot list','قائمة الاهتمام','list_hot')
				Links[3][3] = new Array('Ignore list','قائمة التجاهل','list_ignore')
				Links[3][4] = new Array('New matches','أعضاء جدد يبحثون عنك','NewMatches')
				Links[3][5] = new Array('Banned users','الممنوعون من دخول الموقع','list_banned') 

				Links[4][0] = new Array('My membership','عضويتي','payment')
				Links[4][1] = new Array('Special profile','ملف متميز','specialProfile')
				if( userCountry != "SY" ) {				
					Links[4][2] = new Array('Special Offer','عرض خاص','specialOffer')
				}
								if( IndexOfLinks == 4 ) {
					if ( 	(userCountry == "JO" /*&& ipCountry == "JO"*/) ||
							(userCountry =="MA" /*&& ipCountry == "MA"*/ ) ||
							(userCountry == "DZ" /*&& ipCountry == "DZ"*/ ) ||
							(userCountry =="IQ" /*&& ipCountry == "IQ"*/ )
							){
								Links[4][3] = new Array('Mobile Payment','الدفع عن طريق الموبايل','mobileServiceSelect');
							}
				}
				//remove later DZ
				if( ipCountry == "DZ" ) {
					delete Links[4];
					Links[4] = new Array(); 
					Links[4][0] = new Array('Mobile Payment','الدفع عن طريق الموبايل','mobileService');
				}
				/*
				Links[4][1] = new Array('CashU cards','بطاقات كاش يو','payment_cashu')
				Links[4][2] = new Array('Bentelhalal cards','بطاقات بنت الحلال','payment_bentelhalal')
				Links[4][3] = new Array('Western union','وسترن يونيون','payment_west')
				Links[4][4] = new Array('Money transfer','تحويل بنكي','payment_rest')
				Links[4][5] = new Array('Credit Card','البطاقات الإئتمانية','payment_creditcard')
				*/

				//display wallie payment if the user from eourop
				if( checkIpEour( userCountry ) ) {
					Links[4][6] = new Array('Wallie Card','بطاقات والي','payment_wallie')	
				}
				
				Links[5][0] = new Array('search for video', 'بحث عن الفيديو', 'search_photo_video_club');
				Links[5][1] = new Array('record video', 'تسجيل الفيديو', 'my_video');
				Links[5][2] = new Array('Display Your video', 'استعراض الفيديو', 'displayUserVideo');
				
				Links[6] = new Array();
				/*removed the mobile from tab
				Links[7][0] = new Array('My membership','عضويتي','payment')
				Links[7][1] = new Array('Special profile','ملف متميز','specialProfile')
				Links[7][2] = new Array('Special Offer','عرض خاص','SpecialOffer')
				Links[7][3] = new Array('Mobile Service','الدفع عن طريق الموبايل','mobileService')				
				
				Links[7][0] = new Array('Membership types','انواع العضويات','payment')
				Links[7][1] = new Array('CashU cards','بطاقات كاش يو','payment_cashu')
				Links[7][2] = new Array('Bentelhalal cards','بطاقات بنت الحلال','payment_bentelhalal')
				Links[7][3] = new Array('Credit Card','البطاقات الإئتمانية','payment_creditcard')
				Links[7][4] = new Array('Mobile Service','الدفع عن طريق الموبايل','mobileService')

				Links[8][0] = new Array('Membership types','انواع العضويات','payment')
				Links[8][1] = new Array('CashU cards','بطاقات كاش يو','payment_cashu')
				Links[8][2] = new Array('Bentelhalal cards','بطاقات بنت الحلال','payment_bentelhalal')
				Links[8][3] = new Array('Money transfer','تحويل بنكي','payment_saudi')
				Links[8][4] = new Array('Credit Card','البطاقات الإئتمانية','payment_creditcard')
				Links[8][5] = new Array('Mobile Service','الدفع عن طريق الموبايل','mobileService')
				*/
				
				return Links[IndexOfLinks];
	}
	//timer
	function timeTest( flag ) {
		//increment the counter
		tabCount = document.getElementById( 'tabsCountForHead' );
		//if called new time the counter must be Zero again
		if( flag == '1' ) {
			tabCount.value = 0;	
		}		
		tabCountValue = tabCount.value;
		tabCount.value = parseInt( tabCountValue ) + 1;  
		if( tabCount.value < 15 ) {
			var timeDisplay = setTimeout( "timeTest( '0' )", 1000);
		} else {
			clearTimeout( timeDisplay );
			mainIndex = document.getElementById('mainSeletedItem');
			IndexOfLinks = 0;
			if( mainIndex ) {
				IndexOfLinks = mainIndex.value;
			}
			obj = document.getElementById('main'+IndexOfLinks);
			if( obj && obj.className != 'mbs-portal-book-root-menu-item-active' ) {
				lang = document.getElementById('HeaderLang').value; 
				getTheLinks( lang, IndexOfLinks, obj , '2' );	
			}
			//get the sub title higlighted and solve the problem when the sub header is empty
			subIndex = 0;
			subIndexObj = document.getElementById('subHeaderSeleted');
			if( subIndexObj ) {
				subIndex = subIndexObj.value;
			}
			SubObj = document.getElementById('sub'+subIndex)
			if( SubObj && SubObj.className != 'mbs-portal-book-sub-menu-item-active' ) {
				SubObj.className  = 'mbs-portal-book-sub-menu-item-active';
			}
		}
	}
	
	//check if the user id from eourp
	function checkIpEour( country ) {
		europCountries = new Array(
			'AU','DK','IE','LV','LT','SE','GB',
			'AT','CZ','EE','FI','FR','HU','ID',
			'IT','MY','AN','NO','PL','RO','RU',
			'CS','CH','TH','UA');
		loopCount = europCountries.length	
		stat = false;
		for ( i = 0 ; i < loopCount; i++ ) {
			if( europCountries[i] == country ) {
				stat = true;	
			}
		}
		return stat;
	}
	
	                                 
