﻿/************************************************************************************************************
 * Document Ready
 ***********************************************************************************************************/

$(document).ready(function() {
    $("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_SubmitButton").attr("disabled", false);
	$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_name").focus();
});

/************************************************************************************************************
 * Validation
 ***********************************************************************************************************/

/*$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_SubmitButton").click(function() {
    $("form#aspnetForm").submit(validateForm);
});*/

function validateForm()
{
    $("#input-error").hide();

    var name = RequiredFieldValidator("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_name");
    var email = ValidateEmail("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_email");
    var type = RequiredFieldValidatorSelect("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_type");
    var subject = RequiredFieldValidator("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_subject");
    var message = RequiredFieldValidator("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_message");
    var captcha = RequiredFieldValidator("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_captcha");
    
    var valid = name && email && type && subject && captcha;
    
    if (!valid)
        $("#input-error").show();
    
    return valid;
}

/************************************************************************************************************
 * On Focus
 ***********************************************************************************************************/

 $("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_name").focus(function() {
    StatusMessage(true, this, "Please provide your first and last name.", "Message");
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_email").focus(function() {
    StatusMessage(true, this, "Please provide a real email address so we can contact you if a reply is required.", "Message");
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_type").focus(function() {
    StatusMessageSelect(true, this, "Please select the best type that applies to your reason for contact.", "Message");
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_subject").focus(function() {
    StatusMessage(true, this, "Please enter a subject that applies to your reason for contact.", "Message");
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_message").focus(function() {
    StatusMessage(true, this, "Please enter your message in full detail.", "Message");
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_captcha").focus(function() {
    StatusMessage(true, this, "Verification that you are human and not a robot.", "Message");
});

/************************************************************************************************************
 * On Blur
 ***********************************************************************************************************/

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_name").blur(function() {
    RequiredFieldValidator(this);
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_email").blur(function() {
    ValidateEmail(this);
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_type").blur(function() {
    RequiredFieldValidatorSelect(this);
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_subject").blur(function() {
    RequiredFieldValidator(this);
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_message").blur(function() {
    RequiredFieldValidator(this);
});

$("#ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_captcha").blur(function() {
    RequiredFieldValidator(this);
});