function prefillForm(skip,focusField)
{
        // Some forms skip the form altogether if the same form has already been filled out
        if (skip) return;
        
        // These always there
        $("#firstName")[0].value = form$firstName;
        $("#lastName")[0].value = form$lastName;
        $("#email")[0].value = form$email;
        $("#phone")[0].value = form$phone;
        
        // These may or may not be
        if ($("#companyName").length>0) $("#companyName")[0].value = form$companyName;
        if ($("#city").length>0) $("#city")[0].value = form$city;
        // Must handle state and country differently
        if ($("#state").length>0) {
                sel = $("#state")[0];
                for (i=0; i<sel.options.length; i++) {
                        if (sel.options[i].text.toLowerCase() == form$state.toLowerCase()) {
                            sel.selectedIndex = i;
                                break;
                        }
                }
        }
        if ($("#country").length>0) {
                sel = $("#country")[0];
                for (i=0; i<sel.options.length; i++) {
                        if (sel.options[i].text.toLowerCase() == form$country.toLowerCase()) {
                            sel.selectedIndex = i;
                                break;
                        }
                }
        }
        if ($("#totalDesktops").length>0) $("#totalDesktops")[0].value = form$totalDesktops;
        
        if (focusField != null) {
                $(focusField).focus();
        }
}

// Form validation - VPA/Email
function validateForm1()
{
   
    // Field name & description
    var required = new Array("vpa|VPA number","email|E-mail");
        
    var s = "";
    var t;
    
    // Keep track of which was the first missing so focus can be placed there
    //var firstMissing = "";
    var firstMissing = null;

    // For all these required fields ...    
    for (var i=0; i<required.length; i++) {
        t = required[i].split('|');
        if (document.support_login[t[0]].value.length==0) {
            s += '   ' + t[1] + '\n';
            //if (firstMissing.length==0) firstMissing = t[0];
            if (firstMissing==null) firstMissing = document.support_login[t[0]];
        }
    }
   
    // Any any missing, alert the user and cancel the form submission
    if (s.length != 0) {
        alert('One or more required fields were not specified:\n' + s +
              'Please supply the missing information and resubmit the form.');
        if (firstMissing != null) {
            firstMissing.focus();
        }
        //if (firstMissing.length != 0) {
        //    document.support_login[firstMissing].focus();
        //}
        return false;
    }
    
    // Here's a MUCH more exhaustive e-mail address check courtesy of coveryourasp.com that uses
    // regular expression pattern matching. Portions (c) James Shaw - james@CoverYourASP.com
    var em = document.support_login.email.value;
    if (em.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) == -1) {
        alert('Please verify your e-mail address for correct syntax.');
        document.support_login.email.focus();
        return false;
    }

    return true;
}

// Form validation - VPA/Email/Name/Phone/Company
function validateForm2()
{
   
    // Field name & description
    var required = new Array("vpa|VPA number","name|Name",
    "companyName|Company","email|E-mail","phone|Phone");
        
    var s = "";
    var t;
    
    // Keep track of which was the first missing so focus can be placed there
    //var firstMissing = "";
    var firstMissing = null;

    // For all these required fields ...    
    for (var i=0; i<required.length; i++) {
        t = required[i].split('|');
        if (document.support_login[t[0]].value.length==0) {
            s += '   ' + t[1] + '\n';
            //if (firstMissing.length==0) firstMissing = t[0];
            if (firstMissing==null) firstMissing = document.support_login[t[0]];
        }
    }

    // Any any missing, alert the user and cancel the form submission
    if (s.length != 0) {
        alert('One or more required fields were not specified:\n' + s +
              'Please supply the missing information and resubmit the form.');
        if (firstMissing != null) {
            firstMissing.focus();
        }
        return false;
    }
    
    // Here's a MUCH more exhaustive e-mail address check courtesy of coveryourasp.com that uses
    // regular expression pattern matching. Portions (c) James Shaw - james@CoverYourASP.com
    var em = document.support_login.email.value;
    if (em.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) == -1) {
        alert('Please verify your e-mail address for correct syntax.');
        document.support_login.email.focus();
        return false;
    }

    return true;
}

// Form validation - Email/Name/ESM product & version/Problem (this is for the request for support form)
function validateForm3()
{
   
    // Field name & description
    var required = new Array("name|Name","email|E-mail","problem|Problem Description");
        
    var s = "";
    var t;
    
    // Keep track of which was the first missing so focus can be placed there
    //var firstMissing = "";
    var firstMissing = null;

    // For all these required fields ...    
    for (var i=0; i<required.length; i++) {
        t = required[i].split('|');
        if (document.support_login[t[0]].value.length==0) {
            s += '   ' + t[1] + '\n';
            //if (firstMissing.length==0) firstMissing = t[0];
            if (firstMissing==null) firstMissing = document.support_login[t[0]];
        }
    }
        
        // Check the two required dropdowns
        var sel = document.support_login["esmProd"];
        if (sel.options[sel.selectedIndex].text == "") {
                s += '   Express Product\n';
        if (firstMissing==null) firstMissing = sel;
        }
        sel = document.support_login["esmVer"];
        if (sel.options[sel.selectedIndex].text == "") {
                s += '   Product Version\n';
        if (firstMissing==null) firstMissing = sel;
        }

    // Any any missing, alert the user and cancel the form submission
    if (s.length != 0) {
        alert('One or more required fields were not specified:\n' + s +
              'Please supply the missing information and resubmit the form.');
        if (firstMissing != null) {
            firstMissing.focus();
        }
        return false;
    }
    
    // Here's a MUCH more exhaustive e-mail address check courtesy of coveryourasp.com that uses
    // regular expression pattern matching. Portions (c) James Shaw - james@CoverYourASP.com
    var em = document.support_login.email.value;
    if (em.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) == -1) {
        alert('Please verify your e-mail address for correct syntax.');
        document.support_login.email.focus();
        return false;
    }

    return true;
}


