﻿var imagedir='../images'
var bodyhtml='ctl00_bodyhtml';
var time;
var PopLayer=new String('');
var membersemail=new Number();
var ua = 'msie';
var FiledNull = 'لا تترك الحقل فارغا';
var FiledInteger = 'أدخل قيمة رقمية';
var W=navigator.userAgent.toLowerCase();
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}

var isIE=false;
try{isIE=(navigator.userAgent.indexOf("MSIE") > 0 && !window.opera);}catch(E){}
bodyWidth=function(){return parseInt( isIE ? document.body.clientWidth : window.innerWidth)}
bodyHeight=function(){return parseInt( isIE ? document.body.clientHeight : window.innerHeight)}




// attach a handler to a particular event on an element
	// in a browser-independent way
	function registerEventHandler (element, event, handler) {
		if (element.attachEvent) {
			// MS registration model
			element.attachEvent('on' + event, handler);
		} else if (element.addEventListener) {
			// NN (W4C) regisration model
			element.addEventListener(event, handler, false);
		} else {
			// old regisration model as fall-back
			element[event] = handler;
		}
	}


	
	
function removeListener(obj, event, listener){
    if(ua == 'gecko' || ua == 'opera'){
        obj.removeEventListener(event, listener, false);
    } else if (ua == 'msie') {
        obj.detachEvent("on"+event,listener);
    }
};

function $setatt(obj,att,value)
{
$(obj).setAttribute(att,value)

}

function $(id)
{
var item;
if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;

}



function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");

}

function hs(obj,value)
{
 $(obj).style.display=value;

}





function $ES(txt)
{
 
  return escape(txt)

}

function $F(obj)
{

  $(obj).focus();

}

function Iframe(framename)
{

return $(framename).contentWindow

}

function $css(obj,cn)
{
  $(obj).className=cn;
  
}


 function $FR(obj)
 {
 
   return $(obj).contentWindow;
 
 }

 function ListFiledError(Parent,Msg) {
     this.HC = new htmlcontrol();
     this.Chiled = new String('');
     for (var i = 0; i < Parent.length; i++) {
         this.Chiled = 'SpanError' + i;
         this.HC.addElement(Parent[i], this.Chiled, 'span');
         $(this.Chiled).innerHTML = Msg[i];
         $css(this.Chiled, 'inuptvalide')
     }

 }

 function ClearFiledError(Parent, ErrorFiled) {
     try {
         this.HC = new htmlcontrol();
         this.Chiled = new String('');
         for (var i = 0; i < Parent.length; i++) {
             this.Chiled = 'SpanError' + i;
             this.HC.removeElement(Parent[i], $(this.Chiled))

         }
         removearr(Parent);
         removearr(ErrorFiled);
     } catch (e) { }
 }
 
 
function sitemessage(msg)
{
	    var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();
	    $('ipd-msg-wrapper').style.position='absolute'
	    $('ipd-msg-wrapper').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 45) / 2) + 'px');
	    $('ipd-msg-wrapper').style.left = (((arrayPageSize[0] - 20 - 220) / 2) + 'px');
	    $('ipd-msg-wrapper').style.display = 'block';
	    $('ipd-msg-text').innerHTML=msg;
	    $('ipd-msg-wrapper').style.zIndex = '200';
	    window.setTimeout("hs('ipd-msg-wrapper','none')",2000)
	    
	    
}



function msgconfirm(msg,funcall,FunCancel) {
  
	    var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();

	
	    this.HC=new htmlcontrol(); 
	    $('amf_msg_confirm').style.position='absolute'
	    $('amf_msg_confirm').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 45) / 2) + 'px');
		$('amf_msg_confirm').style.left = (((arrayPageSize[0] - 20 - 220) / 2) + 'px');
	    $('amf_msg_confirm').style.zIndex = '200'
	    $('overlay').style.height = (arrayPageSize[1] + 'px');
	    $('amg_msg_txt').innerHTML=msg
	    $('msgbutton').innerHTML = '<br>' + this.HC.createfiledwithevent('button', 'نعم', '', '0', 'onclick="hs(\'overlay\',\'none\');hs(\'amf_msg_confirm\',\'none\');' + funcall + '"', 'button')
	    if (FunCancel == null) {

	        $('msgbutton').innerHTML += '  ' + this.HC.createfiledwithevent('button', 'إلغاء الأمر', '', '0', 'onclick="hs(\'overlay\',\'none\');hs(\'amf_msg_confirm\',\'none\');"', 'button');

	    }
	    else {
	        $('msgbutton').innerHTML += '  ' + this.HC.createfiledwithevent('button', 'إلغاء الأمر', '', '0', 'onclick="hs(\'overlay\',\'none\');hs(\'amf_msg_confirm\',\'none\');' + FunCancel + '"', 'button')
	    }
	   
	    hs('amf_msg_confirm','block');
	    hs('overlay','block');
	    hs('loadingImage','none');    
	
}






