      var gRefer = parent.location.href;
                
      function checkemail(){
			var testresults;			
			var str=document.demo_account_form.email.value;
			var filter=/^(['_a-z0-9-+]+)(\.['_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/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 isNumeric(s) {
			if(s == null)
			return false;
		
			if(s.length == 0)
			return false;
		
			for(var i=0; i<s.length; ++i)
			{
				if("1234567890".indexOf(s.charAt(i)) < 0)
				{
					return false;
				}
			}
			return true;
			}
			
			function CheckCountry()
			{
				 if (document.demo_account_form.country.value == 'United Kingdom')
				 {
				 	window.location = "http://www.forex.com/forex_demo_account_uk.html";
				 }  
		  }
			
                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) || (isNumeric(document.demo_account_form.first_name.value)))   {
                        //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) || (isNumeric(document.demo_account_form.last_name.value))) {
                        //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 the user has entered a city   
                if (document.demo_account_form.city.value.length == 0)  {
									alert ("الرجاء أدخل ميدنتك");
                  document.demo_account_form.city.focus();                              
                  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;
			          }
                
                //trim leading and trailing spaces to help users with invalid emails
                document.demo_account_form.email.value = trim(document.demo_account_form.email.value);
                
                //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;
                }
                
                 document.demo_account_form.password.value = trim(document.demo_account_form.password.value);
						
			          if (document.demo_account_form.password.value.length < 4)  {
			          	//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 the password is alpha chars only
                if (isAlpha(document.demo_account_form.password.value)==false)
                {
                 	alert ("الرجاء الكتابة بالأحرف الانكليزية فقط من دون استعمال أرقام");
                 	document.demo_account_form.password.focus();
                	//and return false so the form doesn't get submitted
                  return false;
                }

                setwsEntityHigh("NA");
                return true;
     }