﻿// JScript File

 var tac_pbx1,tac_pba1;/*@cc_on @*//*@if(@_jscript_version>=5)try{tac_pbx1=new ActiveXObject('msxml2.xmlhttp')}catch(e){try{tac_pbx1=new ActiveXObject('Microsoft.XMLHTTP')}catch(e){}}@else;tac_pbx1=false;tac_pba1=true;@end;@*/if(!tac_pbx1&&!tac_pba1)
{try{tac_pbx1=new XMLHttpRequest();}catch(e){}}
function tac_post(e,v)
{
    if(tac_pbx1)
    {
        tac_pbx1.open('POST', apath + 'ar/_controls/process.aspx',false);
        tac_pbx1.send('<root><tac>'+e+'</tac><tac>'+v+'</tac></root>');
        return tac_pbx1.responseText;
    }
}
function back()
{
    history.back(-1);
}
function printDoc()
{
    window.print();
}

/* send to friend */
function ebc(mode)
{
    if(document.getElementById("F1") != null)
    {
        if(mode) document.getElementById("F1").style.position = 'static';
        else document.getElementById("F1").style.position = 'relative';
    }
}
function email(obj)
{
   ebc(true); 

   var cLeft = getposOffset(document.getElementById('lnkEmail'),"left");
   var cTop = getposOffset(document.getElementById('lnkEmail'),"top");
   
   document.getElementById('dvSend').style.left = (cLeft -120) + "px";
   document.getElementById('dvSend').style.top = (cTop + 17 ) + "px";
   document.getElementById('dvSend').style.display = "block";
   
    if(document.getElementById('imgGalFlash')!=null)
   {
     document.getElementById('imgGalFlash').style.display='none';
   }
}

function eclose()
{
   ebc(false); 
   document.getElementById('dvSend').style.display = "none";
   
    if(document.getElementById('imgGalFlash')!=null)
   {
     document.getElementById('imgGalFlash').style.display='block';
   }
}