function amf_loading()
{

 	// prep objects
	var objOverlay = $('overlay');
	var objLightbox = $('lightbox');
	var objCaption = $('lightboxCaption');
	var objImage = $('lightboxImage');
	var objLoadingImage = $('loadingImage');
	var objLightboxDetails = $('lightboxDetails');

	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

  
  

}



function Togglemsg(src,msg)
{

 time=window.setTimeout("amf_loading();",99)
 setTimeout("hideLightbox();",3000)
	
}
function setblanket()
{

        clear_time(time); 
        time=window.setTimeout("amf_loading();",99)
      
}

function popupdiv(obj,w,h)
{
	    var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();


	    w = $(obj).offsetWidth;
	    h = $(obj).offsetHeight;
	    this.HC=new htmlcontrol(); 
	    $(obj).style.position='absolute'
	    $(obj).style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - h) / 2) + 'px');
		$(obj).style.left = (((arrayPageSize[0] - 20 - w) / 2) + 'px');
	    $(obj).style.zIndex = '100'
	   // $('overlay').style.height = (arrayPageSize[1] + 'px');
	   
	    hs(obj,'block');
	    PopLayer = obj;
	    //hs('overlay','block');
	    //hs('loadingImage','none');   
	
	

}

function popupdiv(obj) {
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();


   var w = $(obj).offsetWidth;
   var h = $(obj).offsetHeight;

 //  $(obj).style.width = w ;
 //  $(obj).style.height = h;
    
    this.HC = new htmlcontrol();
    $(obj).style.position = 'absolute'
    $(obj).style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - h) / 2) + 'px');
    $(obj).style.left = (((arrayPageSize[0] - 20 - w) / 2) + 'px');
    $(obj).style.zIndex = '100'
    hs(obj, 'block');
    PopLayer = obj;

}


	function $MC(msg,msgcancel)
{
 if (confirm(msg))
  {
         
         return true;
       }
       else {
          alert (msgcancel);
          return false;
       } 
  
}


function hide_show(obj)
{
  if ($(obj).style.display=='block')
      $(obj).style.display='none'
   else
      $(obj).style.display='block'

}



  /*SetAnimation*/
function SetAnimation (obj,step,css1,css2)
	{
			if (step==0 && $(obj))
{
clear_time(time);
ClassSwap(obj,css2);
}
	
	
		if (step % 2 == 0)
		$(obj).className=css1;
		
		else
		$(obj).className=css2;
			

		step++;

		
	time=window.setTimeout("SetAnimation('"+obj+"',"+step+",'"+css1+"','"+css2+"');", 199);
	}  
	
	
		/*destroy setTimeout*/
function clear_time(obj)
{
   window.clearTimeout(obj);
}

//swap css
function ClassSwap(obj,css)
{
 $(obj).className = css;
}








function IsInteger(s) 
   {
       if (!IsNull(s) && (parseFloat(s) || s=='0'))
           return true;
       else
           return false;
    
   }




   function IsNull(v)
   {

   if (v=='' || v==null)
           return true;
   else
      return false;
   
   }
   
   //Check validate Email
   function validate_email(field)
{


apos=field.indexOf("@")
dotpos=field.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {

  return false
  }
else {

return true}

}



/*Checl all box*/

function ckbox(TF,nameck) {

var ck=document.body.getElementsByTagName("input")
for(var i=0;i<ck.length;i++)
{
  if (ck[i].type=='checkbox' && ck[i].name.match(nameck)==nameck)
  ck[i].checked=TF;

}


	}  





