var xmlhttp = false;

// check of we are using IE
try {
    // if the javascript version is greater than 5
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    // if not, then user older active x object.
    try {
        // if we are using IE
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(E) {
        // Else we must be using a non IE browser
        xmlhttp = false;
    }
}

// if we are using a non IE browser, create a Javascript instance of the object
if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
}

function makerequest(serverPage, objID) {

        var obj = document.getElementById(objID);
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                obj.innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null);
}

function postrequest(serverPage, objID) {

        var obj = document.getElementById(objID);
        xmlhttp.open("GET", serverPage + '?q=' + document.mailForm.q.value + '&user=' + document.mailForm.user.value);
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                obj.innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null);
}

function showForm() {

    var showForm = document.getElementById("mailForm").style.visibility;

    if(showForm == "hidden") {
        document.getElementById("mailForm").style.visibility = "visible";
    } else {
        document.getElementById("mailForm").style.visibility = "hidden";
    }
}

function closeForm() {

    if(document.getElementById("mailForm").style.visibility == 'hidden') {
        document.getElementById("mailForm").style.visibility = 'visible';
    } else {
        document.getElementById("mailForm").style.visibility = 'hidden';
    }
}
