/*
  postZip() - validates a zip code and submits the form or displays an error
    Author: dbwhiz@hotmail.com
    Date: 2009-02-26
  Parameters:  zip (string)
*/
function postZip(zip) {
    var frm = document.forms.frmSearchProviders;
    if (zip != frm.txtZip.value) {
        frm.txtZip.value = zip;
    }
    frm.submit();    
}

/*
  postCounty() - submits the form for a county
    Author: dbwhiz@hotmail.com
    Date: 2009-02-26
  Parameters:  county (string)
*/
function postCounty(county) {
    var frm = document.forms.frmSearchProviders;
    
    frm.txtCounty.value = county;
    frm.submit();    
}

/*
  postEmail() - validates the input fields and submits the email form
    Author: dbwhiz@hotmail.com
    Date: 2009-02-26
*/
function postEmail() {
    var frm = document.forms.frmEmail;
    var bReturn = true;
    var sMessage = "";
    var sName = frm.txtName.value;
    var sEmail = frm.txtEmail.value;
    var sPhone = frm.txtPhone.value;
    
    // validate inputs
    if (sName == "") {
        sMessage = "Your name<br/>";
        bReturn = false;
    }
    
    if (sEmail == "" && sPhone.length == "") {
        sMessage += "An email address or phone number";
        bReturn = false;
    }        
    
    if (bReturn) {
        var selContact = document.all("selContactType");
        
        // change the email address if there is are options to change it
        if (selContact) {
            frm.txtTo.value = selContact.options(selContact.selectedIndex).id;    
        }
        frm.submit();    
    }
    else {
        document.all("tdInfo").innerHTML = "<h2>The following fields are required:</h2><br/>" + sMessage;
    }
        
}