/*Return Value selected from checkbox*/

function return_ckbox(nameck) {
var Re=new String('')
var ck=document.body.getElementsByTagName("input")
for(var i=0;i<ck.length;i++)
{
  if (ck[i].type=='checkbox' && ck[i].name.match(nameck)==nameck)
  if (ck[i].checked)
  Re+=ck[i].value+',';

}

return Re
	} 



	


function get_multiple_value_from_checkbox(nameck)
{


  var ck=document.body.getElementsByTagName("input");
  var value=new Array();
for(var i=0;i<ck.length;i++)
{
  if (ck[i].type=='checkbox' && ck[i].name.match(nameck)==nameck)
  {
   if (ck[i].checked)
    value[value.length]=ck[i].value
  
  }
  

}



return value


}



/*True and  False*/
function amf_Boolean(v)
{
v=new String(v.toLocaleLowerCase())
if (v=='true')
return 1;
else
return 0;
}



/*Get value from xml*/
function amf_firstChild_node(obj,i,item)
{
 var value=new String('')
     try{
     value=obj[i].getElementsByTagName(item)[0].firstChild.nodeValue
}
catch (e)
{
//do nothing
}

return value;
}



function getidevent(event)
{
 return window.event.srcElement.id
}






/*Redriect Page*/
function _go(url)
{
 
 
 document.location.href=url


}



/*Remove Enter*/

function noenter() {

  return !(window.event && window.event.keyCode == 13); }
  
  
  
  /*Round Number*/
  
  function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
  
  
  
  
  
  
	function link_to_post(theURL) {
     var temp
temp = prompt("نسخ الوصلة يدويا إلى هذه المشاركة لتخزين الوصلة في ذاكرة لوحة الكتابة في حاسوبك", theURL);
	
return false;
    }
  
  
  
  
  
  
  // Toggle category
//==========================================

function togglecategory(fid,TF,hy,issave)
{
 this.name=fid;
 this.value='';
 
 this.value=TF

 TF=amf_Boolean(TF)

if (TF)
      hs(this.name,'block');
else
      hs(this.name,'none');


 $(hy).href='javascript:togglecategory(\''+fid+'\',\''+!TF+'\',\''+hy+'\','+issave+')';
 
 amf_ajax(xmllinks+'?flag=12&name='+this.name+'&value='+this.value+'&tf='+issave+'',donothing)
 
 /* tmp=my_getcookie('forum'+fid)


 
 switch(tmp)
 {
   case 'none':
                 $('togglecategory'+fid).src=folder_style+'/exp_minus.gif';
                 tmp='block';
                 
   break;
   
   default:
                 $('togglecategory'+fid).src=folder_style+'/exp_plus.gif';
                 tmp='none';
                 
   break;
 }
 
 hs('f_'+fid,tmp,0);

my_setcookie('forum'+fid,tmp, 0 )*/
}
  
  
  
  
  //==========================================
// Get cookie
//==========================================

function my_getcookie( name )
{
	cname = amf_var_cookieid + name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

//==========================================
// Set cookie
//==========================================

function my_setcookie( name, value, sticky )
{
	expire = "";
	domain = "";
	path   = "/";
	
	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}
	
	if ( amf_var_cookie_domain != "" )
	{
		domain = '; domain=' + amf_var_cookie_domain;
	}
	
	/*if ( ipb_var_cookie_path != "" )
	{
		path = ipb_var_cookie_path;
	}*/
	
	//document.cookie = amf_var_cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';
	
	document.cookie = amf_var_cookieid + name +"="+value+expire+"; path="+path+"";
}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  






function myassistant_init(tabno)
{
  var tab=$("myassistant_tab").getElementsByTagName("div");
  
  for (var i=0; i<tab.length; i++)
  {
    if (i==tabno)
    {
        tab[i].className='pp-tabon';
        hs('tab'+i,'block');
    }
    else
    {
        tab[i].className='pp-taboff';
        hs('tab'+i,'none');
  
    } 
  
  }

}




