/*
 *	Simple validation to check for empty required fields
 *	Uses an AJAX call to validate the CAPTCHA security image
 */
function chkShortFrm() {
    // validate the security code
    var code_entered = $('security_code').value;
    var url = 'validate_captcha.php?c=' + code_entered;
    var form_valid = true;
    
    new Ajax.Request(url, {
      method: 'get',
      asynchronous: false,
      onSuccess: function(transport) {
        if (transport.responseText == "valid") {
            if(document.qwik_contact.f_name2.value == "") {
                alert("Please provide your first name.");
                document.qwik_contact.f_name2.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.l_name.value == "") {
                alert("Please provide your last name.");
                document.qwik_contact.l_name.focus();
                form_valid = false;
            }
			if(form_valid && document.qwik_contact.Teen.value =="") {
				alert("Please provide your teen's name.");
				document.qwik_contact.Teen.focus();
				form_valid = false;
			}
			if(form_valid && document.qwik_contact.Age.value =="") {
                alert("Please provide your teen's age.");
                document.qwik_contact.Age.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.Address.value == "") {
                alert("Please provide your street address.");
                document.qwik_contact.Address.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.City.value == "") {
                alert("Please provide your city.");
                document.qwik_contact.City.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.State.value == "") {
                alert("Please provide your state.");
                document.qwik_contact.State.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.Zip.value == "") {
                alert("Please provide your zip code.");
                document.qwik_contact.Zip.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.Phone.value == "") {
                alert("Please provide your contact phone number.");
                document.qwik_contact.Phone.focus();
                form_valid = false;
            }
            if(form_valid && document.qwik_contact.EmailAddress.value == "") {
                alert("Please provide your email address.");
                document.qwik_contact.EmailAddress.focus();
                form_valid = false;
            }
        } else {
            alert('The security code you entered is incorrect.  Please re-enter the security code and try again.  Please note that the security code is case-sensitive.');
            $('security_code').value = "";
            $('security_code').style.backgroundColor = "#D22";
            $('security_code').style.color = "#FFF";
            $('security_code').focus();
            form_valid = false;
        }
      },
      onFailure: function() {
          alert('Failed to validate security code.  Please try again.');
          form_valid = false;
      }
    });
    return form_valid;
}

function chkLongForm() {
    // validate the security code
    var code_entered = $('security_code').value;
    var url = 'validate_captcha.php?c=' + code_entered;
    var form_valid = true;
    
    new Ajax.Request(url, {
      method: 'get',
      asynchronous: false,
      onSuccess: function(transport) {
        if (transport.responseText == "valid") {
            //nothing to do, it's validated
        } else {
            alert('The security code you entered is incorrect.  Please re-enter the security code and try again.  Please note that the security code is case-sensitive.');
            $('security_code').value = "";
            $('security_code').style.backgroundColor = "#D22";
            $('security_code').style.color = "#FFF";
            $('security_code').focus();
            form_valid = false;
        }
      },
      onFailure: function() {
          alert('Failed to validate security code.  Please try again.');
          form_valid = false;
      }
    });
    return form_valid;
}

