window.addEvent('domready', function()
{ 
    Moo = new MooAlertBox({
    OverlayStyles:{ 
   
'background-color': 'black', 
 
'opacity': 0.7 

} 
    });
    

	formcheck = new FormCheck('subscript-form', { 
                display : { 
                        errorsLocation : 1, 
                        indicateErrors : 1, 
                        keepFocusOnError : 0, 
                        closeTipsButton : 1, 
                        showErrors : 1 
                }, 
                addDataString:'action=MyAction',
                submitByAjax: true
                
             //   ajaxResponseDiv:'Wrapper'
        }) 
     
        formcheck.addEvent('onAjaxSuccess', function(result){ 
          //this.form.toQueryString()
   // alert(result);
        	if(result=="")
        	  return;
        	var resArr=new Array();
        	resArr=result.split('~');
			$('nick_error').innerHTML="";
			$('mail_error').innerHTML="";
			$('captcha_error').innerHTML="";
        	//alert(resArr[0]+'&&'+resArr[1])
			if(resArr[0]=='error')
			{
			   if(resArr[1]=="mail_exist")
			   {
					/*$('mail_error').innerHTML="<br>מייל זה כבר קיים במערכת.נא להכניס מייל אחר להרשמה!<br>";*/
				
					   Moo.info('<p style="font-size:18px;color:red">מייל זה כבר קיים במערכת.<br>נא להכניס מייל אחר להרשמה!</p>',
					   {onComplete: function(retvalue)
        			                 {
					                   $('email').focus();
					                   $('email').select();
			   	                       $('email').setStyles({border: '2px solid red',margin:'0px 0px 12px 0px'});        			                 
        			                 }});
				
				}
				
				else if(resArr[1]=="nick_exist")
				{
				  // $('nick_error').innerHTML="<br>כינוי זה כבר קיים במערכת.נא להכניס כינוי אחר להרשמה!<br>";
				   Moo.info('<p style="font-size:18px;color:red">כינוי זה כבר קיים במערכת.<br>נא להכניס כינוי אחר להרשמה!</p>',
				   {onComplete: function(retvalue)
        			                 {
        			                  $('nick').focus();
                                      $('nick').select();
                                      $('nick').setStyles({border: '2px solid red',margin:'0px 0px 12px 0px'});
        			                 
        			                 }});
				
				}
				
			}
        	else if(resArr[0]=='FailedCaptcha')
        	{
        		//$('captcha_error').innerHTML="קוד ביטחון שגוי, אנא נסה שנית"; 
        		Moo.info('<p style="font-size:18px;color:red">קוד ביטחון שגוי, אנא נסה שנית!</p>',
        			     {onComplete: function(retvalue)
        			                 {
        			                   
	                                    $('usercode').setStyles({border: '2px solid red',margin:'0px 0px 12px 0px'});  
	                                    $('usercode').focus();
	                                    $('usercode').select();
        			                 
        			                 }});
        	
        	    $('captchadiv').innerHTML=resArr[1];
        	}
        	else
        	{
        		
$('messg').style.display="block";        		
$('messg').innerHTML='<br/><br/><p style="font-size: 20px; font-weight: 700; font-style: italic;"> שלום '+$('fname').value+' '+$('lname').value+',</p>'
+'<p style="font-size: 16px; font-weight: 700;">אנחנו שמחים על הצטרפותך לאתר סטנדר!</p>'
+'<p style="font-size: 16px; font-weight: 700;">ברגעים אלו נשלח אישור על הרשמתך לכתובת הדוא"ל שהזנת בטופס ההרשמה.</p>'
+'<p style="font-size: 16px; font-weight: 700;">לסיום תהליך ההרשמה עליך ללחוץ על הקישור שקיבלת מאיתנו במייל.</p>'
+'<p style="font-size: 16px; font-weight: 700;">ברגע שחשבונך יאושר יתאפשר לך לכתוב ולהגיב בפורומים, וליהנות מכל השירותים הניתנים לחברי האתר.</p>'
+'<p style="font-size: 16px; font-weight: 700;">המשך גלישה נעימה!</p>'
+'<br><br><a href="#" onclick="document.getElementById(\'messg\').style.display=\'none\';history.go(-1)">חזרה לדף הקודם</a><br><br>';

$('outer').style.display="none";        		
        		
        		//$('messg').focus();
        		//$('messg').select();
        	}
        	        	
        }); 



}); 

function ajax_req() 
{  
 var action = $('subscript-form').get('action');
 //   alert("action="+action);
    new Request({
    url:'/includes/register.ajax.php',
	method: 'post',	
	evalScripts: true, // this is the default 
	onComplete: function(res){alert(res);}
}).send();

  
} 
var pwds_fill_check=function(el)
{
	el.errors = []; 
    el.isOk = true;
    var pwd=$(el.id).value;
	if(pwd.length<4)
	{
		 el.errors.push("נא להכניס סיסמה תקינה-לפחות 4 תווים"); 
         return false; 
	}	
	else
	return true;
}

var compare_pwds = function(el)
{ 
                 
     // block the default validates 
      el.errors = []; 
      el.isOk = true; 
                                 
                                 
      var pwd=$('passw').value;
      var pwd2=$('passw2').value;
                                 
      if(pwd!=pwd2)
      {
		el.errors.push(".אישור סיסמה חייב להיות זהה לסיסמה ראשונה<br>נא להכניס ערך תקין"); 
        return false; 
	  }	
	  else
		return true;
                                 
 }
 
 var is_gender=function(el)
 {
 	// block the default validates 
      el.errors = []; 
      el.isOk = true; 
      
 	if($('gender').value==0)
 	{
 	    el.errors.push(".שדה חובה-נא לציין את המין שלך"); 
        return false; 
	}	
	else
		return true;
 	
 }
 
 
 
