function clearfield(id) {
    if (id.value == "Your email") {
        id.value = "";
        id.style.color = "black";
    }
}
var url = "sendmail.php?email=";
function handleHttpResponse() {
    if (http.readyState == 4) {
        if (http.status == 200) {
            var results = http.responseText;
            document.getElementById('SubscriptionResult').innerHTML = results;
        }
    }
}

function requestSubscription() {
    var email = document.getElementById("email");

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email.value)) {
        alert('Please provide a valid email address.');
        email.focus
        return false;
    } else {

        http.open("GET", url + escape(email.value), true);
        http.onreadystatechange = handleHttpResponse;
        http.send(null);
    }
}
function getHTTPObject() {
    var xmlhttp;

    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        if (!xmlhttp) {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }

    }
    return xmlhttp;
}
var http = getHTTPObject();

function showSubscriptionForm() {
            document.getElementById('SubscriptionResult').innerHTML = 'Be informed about OraSentry version updates: <input type="text" value="Your email" id="email" name="email" onclick="return clearfield(this);" /><input type="button" style="color:black;" value="Subscribe" onclick="requestSubscription();" />';
}
window.onload = showSubscriptionForm;

