/* ---------------------------- */
/* 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();

/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */

/*add new country*/
function rld() {
document.location.reload()
}

var nocache = 0;
function contactLEGACY() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('contactLEGACY_response').innerHTML = "Working...";
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var action= encodeURI(document.getElementById('action').value);
var cName= encodeURI(document.getElementById('cName').value);
var cEmail = encodeURI(document.getElementById('cEmail').value);
var cPhone = encodeURI(document.getElementById('cPhone').value);
var cCountry = encodeURI(document.getElementById('cCountry').value);
var cComment = encodeURI(document.getElementById('cComment').value);
// Set te random number to add to URL request
nocache = Math.random();
if((cName!="")&&(cEmail!=""))
{
// Pass the login variables like URL variable
http.open('get', 'emailer.php?a='+action+'&cName='+cName+'&cEmail='+cEmail+'&cPhone='+cPhone+'&cCountry='+cCountry+'&cComment='+cComment+'&nocache='+nocache);
http.onreadystatechange = contactLEGACYReply;
http.send(null);
url="contactus.html";
setTimeout( "location.href=url", 3000 );
}
 else {
 var thiserror=1;
 http.open('get', 'emailer.php?a='+action+'&e='+thiserror+'&nocache = '+nocache);
 http.onreadystatechange = contactLEGACYReply;
 http.send(null);
 }
}

function contactLEGACYReply() {
if(http.readyState == 4){
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('contactLEGACY_response').innerHTML = response;
}
}