﻿function warp(form) {

    if (form.jumpitem[form.jumpitem.selectedIndex].value == "none") return false;

    window.location = form.jumpitem[form.jumpitem.selectedIndex].value

    return false
}


function form_submit() {

    if (document.e_mail.firmname.value == "") {
        alert("You must complete the following field\nto process this form: Firm Name")
        document.e_mail.firmname.focus()
    } else if (document.e_mail.realname.value == "") {
        alert("You must complete the following field\nto process this form: Your Name")
        document.e_mail.realname.focus()
    } else if (!isEmail(document.e_mail.email.value)) {
        alert("You must use a valid e-mail address.\n\nExample: jsmith@microsoft.com")
        document.e_mail.email.focus()
    } else if (document.e_mail.address.value == "") {
        alert("You must complete the following field\nto process this form: Address")
        document.e_mail.address.focus()
    } else if (document.e_mail.city.value == "") {
        alert("You must complete the following field\nto process this form: City")
        document.e_mail.city.focus()
    } else if (document.e_mail.state.value == "") {
        alert("You must complete the following field\nto process this form: State")
        document.e_mail.state.focus()
    } else if (document.e_mail.zip.value == "") {
        alert("You must complete the following field\nto process this form: Zip Code")
        document.e_mail.zip.focus()
    } else if (document.e_mail.phone.value == "") {
        alert("You must complete the following field\nto process this form: Phone")
        document.e_mail.phone.focus()
    } else if (document.e_mail.fax.value == "") {
        alert("You must complete the following field\nto process this form: FAX")
        document.e_mail.fax.focus()
    } else {
        document.e_mail.submit();
    }
}


// Email address must be of form a@b.c
function isEmail(s) {

    if (isEmpty(s)) { return false; }

    // is s whitespace?
    if (isWhitespace(s)) { return false; }

    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@")) {
        i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != ".")) {
        i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


// Check whether string s is empty.
function isEmpty(s) {
    return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace(s) {
    var whitespace = " \t\n\r";
    var i;

    // Is s empty?
    if (isEmpty(s)) { return true; }

    // Search through characters one by one
    for (i = 0; i < s.length; i++) {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}