// JavaScript Document
// Mohanad .I atwan
// 28/05/09


//------ main menu configration -----------------
var shhidsunmenu;

var msg;
var sssubbb="";
function showSubMenufuncct(msg){	/*  alert(msg);
	 document.getElementById('submenus2').innerHTML = "aaaaaa";
	 aa = document.getElementById('submenus2')

	 <table cellpadding=0 cellspacing=0 border=1 width=100%><tr valign=middle height=20><td>
     <?php
       $xx =0;
   $mlinkselmidsub = mysql_Query('select * from tablinks where catlinks=1 and linkparent=0 and elinkname='msg' order by linkid asc');
   $rooww = mysql_fetch_array($mlinkselmidsub);
                //echo $rooww['linkid'];
   $linkselmidsub = mysql_Query('select * from tablinks where catlinks=1 and linkparent='$rooww['linkid']' order by linkid asc');
        $lineee = mysql_num_rows($linkselmidsub);
    while($lrowmidsub = mysql_fetch_array($linkselmidsub)){

   $xx++; ?>

   <td class='subMenuStyle' onmouseover='style.fontWeight = 'bold'' onmouseout='style.fontWeight = 'normal'' ><?php echo $lrowmidsub['elinkname']; ?></td>

   <?php if($xx < $lineee){ ?>
   <td width='15' align='middle' class='subMenuStyle' style='background-repeat:no-repeat'><img src='images/subMenuSeberater_36.gif'><br></td>
   <?php   }   //if
   }//while
	 ?>
	</d></tr></table>";

	";
	*/
    // submenus

}

function showSubMenuLevel1(tab)
{	//alert(tab);
	shhidsunmenu = document.getElementById('shsubmenu').value;
	//alert(shhidsunmenu);
	if(document.getElementById('shsubmenu').value !="")
	document.getElementById(shhidsunmenu).style.display ="none";
document.getElementById(tab).style.display ="block";
document.getElementById('shsubmenu').value=tab;
}

function showSubMenuLevel2(tab)
{
	//alert(tab);
	//shhidsunmenu = document.getElementById('shsubmenu').value;
	//alert(shhidsunmenu);
	//if(document.getElementById('shsubmenu').value !="")
//	document.getElementById(shhidsunmenu).style.display ="none";
document.getElementById(tab).style.display ="block";
//document.getElementById('shsubmenu').value=tab;
}


function hideSubMenuLevel1(tab)
{

   hideSubMenuLevel2()
   document.getElementById(tab).style.display ="none";

   /*

var subMenuLeval1 = new Array();
subMenuLeval1[0] = "About Us";  // aboutUsSubMenu
subMenuLeval1[1] = "investmentsUsSubMenu";
subMenuLeval1[2] = "investorsCornerSub";
subMenuLeval1[3] = "employeeCorner";


  for(i=0;i<=3;i++)
  {
  document.getElementById(subMenuLeval1[i]).style.display ="none";
  }

  */

}



function hideSubMenuLevel2()
{
var subMenuLeval1 = new Array();
subMenuLeval1[0] = "Manufacturing";      // investmentManfacSiniora
subMenuLeval1[1] = "Distribution"; // investmentDistribution
subMenuLeval1[2] = "investmentServSky";
subMenuLeval1[3] = "investmentOtherInvest";
subMenuLeval1[4] = "investCornFacts";
subMenuLeval1[5] = "interactSection";


  for(i=0;i<=5;i++)
  {
  document.getElementById(subMenuLeval1[i]).style.display ="none";
  }
}


//------------------------------------------------------------
function createCookie(name,value,days)
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}



//------------------------------------------------------------
function getCookie ( cookieName ){
	var results = document.cookie.match ( cookieName + '=(.*?)(;|$)' );
	if ( results )
			return ( unescape ( results[1] ) );
		else
			return null;
}
//////End Function

//---------------- Comunication between the flash menu and the normal menu ---------------
function getFlashMovieObject(movieName)
{
  if (window.document[movieName])
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName];
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function recieveNAPCO(){
	var flash=getFlashMovieObject("flash");
	flash.sendNAPCO();
	}

	function recieveSky(){
	var flash2=getFlashMovieObject("flash");
	flash2.sendSky();
	}

	function recieveSiniora(){
	var flash3=getFlashMovieObject("flash");
	flash3.sendSiniora();
	}

	function recieveUnipal(){
	var flash4=getFlashMovieObject("flash");
	flash4.sendUnipal();
	}
	function recieveHyundai(){
	var flash5=getFlashMovieObject("flash");
	flash5.sendHyundai();
	}

	function recieveMSS(){
	var flash6=getFlashMovieObject("flash");
	flash6.sendMSS();
	}

	function recieveStorage(){
	var flash7=getFlashMovieObject("flash");
	flash7.sendStorage();
	}

	function recieveElectricity(){
	var flash8=getFlashMovieObject("flash");
	flash8.sendElectricity();
	}

	function recievePlaza(){
	var flash9=getFlashMovieObject("flash");
	flash9.sendPlaza();
	}



//==================================================================
//==================== set and get languge =========================
//==================================================================
function testing()
{
	var whatLang = getCookie("langCook");//pass the cookie name to get
	var eNinitials = "en";

var queruStr = document.location.search.substring(1);

   if((queruStr.search(/language=/i) == -1) && (whatLang==null))
	{
	window.open ("Index.php?language="+ setLangEN() ,"_self");
    }else
    {
	alert("english");
    document.getElementById("headerHolder").innerHTML='<?php include("header.php"); ?>';
    }
}



//==================================================================


function checkUrlAndCook()
{
    var queruStr = document.location.search.substring(1);

    var whatLang = getCookie("langCook");//pass the cookie name to get
	var eNinitials = "en";

	//if(queruStr.search(/language=/i) == -1)

	if((whatLang=="en") && (queruStr.search(/language=/i) == -1))
	{
		window.open ("Index.php?language="+ whatLang ,"_self");
		return true;
	}else
	if((whatLang=="ar")  && (queruStr.search(/language=/i) == -1))
	{
		window.open ("Index_ar.php?language="+ whatLang ,"_self");
	    return true;
	}else
	if((whatLang==null)  && (queruStr.search(/language=/i) == -1))
	{
		//document.cookie = createCookie("langCook", eNinitials, 50);
		window.open ("Index.php?language="+ setLangEN() ,"_self");
	    return true;
	}
}


//==================================================================
function setLangEN()
{
var eNinitials = "en";
document.cookie = createCookie("langCook", eNinitials, 50);
var whatLang = getCookie("langCook");//pass the cookie name to get
	return whatLang;
}


//==================================================================
function setLangAR()
{
var eNinitials = "ar";
document.cookie = createCookie("langCook", eNinitials, 50);
var whatLang = getCookie("langCook");//pass the cookie name to get
	return whatLang;
}



function changeItToEnglish()
{
	var url = window.location;
	window.open ("Index.php" + "?language=" + setLangEN() ,"_self");
	return true;
}


function changeItToArabic()
{
	var url = window.location;
	window.open ("index_ar.php" + "?language=" + setLangAR(),"_self");
	return true;
}