function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function validate_step1(step1) {
	if(step1.type_domain.value == "") {
		alert("Please select a domain type.");
		step1.type_domain.focus();
		return false;
	}
	else if(step1.domain_name.value == "" && step1.new_domain_name.value == "") {
		alert("Please enter your domain name.");
		return false;
	}
	else { return true; }
}

function validate_step2(step2) {
	if((step2._ci_first_name.value.length < 2 || step2._ci_last_name.value.length < 2) && step2._ci_company.value.length < 2) {
		alert("Please enter you first and last name or business name.");
		step2._ci_first_name.focus();
		return false;
	}
	
	else if(step2._ci_email.value.indexOf(" ") != -1 )
		{
			alert('Please check your email address. Email cannot contain spaces.');
			step2._ci_email.focus();
			return false;
		}
	else if(step2._ci_email.value.indexOf("@")<1 || step2._ci_email.value.lastIndexOf(".")-step2._ci_email.value.indexOf("@") <2)
		{
			alert('Please check the entered Email Address! Email must contain and @ sign!');
			step2._ci_email.focus();
			return false;
		}
	else if(step2._ci_address1.value.length < 3) {
		alert('Please enter your full address');
		step2._ci_address1.focus();
		return false;
	}
	else if(step2._ci_city.value.length < 2) {
		alert('Please provide your city name.');
		step2._ci_city.focus();
		return false;
	}
	else if(step2._ci_state.value == "") {
		alert('Please choose a state or indicate you are International.');
		step2._ci_state.focus();
		return false;
	}
	else if(step2._ci_postal_code.value.length < 5 || !IsNumeric(step2._ci_postal_code.value)) {
		alert('Please enter a valid postal code.');
		step2._ci_postal_code.focus();
		return false;
	}
	else if(step2._ci_phone.value.length < 10) {
		alert('Please enter a valid phone number.');
		step2._ci_phone.focus();
		return false;
	}
	else if(step2.login.value.length < 5 || step2.login.value.length > 20) {
		alert('Your username must be at least 4 characters and 20 characters maximum.');
		step2.login.focus();
		return false;
	}
	else if(step2.password.value != step2.password2.value) {
		alert('Password mismatch.  Please re-enter your passwords.');
		step2.password.focus();
		return false;
	}
	else if(step2.password.value.length < 6) {
		alert('Password must contain at least 6 characters and at least 1 letter and 1 number or symbol.');
		step2.password.focus();
		return false;
	}
	else if(step2._eul.checked) { return true; }
	else { 
		alert('You must agree with our Terms of Service to continue.');
		step2._eul.focus();
		return false;
	}
}


function validate_step3(step3) {
	if((step3._bi_first_name.value.length < 2 || step3._bi_last_name.value.length < 2) && step3._bi_company.value.length < 2) {
		alert("Please enter you first and last name or business name.");
		step3._bi_first_name.focus();
		return false;
	}
	
	else if(step3._bi_email.value.indexOf(" ") != -1 )
		{
			alert('Please check your email address. Email cannot contain spaces.');
			step3._bi_email.focus();
			return false;
		}
	else if(step3._bi_email.value.indexOf("@")<1 || step3._bi_email.value.lastIndexOf(".")-step3._bi_email.value.indexOf("@") <2)
		{
			alert('Please check the entered Email Address! Email must contain and @ sign!');
			step3._bi_email.focus();
			return false;
		}
	else if(step3._bi_address1.value.length < 3) {
		alert('Please enter your full address');
		step3._bi_address1.focus();
		return false;
	}
	else if(step3._bi_city.value.length < 2) {
		alert('Please provide your city name.');
		step3._bi_city.focus();
		return false;
	}
	else if(step3._bi_state.value == "") {
		alert('Please choose a state or indicate you are International.');
		step3._bi_state.focus();
		return false;
	}
	else if(step3._bi_postal_code.value.length < 5 || !IsNumeric(step3._bi_postal_code.value)) {
		alert('Please enter a valid postal code.');
		step3._bi_postal_code.focus();
		return false;
	}
	else if(step3._bi_phone.value.length < 10) {
		alert('Please enter a valid phone number.');
		step3._bi_phone.focus();
		return false;
	}
	else if(step3._bi_type.value == "CC" && step3._bi_cc_number.value.length < 16) {
		alert('Please enter your credit card number.');
		step3._bi_cc_number.focus();
		return false;
	}
	else { return true; }
}

