// JavaScript Functions for contact page.

function contactUs() {
    hideAll();
    showDiv("sending");
    retrieveURLWithForm("/mi/contactUs.do","contact",contactUsResponse);
}

function contactUsResponse(response) {
    ajaxResponseChecks(response);
    hideAll();
    showDiv(ajax.result);
    if (ajax.result == "failure" || ajax.result == "invalid") {
        showDiv("security");
        showDiv("secureAndSend");
    }
    reloadSecurityImage();
}

function hideAll() {
    hideDiv("security");
    hideDiv("secureAndSend");
    hideDiv("failure");
    hideDiv("invalid");
    hideDiv("sending");
    hideDiv("success");
}

function showDiv(id) {
    document.getElementById(id).style.display = "block";
}

function hideDiv(id) {
    document.getElementById(id).style.display = "none";
}

function reloadSecurityImage() {
    var random = Math.random();
    document.getElementById("securityImage").src = "/mi/securityImage.do?random=" + random;
}
