function xmlhttpPost() {
    var strURL = "/cgi-bin/mailer.pl";
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['join_mailing_list'];
    var firstName = form.first_name.value;
    var surname = form.surname.value;
    var postcode = form.postcode.value;
    var email = form.email.value;
    var howDidYouHear = form.how_did_you_hear.value;
    var other = form.other.value;
    
    qstr = 'fn=' + escape(firstName) +
           '&sn=' + escape (surname) +
           '&pc=' + escape (postcode) +
           '&em=' + escape (email) +
           '&hw=' + escape (howDidYouHear) +
           '&ot=' + escape (other);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str){
    document.getElementById("form").innerHTML = str + " <input class='btn' type='button' name='ok' value='OK' onClick='hm(&#39;bx&#39;)'>";
}
