﻿// JScript File

// Removes leading whitespaces
function LTrim(value) {

    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim(value) {

    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function trim(value) {

    return LTrim(RTrim(value));

}

function quick_submit() {
    var txtName = document.getElementById("ctl00_Navigation_Vertical_Right1_Quick_Contact1_txtName");
    var txtEmail = document.getElementById("ctl00_Navigation_Vertical_Right1_Quick_Contact1_txtEmail");
    var validation_summary = "Please complete and answer the required fields:\n";
    if (trim(txtName.value) == "") {
        validation_summary = validation_summary + "Full Name\n";
    }

    if (trim(txtEmail.value) == "") {
        validation_summary = validation_summary + "E-mail\n";
    }
    else {
        retxtname = new RegExp(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
        if (!(retxtname.test(trim(txtEmail.value)))) {
            validation_summary = validation_summary + "E-mail address is not valid\n";
        }
    }
    if (validation_summary == "Please complete and answer the required fields:\n") {
        return true;
    }
    else {
        alert(validation_summary);
        return false;
    }
}
