﻿// Contact Us JavaScript File

function cu_validatePage() {
    var errors = "";
    var form = document.forms[0];
    
    // Hide any existing errors
    jQuery("#contact_errors").hide();
    
    // Title
    if (jQuery("#ctl00_PHMainContent_ddTitle").val() == "0") {
        errors = errors + "* Please select your title.<br/>";
    }
    // First Name
    if (jQuery("#ctl00_PHMainContent_tbFirstname").val() == "") 
        errors = errors + "* Please enter your first name.<br/>";
    // Surname
    if (jQuery("#ctl00_PHMainContent_tbSurname").val() == "") 
        errors = errors + "* Please enter your surname.<br/>";
    // Email
    if (jQuery("#ctl00_PHMainContent_tbEmail").val() == "") {
        errors = errors + "* Please enter your email address.<br/>";
    } else if (!validateEmail(jQuery("#ctl00_PHMainContent_tbEmail").val())) {
        errors = errors + "* Please enter a valid email address.<br/>";
    }
    //Message
    if (jQuery("#ctl00_PHMainContent_tbMessage").val() == "") 
        errors = errors + "* Please enter your message.<br/>";
    // Privacy
    if (jQuery("input[@name='ctl00$PHMainContent$privacy']:checked").val() == "privacy_no") 
        errors = errors + "* You must agree to the sites Privacy Policy to continue.";
    
    // Any errors to show?
    if (errors.length > 0)
        jQuery("#contact_errors").html(errors).show();
    else
        form.submit();
}