function $GetParent(Obj) {
    alert($(Obj).offsetParent.offsetTop)
}
/*
function showToolTip1DivScrollingThird(e, headline, publishdate, body) {
    var headline = headline;
    var publishdate = publishdate;
    var body = body;
    var obj = document.getElementById('bubble_tooltip');
    obj.style.display = '';
    var obj2 = document.getElementById('tooltipBoldTxt');
    obj2.innerHTML = headline;
    var obj3 = document.getElementById('tooltipDateTxt');
    obj3.innerHTML = publishdate;
    var obj4 = document.getElementById('tooltipBodyTxt');
    obj4.innerHTML = body;
    var st = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
    obj.style.left = eval(eval(getElementLeft2(e) - 100)) + 'px';
    obj.style.top = getElementTop2(e) - obj.offsetHeight - document.getElementById('divMainThirdWeb2' + ImageUpID).scrollTop + 'px';
}



function ToolTipe(Obj,Title,Contenet) {
    this.X = new Number();
    this.Y = new Number();
    this.st = new Number(Math.max(document.body.scrollTop, document.documentElement.scrollTop));
    this.parentNode = $(Obj);

    while (this.parentNode.offsetParent) {
        this.parentNode = this.parentNode.offsetParent;
        this.X += this.parentNode.offsetLeft;
        this.Y += this.parentNode.offsetTop;
    }

    this.X = eval(this.X + $(Obj).offsetWidth);
    this.Y = this.Y - $(Obj).offsetHeight;
    $('ipd-msg-wrapper').style.left = this.X + 'px';
    $('ipd-msg-wrapper').style.top = (this.Y) + 'px';
    hs('ipd-msg-wrapper', 'block');
}
*/
/*Show Time*/

function HandleTimes(Obj, gServerTime, bFirstCall) {
    var result = false;
    var serverTime = document.getElementById(Obj);
  
    if (serverTime != null) {
        if (bFirstCall) {
            bFirstCall = false;
            gServerTime = gServerTime.valueOf() - new Date().valueOf();
        }
        gServerTime = new Number(gServerTime)
        var temp = new Date(new Date().valueOf() + gServerTime);

        try {
            serverTime.innerHTML = GetTimeString(temp);
            result = true;
        }
        catch (ex)
		{ }
    }

    if (result)
        setTimeout('HandleTimes(\'' + Obj + '\',' + gServerTime + ',' + bFirstCall + ');', 1000);
}

function GetTimeString(now) {
    var result;
    if (isIE) {
        if (0 == now.getHours()) {
            result = "12:" + LPad(now.getMinutes(), 2, "0") + " صباحاً";
        } else if (12 < now.getHours()) {
            result = (now.getHours() - 12) + ":" + LPad(now.getMinutes(), 2, "0") + " مساء";
        }
        else {
            result = now.getHours() + ":" + LPad(now.getMinutes(), 2, "0") + " صباحاً";
        }
    }
    else {
        result = now.toLocaleTimeString();
    }
    return result
}

function LPad(str, length, chr) {
    while (str.length <= length) {
        str = chr + str;
    }
    return str;
}

function ExecuteProd()
{

 sitemessage('جاري تنفيذ الإجراء');

}

function hlightWord(Str, Keyword, Separator)
{

if (Str !='' && Keyword.length>3)
{
 this.Word=new Array();
 this.Word=Keyword.split(Separator)
var myRegExp
 for (var i=0;i<this.Word.length;i++)
 {

    var  myRegExp = new RegExp(this.Word[i],"gi"); 


   Str = Str.replace(myRegExp, '<span class=searchlite>'+this.Word[i]+'</span>'); 
 
 
 } 
}
return Str;
}

function SelectFile(frameattachment,Fileattachment,Obj)
{
 this.Iframe = $FR(frameattachment)
 

 this.Iframe.$(Fileattachment).click();
 $(Obj).value=this.Iframe.$(Fileattachment).value;
}

function CheckIsImage(Ext){

this.ImgExt=new Array('.jpg','.jpeg','.gif','.bmp','.tiff');
this.Correct=new  Boolean(false);
Ext=new String(Ext.toLocaleLowerCase())
for (var i=0;i<this.ImgExt.length;i++)
{
 
 if (Ext==this.ImgExt[i])
 {
 this.Correct=true; 
 break;
 }

}

return this.Correct;
}
