function loadcaptcha() {
var imagenumber = 1;
var theImage;
var hResult;

imagenumber = Math.round(Math.random()*10);
theImage = document.getElementById('captchaimage');
hResult = document.getElementById('hCaptcha');

switch (imagenumber)
{
	case 1:
		theImage.src='/images/captcha/cap1.jpg'
		hResult.value = '71817'
		break
	case 2:
		theImage.src='/images/captcha/cap2.jpg'
		hResult.value = '82273'
		break
	case 3:
		theImage.src='/images/captcha/cap3.jpg'
		hResult.value = '97277'
		break
	case 4:
		theImage.src='/images/captcha/cap4.jpg'
		hResult.value = '28366'
		break
	case 5:
		theImage.src='/images/captcha/cap5.jpg'
		hResult.value = '29678'
		break
	case 6:
		theImage.src='/images/captcha/cap6.jpg'
		hResult.value = '36715'
		break
	case 7:
		theImage.src='/images/captcha/cap7.jpg'
		hResult.value = '39164'
		break
	case 8:
		theImage.src='/images/captcha/cap8.jpg'
		hResult.value = '47355'
		break
	case 9:
		theImage.src='/images/captcha/cap9.jpg'
		hResult.value = '64558'
		break
	case 10:
		theImage.src='/images/captcha/cap10.jpg'
		hResult.value = '67912'
		break
	default:
		theImage.src='/images/captcha/cap1.jpg'
		hResult.value = '71817'
		
}
}


function Validator(theForm)
{

  if (theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"LastName\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"LastName\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"LastName\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.Street.value == "")
  {
    alert("Please enter a value for the \"Street\" field.");
    theForm.Street.focus();
    return (false);
  }

  if (theForm.Street.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Street\" field.");
    theForm.Street.focus();
    return (false);
  }

  if (theForm.Street.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Street\" field.");
    theForm.Street.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.ZipCode.value == "")
  {
    alert("Please enter a value for the \"ZipCode\" field.");
    theForm.ZipCode.focus();
    return (false);
  }

  if (theForm.ZipCode.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"ZipCode\" field.");
    theForm.ZipCode.focus();
    return (false);
  }

  if (theForm.ZipCode.value.length > 12)
  {
    alert("Please enter at most 12 characters in the \"ZipCode\" field.");
    theForm.ZipCode.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }
  
  return checkcaptcha();
  
}



function checkcaptcha(){
	var capInput
	var hResult
	var Result
	
	capInput = document.getElementById('captcha')
	hResult = document.getElementById('hCaptcha')
	
	Result = parseInt(hResult.value) + 10
	
	
	if (capInput.value==Result.toString()) {
	return true;
	}else{
	alert("You have entered the wrong code!");
	return false;	
	}

}

