
    function logOut(lang){
	
	    if(lang == 'en'){
		     var text = "Are you sure you want to logout?"; 
	    }else{
		     var text = "هل انت متاكد بانك تريد الخروج ؟";
	    } 
	
        if(confirm(text))
            top.location="http://ldap.maktoob.com/newSkype/pages/logOut.php?lang="+lang;
        }


    function register(lang){    
        top.location="http://ldap.maktoob.com/newreg/register_"+lang+".php?page_name=https://ldap.maktoob.com/newSkype/pages/index.php&maktoobfield=skype&utm_source=skype&utm_medium=URL&utm_campaign=Registration-through-header";
    }//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 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 validate(lang){
        var x=1;
        document.form1.user_name.value  =  trim(document.form1.user_name.value);
        document.form1.user_mail.value  =  trim(document.form1.user_mail.value);
        document.form1.n1.value         =  trim(document.form1.n1.value);
        document.form1.n2.value         =  trim(document.form1.n2.value);
        document.form1.n3.value         =  trim(document.form1.n3.value);
        document.form1.n4.value         =  trim(document.form1.n4.value);
        document.form1.n5.value         =  trim(document.form1.n5.value);
        document.form1.n6.value         =  trim(document.form1.n6.value);
        document.form1.n7.value         =  trim(document.form1.n7.value);
        document.form1.n8.value         =  trim(document.form1.n8.value); 
        document.form1.n9.value         =  trim(document.form1.n9.value);
        document.form1.n10.value        =  trim(document.form1.n10.value);  
        document.form1.a1.value         =  trim(document.form1.a1.value);
        document.form1.a2.value         =  trim(document.form1.a2.value);
        document.form1.a3.value         =  trim(document.form1.a3.value);
        document.form1.a4.value         =  trim(document.form1.a4.value);
        document.form1.a5.value         =  trim(document.form1.a5.value);
        document.form1.a6.value         =  trim(document.form1.a6.value);
        document.form1.a7.value         =  trim(document.form1.a7.value);
        document.form1.a8.value         =  trim(document.form1.a8.value); 
        document.form1.a9.value         =  trim(document.form1.a9.value);
        document.form1.a10.value        =  trim(document.form1.a10.value);    
             
//**********************************user name******************************************** 
        if(document.form1.user_name.value == ""){
        	if(lang == "en")
                alert("Please fill in your name");
            else
                alert("الرجاء إدخال اسمك");    
            document.form1.user_name.focus();
            x=0;
            return false;
        }

        if(!check_chars(document.form1.user_name.value)){
        	if(lang == "en")
                alert("Please chick your name");
            else
                alert("الرجاء التاكد من صحة اسمك");
            document.form1.user_name.focus();
            x=0;
            return false;
        }



//*********************************user email********************************************* 
        if(document.form1.user_mail.value == ""){
            if(lang == "en")
        	    alert("Please fill in your email address");
        	else
                alert("الرجاء ادخل عنوان بريدك الالكتروني");    
            document.form1.user_mail.focus();
            x=0;
            return false;
        }
    
    
        if (!testemail(document.form1.user_mail) ){
            if(lang == "en")
        	    window.alert('Please check your email address ');
        	else
                alert("الررجاء االتأكد من صحة عنوان بريدك الإلكتروني");     
            document.form1.user_mail.focus();
            return false;
        }
   

//****************************at least one friend's name and email**********************************  
        if(document.form1.n1.value == ""){
            if(lang == "en")
        	    alert("Please enter at least one frind name");
        	else
                alert("الرجاء ادخل اسم صديق واحد على الأقل");      
            document.form1.n1.focus();
            x=0;
            return false;
        }

        if(!check_chars(document.form1.n1.value)){
            if(lang == "en")
        	    alert("Please chick your friend name");
        	else
                alert("الرجاء التأكد من صحة عنوان بريد صديقق الإلكتروني");       
            document.form1.n1.focus();
            x=0;
            return false;
        }

        if(document.form1.a1.value == ""){
        	if(lang == "en")
                alert("Please enter one friend email address");
            else
                alert("الرجاء إدخال عنوان بريد صديقك الإلكتروني");      
            document.form1.a1.focus();
            x=0;
            return false;
        }
    
        if (!testemail(document.form1.a1) ){
            if(lang == "en")
        	    alert("Please chick your friend email address");
        	else
                alert("الرجاء التأكد من صحة عنوان بريد صديقك الإلكتروني"); 
            document.form1.a1.focus();
	        x=0;
            return false;
        }