function getposOffset(what, offsettype)
{
    var totaloffset=(offsettype=="right")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null)
    {
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

/* Survey */
function Survey(id)
{
document.getElementById('ctl00_content_hidSurveyId').value = id;
__doPostBack('ctl00$content$lnkSurvey','');
}

/* --- Search start ---*/

function cSearch()
{
    if(document.getElementById(tSearch).value == 'البحث')
    document.getElementById(tSearch).value = '';
}

function rSearch()
{
    if(document.getElementById(tSearch).value == '')
    document.getElementById(tSearch).value = 'البحث';
}
function checksearch(oSrc, args)
{
    if(document.getElementById(tSearch).value == 'البحث')
    {
        document.getElementById(tSearch).value = '';
        args.IsValid = false;
    }
    else 
    {
        args.IsValid = true;
    }
}
/* ---- Search End ----*/

/* News letter */
function checkmail(oSrc, args)
{
    if(document.getElementById(tNletter).value == 'أدخل عنوان بريدك الالكتروني')
    {
        document.getElementById(tNletter).value = '';
        args.IsValid = false;
        ValidatorEnable(document.getElementById(reVal), false);
    }
    else 
    {
        args.IsValid = true;
        ValidatorEnable(document.getElementById(reVal), true);
    }
}
function cmail()
{
    if(document.getElementById(tNletter).value == 'أدخل عنوان بريدك الالكتروني')
    document.getElementById(tNletter).value = '';
}

function rmail()
{
    if(document.getElementById(tNletter).value == '')
    document.getElementById(tNletter).value = 'أدخل عنوان بريدك الالكتروني';
}

/*  --------------- Weblinks -------------------*/

function DisplayItem(id,obj)
{
   //alert(obj.id);
   if(document.getElementById('hom1e_weblinks_hidPrevSelectId').value !='')
    {
      var objPrev=document.getElementById('hom1e_weblinks_hidPrevSelectId').value;
      if(document.getElementById(objPrev)!=null)
      {
       document.getElementById(objPrev).className='related_website';
       }
    }
    else
    {
      if(document.getElementById('hom1e_weblinks_dlstCategories_ctl00_tblFaqCat')!=null)
      {
        document.getElementById('hom1e_weblinks_dlstCategories_ctl00_tblFaqCat').className='related_website';
      }
    }
  document.getElementById('hom1e_weblinks_hidPrevSelectId').value=obj.id;
  
   obj.className="related_website_selected";
    var rtn = tac_post("on_weblinks_over",id).split(';');
    document.getElementById('hom1e_weblinks_lnkTitle').innerHTML = rtn[0];   // rtn[0]-title ; [1]-image ; [2]-external url [3]-description;  
    if(rtn[2]!="")
    {
        document.getElementById('hom1e_weblinks_lnkTitle').href = rtn[2];
        document.getElementById('hom1e_weblinks_lnkTitle').target = "_blank";
    }
    else
    {
        document.getElementById('hom1e_weblinks_lnkTitle').href="";
    }
    if(rtn[1]!= "")
    {
        document.getElementById('hom1e_weblinks_imgweblinkLogo').src = bpath+rtn[1];
        document.getElementById('hom1e_weblinks_lnkweblink').href = bpath+rtn[1]; 
        document.getElementById('hom1e_weblinks_imgweblinkLogo').style.display = 'block';
    }
    else
    {
        document.getElementById('hom1e_weblinks_imgweblinkLogo').style.display = 'none';
    }
    if(rtn[3]!= "")
    {
        document.getElementById('hom1e_weblinks_ltDescription').innerHTML = rtn[3];
        document.getElementById('hom1e_weblinks_ltDescription').style.display = 'block';
    }
    else
    {
        document.getElementById('hom1e_weblinks_ltDescription').style.display = 'none';
    }
}

function English()
{
   var Urls = location.href;
   if(Urls.length > 0)
   {
        var fixpath = Urls.split("/ar/");
        if(fixpath.length > 1)
        {
            location.href = apath+"en/"+fixpath[fixpath.length-1];
        }
      
   }
   else
   {
    location.href = apath+"en/";
   }
}

/* Show video Scripts */

function PlayMovie(filename) {
    Ovideo();
    var player = document.getElementById('flvPlayer');
    player.innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='387' height='302' bgcolor='#000000' id='myFlashMovie' name='myFlashMovie'><param name='movie' value='/downloads/zoom.swf' /><param name='FlashVars' value='videos=/downloads/files/" + filename + "&fms=&app=' /><param name='allowFullScreen' value='true' /><param name='quality' value='high'/><embed src='/downloads/zoom.swf' width='387' height='302' bgcolor='#000000' flashvars='videos=/downloads/files/" + filename + "&fms=&app=' allowfullscreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'  id='myFlashMovie' name='myFlashMovie'/></object>";
}
function setScroll() {
    var tPos = (screen.availHeight) ? (screen.availHeight - 500) / 2 : 0;
    tPos += document.documentElement.scrollTop;
    document.getElementById('nxt').style.top = tPos + "px";
}
function fixScroll() {
    //document.getElementById('main1').style.height = document.getElementById('tblContent').offsetHeight;
   // document.getElementById('main1').style.width = screen.width - 23;
    var lPos = (screen.width) ? (screen.width - 300) / 2 : 0;
    document.getElementById('nxt').style.left = lPos + 'px';
    var tPos = (screen.availHeight) ? (screen.availHeight - 430) / 2 : 0;
    document.getElementById('nxt').style.top = tPos + 'px';


    var cleft = 0;
    var cTop = 0;
    var obj = document.getElementById('tdContent');
    if (obj != null) {
        if (obj.offsetParent) {

            while (true) {
                cleft += obj.offsetLeft;
                cTop += obj.offsetTop;
                if (!obj.offsetParent) break;
                obj = obj.offsetParent;
            }
        }
    }
}
function Ovideo() {
    //document.getElementById('main1').style.display = 'block';
    document.getElementById('nxt').style.display = 'block';
}
function Cvideo() {
    //document.getElementById('main1').style.display = 'none';
    document.getElementById('nxt').style.display = 'none';
    var player = document.getElementById('flvPlayer');
    player.innerHTML = '';
}

/* New Video Gallery */
function PlayMovie1(filename) {
    Ovideo();
    var player = document.getElementById('flvPlayer');
    player.innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='387' height='302' bgcolor='#000000' id='myFlashMovie' name='myFlashMovie'><param name='movie' value='" + AppPath + "downloads/zoom.swf' /><param name='FlashVars' value='videos=" + filename + "&fms=&app=' /><param name='allowFullScreen' value='true' /><param name='quality' value='high'/><embed src='" + AppPath + "downloads/zoom.swf' width='387' height='302' bgcolor='#000000' flashvars='videos=" + filename + "&fms=&app=' allowfullscreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'  id='myFlashMovie' name='myFlashMovie'/></object>";
}


/*----------------------*/

/* --------------------------- Mp3 E library ----------------------------------- */
 var popupwidth = 200;
 /* < ELIBRARY Pdf and Video Popup */
	var showPopup = false;
	var popUpId = '';
	var popUpLeftPos = '0px';
	var popUpTopPos = '0px';
	
	function setParam(popup, e, x, h) 
	{
	    var posx = 0;
	    var posy = 0;
	    if (!e) var e = window.event;
//	    alert(e.pageX);
//	    alert(e.pageY);
//	    alert(e.clientX);
//	    alert(e.clientY);
	    if (e.pageX || e.pageY){
		    posx = e.pageX;
		    posy = e.pageY;
	    }
	    else if (e.clientX || e.clientY){
		    posx = e.clientX + document.body.scrollLeft
			    + document.documentElement.scrollLeft;
		    posy = e.clientY + document.body.scrollTop
			    + document.documentElement.scrollTop;
			
//			var width = document.body.scrollLeft + document.body.clientWidth;    
//			    if (posx > width) // if it will exceed the clientWidth
//			     posx = 
			    
	    }
	   
	    document.getElementById('hidShowPopUp').value = "TRUE"; //set hidden field from Masterpage to true
	    showPopup = true;
        popUpId = popup;
        
        popUpLeftPos=(posx - x) + 'px';
        popUpTopPos=(posy - h) +'px'; 
      
        //resizing of the popup    
        var width =document.body.scrollLeft + document.body.clientWidth ;        
        // alert('popUpLeftPos = ' + popUpLeftPos + '    ' + ' width = ' + width + ' offsetwidth = ' + popup.offsetWidth);         
         if ( (posx + 604) > width)
            popUpLeftPos = width - 604;   // Commented by vimal to make pop up center align. 
        if(popUpTopPos.indexOf("-")!="-1")
        {
            popUpTopPos = 192+'px';
            popUpLeftPos = 92+'px';
        }
                
        if(checkLayer(popup)) return true;
        else
        {
            initLayer();
            return false;
        }
    }      
    
    function setOver(objname) 
    {
        if (document.all && document.getElementById) 
        {
            navRoot = document.getElementById(objname);
            if(navRoot != null)
            {
                for (i=0; i<navRoot.childNodes.length; i++) 
                {
                    node = navRoot.childNodes[i];
                    if (node.nodeName=="LI") 
                    {
                        node.onmouseover=function() 
                        {
                            this.className+=" liover";
                        }
                        node.onmouseout=function() 
                        {
                            this.className=this.className.replace(" liover", "");
                        }
                    }
                }
            }
        }
    }
    
    function closeLayer(pop)
    {       
        var objPop = document.getElementById(pop);
        if(objPop != null)
        {
            objPop.style.display = 'none';
            document.getElementById('hidShowPopUp').value = "FALSE"; //set hidden field from Masterpage to false
            
            if( document.getElementById('ctl00_content_divAudioVideo') != null) // Stop playing the file once you close the Window.
            {
            document.getElementById('ctl00_content_divAudioVideo').innerHTML='';
            }
        }
    }
    
    function checkLayer(pop)
    {
        var objPop = document.getElementById(popUpId);
        if(objPop != null)
        {
            if(objPop.style.display == 'block') return false;
            else return true;
        }
        else return true;
    }
    
	function initLayer()
	{
	    //setOver("eliblst"); // IE Patch for Elibray List
	    	    
	    if (document.getElementById('hidShowPopUp').value == "FALSE") //check hidden field from Masterpage;
	        showPopup = false;
	    else
	        showPopup = true;   
	    
	    try
	    {
	        if(showPopup)
	        {
	            
	            var objPop = document.getElementById(popUpId);
	            if(objPop != null)
	            {
	                objPop.style.left = popUpLeftPos;
	                objPop.style.top = popUpTopPos;
	                objPop.style.display = 'block';
	            }
	        }
	        else
	        {
	            popUpId = '';
	            popUpleftPos = '0px';
	            popUprightPos = '0px';
	            
	        }
	    }
	    catch(err)
	    {
	        //alert('error : ' + err.description);
	    }
	}
function closePopUP(pop)
   {           
        var objPop = document.getElementById(pop);
        if(objPop != null)
        {
            objPop.style.display = 'none';        
        }
   }
 /*  ELIBRARY MP3 End>  */

