/*
HMenu, JavaScript Menu on Html Pages, Created by: Abdo El-Howbani,
It tested on IE only.
// 2001
*/

function DoNothing()
{
 // nothing to do
}

var id=0;

function mo2(a)
{
   a.bgColor='#fee8b3'; //'#ffc8c8';
   window.clearTimeout(id);
}

function mt2(a)
{
  a.bgColor='#ffffff'; 
}

function go(u)
{
  //window.alert(u);
  if (u !="" ) window.location.href=u; 
}

function mc(u)
{
  var mdiv;
  mdiv=document.getElementById("hmenu");
  if (mdiv==null) return;  

  mdiv.innerHTML='<div style="position:absolute;cursor=hand;visibility:visible;"></div>';
  if (u !="" ) window.location.href=u;  
} 

 function HeadItem(cap)
 {
    return "<tr align='center' class='ListHead'><td>" + cap + "</td></tr>"; ;
 }

 function MenuItem(cap,lnk)
 {
    var menu_item;
    menu_item="<tr align=center onmouseover='mo2(this)' onmouseout='mt2(this)' onclick='mc(\"";
    menu_item+=lnk;
    menu_item+="\")'><td>" 
    menu_item+=cap;
    menu_item+="</td></tr>";
    return menu_item;
 }



function menu_table()
{
  return "<table dir='ltr' border='1' cellspacing='0' cellpadding='3' align='center' width='120%' class='Left' styles='font-weight:bold; color:#931b1d;' >";
}

function build_newsroom_menu()
{
  var ms="";
   ms+=menu_table();
   //ms+=HeadItem("Newsroom");
   ms+=MenuItem("Company News","/ws/en/articles/ShowArt.aspx?cmd=showlast&at=news");
   ms+=MenuItem("External News","/ws/en/articles/ShowArt.aspx?cmd=showlast&at=gnews");
   
   ms+=MenuItem("Daily Mail","/ws/en/misc/ShowDm.aspx?cmd=dm&n=30");
   ms+=MenuItem("Press Clippings","/ws/en/docs/ShowDoc.aspx?cmd=showlast&dt=prsclp");
   
   ms+=MenuItem("Publications","/ws/en/docs/ShowDoc.aspx?cmd=showlast&dt=pubs");
   ms+="</table>";
   return ms;
}
//----

function build_depts_menu()
{
   var ms="";
   var u="/ws/en/depts/MainDept.aspx?dep=";
   ms+=menu_table();
  // ms+=HeadItem("Departments");
   ms+=MenuItem("Corporate&nbsp;Affairs",u+"PR");
   ms+=MenuItem("Finance",u+"FINC");
   ms+=MenuItem("HSSE",u+"HSSE");
   ms+=MenuItem("Human Resources",u+"HR");
   ms+=MenuItem("Logistics",u+"LOGS");
   //ms+=MenuItem("Management",u+"MGMT");
   //ms+=MenuItem("Marketing",u+"MARK");
   ms+=MenuItem("Operations",u+"OPRT");
   ms+=MenuItem("Project",u+"PROJ");
   ms+=MenuItem("Security",u+"SCRT");
   ms+="</table>";
   return ms;
}
//------------
function build_PnP_menu()
{
  var ms="";
   ms+=menu_table();
   //ms+=HeadItem("Newsroom");
   ms+=MenuItem("Policies","/ws/en/docs/ShowDoc.aspx?cmd=showlast&dt=policy");
   ms+=MenuItem("Procedures","/ws/en/docs/ShowDoc.aspx?cmd=showlast&dt=proced");
   ms+="</table>";
   return ms;
}
//----
function build_menu_str(t)
{ 
   if (t=="news") return build_newsroom_menu();
   if (t=="depts") return build_depts_menu();
   if (t=="pnp") return build_PnP_menu();
   return "";
};


function GetLeft(e)
{
   if (e==null) return 0;
   return e.offsetLeft + GetLeft(e.offsetParent);
}

function GetTop(e)
{
  if (e==null) return 0;
  return e.offsetTop + GetTop(e.offsetParent);
}

function ShowHmenu(o,t)
{
   //window.alert(t);
   var mdiv;
   var par;
   mdiv=document.getElementById("hmenu"); 
   par=document.getElementById(o); 
   if (mdiv==null) return;
   if (par==null) return;
   
   var x=1,y=1,s,width=100,height=100;
   x=GetLeft(par) + par.offsetWidth + 1;
   y=GetTop(par);

  
     
   s='<div id=div2 align="center" style="position:absolute;cursor:hand; z-index:99;';
   s=s+ 'top:' + y+ '; left:'+ x +'; width:'+width+'px; height:'+height+'px;';
   s=s+ 'visibility:visible;  background-color:"#ff00ff" onmouseleave="mc(\'\')">';
   s+=build_menu_str(t);
   s+='</div>';
   mdiv.innerHTML=s;
   
   window.clearInterval(id);
   id=window.setTimeout("mc('');",2000);   
}
