function getSiteUserId()
{
	var name = '', userId, cookies, i, a = document.cookie;
	a = unescape(a);
	cookies = a.split(";");
	for (i=0;i<cookies.length;i++)
	{
		if (cookies[i].indexOf('userId') != -1)
		{
			userId = cookies[i];
			// remove the cookie key, and keep/use the value(s)
			a = userId.split("=");
			values = a[1].split("|");
			for (i=0;i<values.length;i++)
			{
				if (values[i].indexOf('name') != -1)
				{
					a = values[i].split("?");
					name = a[1];
				}
			}
			break;
		}
	
	}
	return name;
}

function siteLoginMessage()
{
	var message;
	var name;
	
	// check if user accepts cookies
	var test;
	document.cookie = 'WM_acceptsCookies=yes; path=/';
	test = getCookieVal('WM_acceptsCookies');
	if (test != 'yes')
	{
		document.getElementById('login').innerHTML = '<span class=content1><img  height=14 src=/images/icon_caution.gif>&nbsp;<font color=red>Please set your browser to accept cookies to sign in</font>&nbsp;</span>';
		return;
	}
	plugTopSignin();
}

function getCookieVal (cookieName) {
    // By A. Solheim 1999
    var _allCookies = self.document.cookie;
    var _pos = _allCookies.indexOf(cookieName + "=");

    // Set the variable _value to default value that you
    // want to be returned if the cookie with the given
    // name isn't found
    var _value = "";

    if (_pos !=-1) {
        var _start = _pos + cookieName.length+1;
        var _end = _allCookies.indexOf(";", _start);
        if (_end == -1) _end = _allCookies.length;
        _value = _allCookies.substring(_start, _end);
    }
    return _value;
}

function getSignin()
{
	var resp = makeHttpRequest("http://www.jannah.com/tpl/signinPluginUnicode.html");
	return resp;
}

function plugSignin()
{
	var userName = getSiteUserId();
	if (userName == '')
	{
		var resp = unescape(getSignin());
		document.write(resp);
	}
	return;
}

function getTopSignin()
{
	var resp = makeHttpRequest("http://www.jannah.com/site/topSigninPlugin.html");
	return resp;
}

function plugTopSignin()
{
	var userName = getSiteUserId();
	if (userName == '')
	{
		
		var resp = unescape(getTopSignin());
		//document.write(resp);
		message = resp;
	}
	else
	{
		message = '<font color=white><span class=topsignin>Welcome <b>' + userName + '</b> (<a href=http://www.jannah.com/cgi-bin/site/logout.pl>sign out</a>)  not ' + userName + ' ? <a href=http://www.jannah.com/site/login.html>sign in</a></span></font>';
	}
	//message='test';
	document.getElementById('login').innerHTML = message;
	document.getElementById('login').style.cssFloat="right";
	return;
}

function expandCollapse(obj,img,override)
{
	// override (optional): the display value to use to override the toggle - values exp, col
	var el = document.getElementById(obj);
	var icon = document.getElementById(img);
	
	if (undefined == override)
	{
		if ( el.style.display != 'none' )
		{
			el.style.display = 'none';
			(undefined == img) ? undefined : icon.src ="/images/icon_expand.gif";
		}
		else
		{
			el.style.display = '';
			(undefined == img) ? undefined : icon.src ="/images/icon_collapse.gif";
		}
	}
	else
	{
		if (override == 'exp')
		{
			el.style.display = '';
			(undefined == img) ? undefined : icon.src ="/images/icon_collapse.gif";
		}
		else
		{
			el.style.display = 'none';
			(undefined == img) ? undefined : icon.src ="/images/icon_expand.gif";			
		}
	}
}
function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;
   var resp;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   resp = http_request.responseXML;
				   //eval(callback_function + '(http_request.responseXML)');
				   
               } else {
                   resp = http_request.responseText;
				   //alert(resp);
				   //eval(callback_function + '(http_request.responseText)');
				   
               }
           } else {
               alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   
   http_request.open('GET', url, false);
   http_request.send(null);
   return (http_request.responseText);
}

// start: cmg.js consolidation starts here

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function getCookieVal (cookieName) {
    // By A. Solheim 1999
    var _allCookies = self.document.cookie;
    var _pos = _allCookies.indexOf(cookieName + "=");

    // Set the variable _value to default value that you
    // want to be returned if the cookie with the given
    // name isn't found
    var _value = "";

    if (_pos !=-1) {
        var _start = _pos + cookieName.length+1;
        var _end = _allCookies.indexOf(";", _start);
        if (_end == -1) _end = _allCookies.length;
        _value = _allCookies.substring(_start, _end);
    }
    return _value;
}


// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

// end: cmg.js consolidation ends here


// start consolidation of p7MenuMgmt.js
// new - for usage with p7pmm
function selectMenu()
{
	// decides which lang of menu to pick upon initial load of page
	var lang,resp,url;
	lang = getCookie('l');
	document.getElementById('jmenu').innerHTML = getMenu(lang);
	P7_initPM(1,3,0,-20,10);
}

function updateMenu(lang)
{
	// to update the p7 nav menu to language selected by user
	var lang,resp,trek;
	if (!lang) { lang= 'e';};
	// first, set cookie
	setLang(lang);
	// second, update menu
	document.getElementById('jmenu').innerHTML = getMenu(lang);
	P7_initPM(1,3,0,-20,10);
}

function getMenu(lang)
{
	var lang,resp;
	url='http://www.jannah.com/p7menus/';
	switch(lang)
	{
			case 'e':
				resp = makeHttpRequest(url+'english.html');
				break;
			case 'a':
				resp = makeHttpRequest(url+'arabic.html');
				break;
			case 'f':
				resp = makeHttpRequest(url+'french.html');
				break;
			default:
				resp = makeHttpRequest(url+'english.html');
	}
	return resp;
}

function setLang(l)
{
	var l;
	var trek = new Date();
	fixDate(trek);
	//trek.setYear(2037);
	trek.setTime(trek.getTime() + 3650 * 24 * 60 * 60 * 1000);
	setCookie('l',l,trek,'/','.jannah.com');
	//alert('Cookie set to: ' + l);
	//setTimeout(5000,"");
}

// end p7MenuMgmt.js consolidation

// start p7popmenu 3rd party js script consolidation

/* 
  ------------------------------------------------
  PopMenu Magic menu scripts
  Copyright (c) 2004-2006 Project Seven Development
  www.projectseven.com
  Version: 1.0.3
  ------------------------------------------------
*/
var p7PMp,p7PMct;
function P7_setPM(){ //v1.0.3 by PVII-www.projectseven.com
 var i,d='',h="<sty"+"le type=\"text/css\">",tA=navigator.userAgent.toLowerCase();if(window.opera){
 if(tA.indexOf("opera 5")>-1||tA.indexOf("opera 6")>-1){return;}}if(document.getElementById){
 for(i=1;i<20;i++){d+='ul ';h+="\n#p7PMnav "+d+"{position:absolute;left:-9000px;}";}
 document.write(h+"\n<"+"/sty"+"le>");}}P7_setPM();