// ************************************ For loop other names and addresses *****************
        var count = 0;
	    var emails = new Array();
	    
        for(var i = 1 ; i <= 10 ; i++){
           if(eval("document.form1.a"+i+".value.length") > 0 || eval("document.form1.n"+i+".value.length") > 0){
	           if(eval("document.form1.n"+i+".value") == ""){
	               if(lang == "en")
	           	       alert("please enter your friend name");
	           	   else
                       alert("الرجاء ادخل اسم صديقك");     
		           f = eval("document.form1.n"+i+"");
		           f.focus();
		           x=0;
		           return false;
	           }

	           if(!check_chars(eval("document.form1.n"+i+".value"))){
	               if(lang == "en")           	
	                   alert("Please chick your friend name");
	               else
                       alert("الرجاء التأكد من صحة عنوان بريد صديقق الإلكتروني");       
		           f = eval("document.form1.n"+i+"");
		           f.focus();
		           x=0;
		           return false;
	           }

	           if(eval("document.form1.a"+i+".value") == ""){
	                if(lang == "en")   
	           	        alert("please fill in your friend email address");
		            else
	           	        alert("الرجاء إدخال عنوان بريد صديقك الإلكتروني"); 
	               f = eval("document.form1.a"+i+"");
		           f.focus();
		           x=0;
		           return false;
	           }

	            if(!testemail(eval("document.form1.a"+i+""))){
                    if(lang == "en")     
	            	    alert("Please chick your friend email address");
	                else
                        alert("الرجاء التأكد من صحة عنوان بريد صديقك الإلكتروني");
		            f=eval("document.form1.a"+i+"");
		            f.focus();
		            x=0;
	                return false;
	            }
	            
	            if(eval("in_array(emails,document.form1.a"+i+".value)")) {
				    if(lang == "en")   
	            	    window.alert("you cannot use the same email twice");
	            	else
                        alert("لا يمكنك استخدام عنوان البريد الإلتروني اكثر من مره ");    
				    eval("emails,document.form1.a"+i+".focus()");
				    return false;
			    }
			    
			    emails[count] = eval("document.form1.a"+i+".value");
			    count++;

  	
           }
       }   
//******************************************************************************************************

       /*if(x == 1){
           all_mails = "";
           all_names = "";
        
           for(var j=1;j<10;j++){
	       if(eval("document.form1.a"+j+".value.length") > 0){
	           all_mails=all_mails+eval("document.form1.a"+j+".value")+",";
		   all_names=all_names+eval("document.form1.n"+j+".value")+",";
               }
           }
 
           document.form1.all_mails.value=all_mails;
           document.form1.all_names.value=all_names;
           document.form1.submit();
       }//end if(x == 1)*/
       return true;
       
    }//end validatin function

   
    function go(){
        document.cashU.submit();
    }//end function go
    
    
    function validContactUs(lang) {
    	document.contact.name.value    = trim(document.contact.name.value);
    	document.contact.email.value   = trim(document.contact.email.value);
    	document.contact.subject.value = trim(document.contact.subject.value);
        document.contact.comment.value = trim(document.contact.comment.value);
        
    	if(document.contact.name.value == ""){
            if(lang == "en")
    		    alert("Please fill in your name");
            else
                alert("الرجاء ادخال إسمك");
    	    document.contact.name.focus();            
            return false;
        }
        
        if(document.contact.email.value == ""){
            if(lang == "en")
        	    alert("Please fill in your email");
        	else
        	    alert("الرجاء ادخال بريدك الإلكتروني");        	    
            document.contact.email.focus();            
            return false;
        }
        
        if (!testemail(document.contact.email) ){
            if(lang == "en")
        	    alert("Please chick your email address");
            else
                alert("الرجاء التاكد من صحة بريدك الإلكتروني");
            document.contact.email.focus();
            return false;
        }
        
         if(document.contact.subject.value == ""){
            if(lang == "en")
         	    alert("Please fill in the subject");
         	else
         	    alert("الرجاء ادخال الموضوع");    
            document.contact.subject.focus();            
            return false;
        }
        
        if(document.contact.comment.value == ""){
        	if(lang == "en")
                alert("Please fill in the comment");
            else
                alert("الرجاء ادخال التعليق");
            document.contact.comment.focus();            
            return false;
        }
         	
    }//end validContactUs()
    
    
    
    function in_array(arr,str) {
	    var word= str.toUpperCase();
	    for (var i = 0; i < arr.length; i++) {
		    if(arr[i].toUpperCase() == word) {
			    return true;
		    }
	   }
	   return false;
    }//end function in_array
    
    
    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(!valid(document.login.meuser.value)) {
        	if(lang == "en")
                window.alert('Please chick your username');
            else
               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;
        }
   }
   
    function validPromotion(lang) {
   	    document.promo.name.value  =  trim(document.promo.name.value);
   	    document.promo.email.value =  trim(document.promo.email.value);
   	    
   	    if (document.promo.name.value == ""){
   	        if(lang == "en")
                window.alert("Please enter you name");
            else
               window.alert("الرجاء ادخال اسم المستخدم");
            
            document.promo.name.focus();   
            return false;
        }
        
        if(document.promo.email.value == ""){
            if(lang == "en")
        	    alert("Please fill in your email address");
        	else
                alert("الرجاء ادخل عنوان بريدك الالكتروني");    
            document.promo.email.focus();
            x=0;
            return false;
        }
    
    
        if (!testemail(document.promo.email) ){
            if(lang == "en")
        	    window.alert('Please check your email address ');
        	else
                alert("الررجاء االتأكد من صحة عنوان بريدك الإلكتروني");     
            document.promo.email.focus();
            return false;
        }
        
   	
   }
   
   
   
   var go_search_ar=false;
	function arabySearch(tt,lang){
		if(tt==13){  
			if(document.form1.q.value == ""){
				//document.form1.q.focus();
				if(lang == "ar"){
					alert("الرجاء ادخال الكلمة او العبارة التي تبحث عنها");
				}else{
					alert("please enter the word or statement you search about it");
				}
				return false;
			}
			if(document.form1.type.value == 2 ){
				if(lang == "ar"){
					document.location="searchAll_a.php?section=All&q="+document.form1.q.value+"&page=1&type=2";
				}else{
					document.location="searchAll_a.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;
	}