                var gRefer = parent.location.href;		
		
		function checkemail(){
			var testresults;			
			var str=document.demo_account_form.email.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(str))
				testresults=true
			else				
				testresults=false				
			return (testresults)			
			}
			
		function trim(s) {
  			while (s.substring(0,1) == ' ') {
    			s = s.substring(1,s.length);
  			}
  			while (s.substring(s.length-1,s.length) == ' ') {
    			s = s.substring(0,s.length-1);
  			}
  			return s;
			}
			
		function isAlpha(s) {
			if(s == null)
			return false;
		
			if(s.length == 0)
			return false;
		
			for(var i=0; i<s.length; ++i)
			{
				if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".indexOf(s.charAt(i)) < 0)
				{
					return false;
				}
			}
			return true;
			}
	
		
                function ValidateForm(){
      				
			          //now verify the form fields
						
			                  //make sure that the first name is not blank.
                        if (document.demo_account_form.first_name.value.length == 0)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Пожалуйста, впишите ваше имя");
                                document.demo_account_form.first_name.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }
                                
                        //make sure that the last name field is not blank.
                        if (document.demo_account_form.last_name.value.length == 0)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Пожалуйста, впишите вашу фамилию");
                                document.demo_account_form.last_name.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }

                        //make sure that the country field is not blank.
                        if (document.demo_account_form.country.value.length == 0)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Пожалуйста, впишите страну, в которой вы живете");
                                document.demo_account_form.country.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                        //make sure that the phone field is not blank.
                        if (document.demo_account_form.phone.value.length < 6)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Пожалуйста, впишите ваш номер телефона");
                                document.demo_account_form.phone.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                        //make sure that the email field is not blank.
                        if (document.demo_account_form.email.value.length == 0)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Пожалуйста, впишите ваш адрес электронной почты");
                                document.demo_account_form.email.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                        //make sure the email address is formatted properly
                        if (checkemail()==false)
                        {
                        	alert ("Пожалуйста, проверьте ваш адрес электронной почты, он неправильный");
                        	document.demo_account_form.email.focus();
                        	//and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                        var emailtest = trim(document.demo_account_form.password.value);
												
												if (emailtest.length < 3)  {
													//it isn't so show the user an alert and go to that field
													alert ("Пожалуйста, впишите пароль, который состоит не меньше чем из 4 символов");
													document.demo_account_form.password.focus();
													//and return false so the form doesn't get submitted
      									                          
													return false;
												}
												
												//make sure that the password field is in English characters
			                  if (document.demo_account_form.password.value.length > 3)  {
			                  	//it's a valid length, so let's validate it
			                  	//define valid characters
			                  	var valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
			                  	var string=document.demo_account_form.password.value;									
			                  	for (var i=0; i< string.length; i++) {
                         				if (valid.indexOf(string.charAt(i)) == -1)
                         				{
                         					alert ("Пожалуйста используйте Англоязычные буквы для Вашего пароля");
                         					document.demo_account_form.password.focus();
                         					return false;       					
    	                  			  }    				
    	                  	}
    	                  }       
                        
                        //make sure the user has picked a referrer
                        if ((document.demo_account_form.hear_about.selectedIndex == 0) || (document.demo_account_form.hear_about.selectedIndex == 1))
                        {
                                //if statement failed so ask the user to pick one!
                                alert ("Пожалуйста, скажите нам от куда вы о нас узнали");
                                document.demo_account_form.hear_about.focus();
                                //and return false so the form doesn't get submitted                                
                                return false;
                        }	
                        
                        //make sure the user has checked a forex experience box
												if ((document.demo_account_form.forex_experience[0].checked == false) && (document.demo_account_form.forex_experience[1].checked == false) && (document.demo_account_form.forex_experience[2].checked == false) && (document.demo_account_form.forex_experience[3].checked == false))
												{
													//Trading information needs to be selected
													alert ("Выберите уровень опыта");
													document.demo_account_form.forex_experience[0].focus();
													//and return false so the form doesn't get submitted				
                        	return false;
                        }
                        
                        return true;
                				}