function P7_initPM(){ //v1.0 by PVII-www.projectseven.com
 var i,g,tD,tA,tU,pp,lvl,ev,tn=navigator.userAgent.toLowerCase();if(window.opera){
 if(tn.indexOf("opera 5")>-1||tn.indexOf("opera 6")>-1){return;}}else if(!document.getElementById){return;}
 p7PMp=arguments;p7PMct=new Array;tD=document.getElementById('p7PMnav');if(tD){tA=tD.getElementsByTagName('A');
 for(i=0;i<tA.length;i++){tA[i].p7PMcl=p7PMct.length;p7PMct[p7PMct.length]=tA[i];g=tA[i].parentNode.getElementsByTagName("UL");
 tA[i].p7PMsub=(g&&g[0])?g[0]:false;ev=tA[i].getAttribute("onmouseover");if(!ev||ev=='undefined'){tA[i].onmouseover=function(){
 P7_PMtrig(this);};}ev=tA[i].getAttribute("onfocus");if(!ev||ev=='undefined'){tA[i].onfocus=function(){P7_PMtrig(this);};}
 if(tA[i].p7PMsub){pp=tA[i].parentNode;lvl=0;while(pp){if(pp.tagName&&pp.tagName=="UL"){lvl++;}pp=pp.parentNode;}
 tA[i].p7PMlv=lvl;}}tD.onmouseout=P7_PMclose;P7_PMopen();}
}
function P7_PMtrig(a){ //v1.0.3 by PVII-www.projectseven.com
 var b,t;if(document.p7PMt){clearTimeout(document.p7PMt);}document.p7PMa=1;b=(a.p7PMsub)?'P7_PMshow(':'P7_PMtg(';
 t='document.p7PMt=setTimeout("'+b+a.p7PMcl+')",160)';eval (t);
}
function P7_PMshow(a,bp){ //v1.0.3 by PVII-www.projectseven.com
 var u,lv,oft,ofr,uw,uh,pp,aw,ah,adj,mR,mT,wW=0,wH,w1,w2,w3,sct,pw,lc,pwv,xx=0,yy=0,wP=true;
 var iem=(navigator.appVersion.indexOf("MSIE 5")>-1)?true:false,dce=document.documentElement,dby=document.body;document.p7PMa=1;
 if(!bp){P7_PMtg(a);}u=p7PMct[a].p7PMsub;if(u.p7pmax&&u.p7pmax==1){return;}u.p7pmax=1;lv=(p7PMp[0]==1&&p7PMct[a].p7PMlv==1)?true:false;
 p7PMct[a].className=p7PMct[a].className.replace("p7PMtrg","p7PMon");oft=parseInt(p7PMp[3]);ofr=parseInt(p7PMp[4]);
 uw=u.offsetWidth;uh=u.offsetHeight;pp=p7PMct[a];aw=pp.offsetWidth;ah=pp.offsetHeight;while(pp){xx+=(pp.offsetLeft)?pp.offsetLeft:0;
 yy+=(pp.offsetTop)?pp.offsetTop:0;if(window.opera||navigator.userAgent.indexOf("Safari")>-1){
 if(p7PMct[a].p7PMlv!=1&&pp.nodeName=="BODY"){yy-=(pp.offsetTop)?pp.offsetTop:0;}}pp=pp.offsetParent;}
 if(iem&&navigator.userAgent.indexOf("Mac")>-1){yy+=parseInt(dby.currentStyle.marginTop);}adj=parseInt((aw*ofr)/100);mR=(lv)?0:aw-adj;
 adj=parseInt((ah*oft)/100);mT=(lv)?0:(ah-adj)*-1;w3=dby.parentNode.scrollLeft;if(!w3){w3=dby.scrollLeft;}w3=(w3)?w3:0;
 if(dce&&dce.clientWidth){wW=dce.clientWidth+w3;}else if(dby){wW=dby.clientWidth+w3;}if(!wW){wW=0;wP=false;}wH=window.innerHeight;
 if(!wH){wH=dce.clientHeight;if(!wH||wH<=0){wH=dby.clientHeight;}}sct=dby.parentNode.scrollTop;if(!sct){sct=dby.scrollTop;if(!sct){
 sct=window.scrollY?window.scrollY:0;}}pw=xx+mR+uw;if(pw>wW&&wP){mR=uw*-1;mR+=10;if(lv){mR=(wW-xx)-uw;}}lc=xx+mR;if(lc<0){mR=xx*-1;}
 pw=yy+uh+ah+mT-sct;pwv=wH-pw;if(pwv<0){mT+=pwv;if(uh>wH){mT=(yy+ah-sct)*-1;}}u.style.marginLeft=mR+'px';u.style.marginTop=mT+'px';
 if(p7PMp[2]==1){if(!iem){P7_PManim(a,20);}}u.className="p7PMshow";
}
function P7_PMhide(u){ //v1.0.3 by PVII-www.projectseven.com
 var i,tt,ua;u.p7pmax=0;u.className="p7PMhide";ua=u.parentNode.firstChild;ua.className=ua.className.replace("p7PMon","p7PMtrg");
}
function P7_PMtg(a,b){ //v1.0.3 alpha by PVII-www.projectseven.com
 var i,u,tA,tU,pp;tA=p7PMct[a];pp=tA.parentNode;while(pp){if(pp.tagName=="UL"){break;}pp=pp.parentNode;}if(pp){
 tU=pp.getElementsByTagName("UL");for(i=tU.length-1;i>-1;i--){if(b!=1&&tA.p7PMsub==tU[i]){continue;}else{P7_PMhide(tU[i]);}}}
}
function P7_PMclose(evt){ //v1.0.3 by PVII-www.projectseven.com
 var pp,st,tS,m=true;evt=(evt)?evt:((event)?event:null);st=document.p7PMa;if(st!=-1){if(evt){
 tS=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;if(tS){pp=tS.parentNode;while(pp){if(pp&&pp.id&&pp.id=="p7PMnav"){m=false;
 document.p7PMa=1;break;}pp=pp.parentNode;}}if(m){document.p7PMa=-1;if(document.p7PMt){clearTimeout(document.p7PMt);}
 document.p7PMt=setTimeout("P7_PMclr()",360);}}}
}
function P7_PMclr(){ //v1.0.3 by PVII-www.projectseven.com
 var i,tU,tUU;document.p7PMa=-1;tU=document.getElementById('p7PMnav');if(tU){tUU=tU.getElementsByTagName("UL");if(tUU){
 for(i=tUU.length-1;i>-1;i--){P7_PMhide(tUU[i]);}}}
}
function P7_PManim(a,st){ //v1.0.3 by PVII-www.projectseven.com
 var g=p7PMct[a].p7PMsub,sp=30,inc=20;st=(st>=100)?100:st;g.style.fontSize=st+"%";if(st<100){st+=inc;setTimeout("P7_PManim("+a+","+st+")",sp);}
}
function P7_PMmark(){document.p7PMop=arguments;}
function P7_PMopen(){ //v1.0.3 by PVII-www.projectseven.com
 var i,x,tA,op,pp,wH,tA,aU,r1,k=-1,kk=-1,mt=new Array(1,'','');if(document.p7PMop){mt=document.p7PMop;}op=mt[0];if(op<1){return;}
 tA=document.getElementById('p7PMnav').getElementsByTagName("A");wH=window.location.href;r1=/index\.[\S]*/i;for(i=0;i<tA.length;i++){
 if(tA[i].href){aU=tA[i].href.replace(r1,'');if(op>0){if(tA[i].href==wH||aU==wH){k=i;kk=-1;break;}}if(op==2){if(tA[i].firstChild){
 if(tA[i].firstChild.nodeValue==mt[1]){kk=i;}}}if(op==3 && tA[i].href.indexOf(mt[1])>-1){kk=i;}if(op==4){for(x=1;x<mt.length;x+=2){
 if(wH.indexOf(mt[x])>-1){if(tA[i].firstChild&&tA[i].firstChild.data){if(tA[i].firstChild.data==mt[x+1]){kk=i;break;}}}}}}}k=(kk>k)?kk:k;
 if(k>-1){pp=tA[k].parentNode;while(pp){if(pp.nodeName=="LI"){pp.firstChild.className="p7PMmark"+" "+pp.firstChild.className;}
 pp=pp.parentNode;}}if(kk>-1){document.p7PMad=1;}P7_PMadma();P7_PMadmb();
}
function P7_PMadma(){ //v1.0.3 by PVII-www.projectseven.com
 var s,ss,i,j,a,g,b,c,d,t,h,tA,b,tP,r1,r2,tI,bA,aA,tB=new Array(),bC='',x=0,ur=1,mt=document.p7PMad;g=document.getElementById("p7PMnav");
 b=document.getElementById("pmmcrumb");if(g&&b){c=b.getElementsByTagName("A");if(c&&c[0]){tP=c[0].parentNode.childNodes;r1=/<a/i;r2=/\/a>/i;
 tI=c[0].parentNode.innerHTML;j=tI.search(r1);bA=tI.substring(0,j);j=tI.search(r2);aA=tI.substring(j+3);bC+=(bA)?bA:'';s=(aA)?aA:' &gt ';
 if(!c[0].id||c[0].id!="pmmcn"){if(c[0].href!=window.location.href){tB[0]=c[0];x++;ur=2;}}tA=g.getElementsByTagName("A");for(i=0;i<tA.length;i++){
 if(tA[i].className.indexOf("p7PMmark")>-1){tB[x]=tA[i];x++;}}for(i=0;i<tB.length;i++){ss=(i>0)?s:'';a=(i==tB.length-1)?0:1;
 d=(i==0&&c[0].id)?'id="'+c[0].id+'" ':' ';t=tB[i].firstChild.nodeValue;if(a==1||mt==1||x<ur){bC+=ss+'<a '+d+'hr'+'ef="'+tB[i].href+'">'+t+'</a>';
 }else{bC+=ss+t;}}if(mt==1||i<ur){ss=(i>0)?s:'';bC+=ss+document.title;}c[0].parentNode.innerHTML=bC;}}
}
function P7_PMadmb(){ //v1.0.3 by PVII-www.projectseven.com
 var h='',g,i,tA,b,m=false;g=document.getElementById("p7PMnav");b=document.getElementById("pmmnext");if(g&&b){tA=g.getElementsByTagName("A");
 for(i=tA.length-1;i>-1;i--){if(tA[i].className.indexOf("p7PMmark")>-1){m=true;break;}}if(m){if(i<tA.length-1){i++;}else{i=0;}
 while(tA[i].href==window.location.href+"#"||tA[i].href=="javascript:;"){i++;if(i>tA.length-1){
 i=0;break;}}b.href=tA[i].href;b.innerHTML=tA[i].firstChild.nodeValue;}}	
}

// p7popmenu 3rd party js script consolidation