    var URL = 'http://seenjeem.maktoob.com/';
    
    function logOut(lang,source){
	
	    if(lang == 'en'){
		     var text = "Are you sure you want to logout?"; 
	    }else{
		     var text = "هل انت متاكد بانك تريد الخروج ؟";
	    } 
	
        if(confirm(text))
            top.location="http://www.maktoob.com/logout.pl?language=ar&source="+source;
        }


    function register(lang){    
        top.location="http://ldap.maktoob.com/newreg/register_"+lang+".php?page_name=http://skype.maktoob.com/pages/index.php&maktoobfield=skype&mm="+Math.floor(1000000*Math.random());
    }//end function




     function check_chars(urstr) {
            var newstr = new String(urstr);
            var i; 
            var result;
            var allowedchar = " '@_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzدجحخهعغفقثصضذطكمنتالبيسشئءؤرلاىةوزظ"   ;
         
            for(i=0; i<urstr.length; i++) {
                if(allowedchar.indexOf(urstr.charAt(i))<0)
                    return false;
                else
                    result = true;
            }
            if(result == true)
                return true;
    }//end function
    
    
    function trim(str) {
        
        var from_start = 0;
        var from_end = str.length - 1;
        var return_value;

        while(str.charAt(from_start) == ' ') {
            from_start ++;
        }

        while(str.charAt(from_end) == ' ') {
           from_end --;
        }
   
        if(from_end < from_start){
           return '' ;
        }

        return_value = str.substring(from_start,from_end+1);
        return return_value;

    }//end function trim 


    function checkArabic(str) {
        for(var i = 0; i < str.length; i++) {
            if(str.charCodeAt(i) < 0x20 || str.charCodeAt(i) > 0x7E) {
                return true;
            }//end if(str.charCodeAt(i) < 0x20 || str.charCodeAt(i) > 0x7E)
 
        }//end for(var i = 0; i < str.length; i++)
 
        return false;
 
    }//end function checkArabic

 
   
    function valid(str) {
        for(var i = 0; i < str.length; i++) {
            var charcode = str.charCodeAt(i);

            /* A-Z */
            if(charcode >= 0x41 && charcode <= 0x5A) {
                continue;
            }               
            /* a-z */
            if(charcode >= 0x61 && charcode <= 0x7A) {
                continue;
            }   
            /* 0-9 */
            if(charcode >= 0x30 && charcode <= 0x39) {
                continue;
            }               
            /* . - _ 32*/
            if(charcode == 0x2D || charcode == 0x2E || charcode == 0x5F  ) {
                continue;
            }
               
            return false;
        }//end for(var i = 0; i < str.length; i++)

        return true;

    }//end function valid

    
    function validUsername(str) {
        for(var i = 0; i < str.length; i++) {
            var charcode = str.charCodeAt(i);

            /* A-Z */
            if(charcode >= 0x41 && charcode <= 0x5A) {
                continue;
            }               
            /* a-z */
            if(charcode >= 0x61 && charcode <= 0x7A) {
                continue;
            }   
            /* 0-9 */
            if(charcode >= 0x30 && charcode <= 0x39) {
                continue;
            }               
            /* - _*/
            if(charcode == 0x2D || charcode == 0x5F  ) {
                continue;
            }
               
            return false;
        }//end for(var i = 0; i < str.length; i++)

        return true;

    }//end function validUsername


    function testemail(obj) {
        var atpos = obj.value.indexOf("@");
            if(atpos == -1) {
                return false;
            }

            if(atpos == 0) {
                return false;
            }

            var dotpos = obj.value.indexOf('.', atpos+2);

            if( dotpos == -1) {
                return false;
            }
               
            if(dotpos == (obj.value.length - 1) ) {
               return false;
            }
               
            if(obj.value.indexOf(".") == 0){
                return false;
            }
               
            if( obj.value.indexOf("@")  == (obj.value.indexOf('.', obj.value.indexOf("@")+1)) - 1 ){
                return false;
            }
                              
            if( obj.value.indexOf(".")  == (obj.value.indexOf('.', obj.value.indexOf(".")+1)) - 1 ){
	        return false;
            }
               
                             
           var fpart = obj.value.substring(0,atpos);
           var host = obj.value.substring(atpos + 1, dotpos);
           var domain = obj.value.substr(dotpos +1);

           if(!( valid(fpart) && valid(host) && valid(domain))) {
               return false;
           }
     
           var afterat = obj.value.substr(atpos + 1);
     
           if(afterat.lastIndexOf('.') == (afterat.length - 1)) {
               return false;
           }
     
           for(var i = 1; i < afterat.length; i++) {
        
     	       if(afterat.charAt(i) == '.' && afterat.charAt(i-1) == '.') {
                   return false;
               }

           }//end for(var i = 1; i < afterat.length; i++)

           return true;
                  
    }//end function testemail

    
    function chickLogin(lang){
        document.login.meuser.value   =  trim(document.login.meuser.value);
        
        
        if (!document.login.meuser.value){
            if(lang == "en")
                window.alert("Please enter username");
            else
               window.alert("الرجاء ادخال اسم المستخدم");
            
            document.login.meuser.focus();   
            return false;
        }
		
        if(checkArabic(document.login.meuser.value) || !validUsername(document.login.meuser.value)){
        	window.alert("الرجاء إستخدام الأحرف الإنجليزية والأرقام و (_) و(-) فقط في اسم المستخدم ");   
        	document.login.meuser.focus();   
            return false;			
		}
		
        if (!document.login.password.value ){
        	
        	if(lang == "en")
                window.alert("Please enter password");
            else
               window.alert("الرجاء إدخال كلمة السر");    
            
            document.login.password.focus();  
            return false;
        }
        
        if(checkArabic(document.login.password.value) || !validUsername(document.login.password.value)){
        	window.alert("الرجاء استخدام الأحرف  الإنجليزية والأرقام و(-) و  (_) فقط في كلمة السر");
        	document.login.password.focus();   
            return false;
         }
   }
   
   
   function valaidSmallSearch() {
	    document.s1.name.value  =  trim(document.s1.name.value);
   	    var str_search          = document.s1.name.value;
   	    if (document.s1.name.value == "" || document.s1.name.value == "ما هو سؤالك؟"){
   	        window.alert("الرجاء قم بإدخال الكلمة التي تبحث عنها");            
            document.s1.name.focus();   
            return false;
        }
        if(str_search.length < 3) {
        	window.alert("الرجاء قم بإدخال الكلمة التي تبحث عنها على ان لاتقل عن ثلاثة أحرف");            
            document.s1.name.focus();   
            return false;	
        }
        
	    
	
    }//end method
   
    
    var go_search_ar=false;
	function arabySearch(tt){
		if(tt==13){  
			if(document.form1.q.value == ""){
				//document.form1.q.focus();
				alert("الرجاء ادخال الكلمة او العبارة التي تبحث عنها");
				
				return false;
			}
			if(document.form1.type.value == 2 ){
				document.location="searchAll.php?section=All&q="+document.form1.q.value+"&page=1&type=2";
				return false;
			}else{
				go_search_ar=true;
				document.form1.submit();
			}
		}//end if keyCode
		else{
			return false;
		}
	}

	function doSearch1(){
		document.getElementById("y").className = "on";
		document.getElementById("x").className = "off";
		document.form1.type.value = 2;
	}
	
	function doSearch(){
		document.getElementById("x").className = "on";
		document.getElementById("y").className = "off";
		document.form1.type.value = 1;
	}
  
   
   
  