/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */

function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();
var nocache = 0;
function show_state() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('state_display').innerHTML = "Wait..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var industs = encodeURI(document.getElementById("indust").value);
var monthselect = encodeURI(document.getElementById("selectmonth").value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'second_state.php?industs='+industs+'&monthselect='+monthselect+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){ 
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('state_display').innerHTML = ''+response;
}
}
