// JavaScript Document

// This script will detect to see if the user is using Internet Explorer, if they are a popup message will come up saying whatever you like.

// This script has been created by Jack Day!

																				// The code from this line
function getXMLHTTPRequest()
{
var req = false;
try
  {
    req = new XMLHttpRequest(); /* e.g. Firefox */
  }
catch(err1)
  {
  try
    {
     req = new ActiveXObject("Msxml2.XMLHTTP");
  /* some versions IE */
    }
  catch(err2)
    {
    try
      {
       req = new ActiveXObject("Microsoft.XMLHTTP");
  /* some versions IE */
      }
      catch(err3)
        {
         req = false;
        }
    }
  }
return req;
}

var myRequest = getXMLHTTPRequest();											// To this line is basicallly creating the HTTPRequest Object


// Now we start the fun bit!


// The name field
function callName() {
	var nameField = document.getElementById("nameField").value;					// Get the value of Name
	
	var myRandom=parseInt(Math.random()*99999999);								// add a random number on the url so browser doesnt get confused
	var url = "_php/_ajax/_name.php?name=";									// This is the main URL

	myRequest.open("GET", url + nameField+ "&rand=" + myRandom, true);			// Open the request
	myRequest.onreadystatechange = responseName;								// When we get a responsewe execute the function  responseName
	myRequest.send(null);														// Send NULL
}

function responseName() {
	if (myRequest.readyState<4) {
		document.getElementById("outputName").innerHTML = '';
	} else {
		document.getElementById("outputName").innerHTML = myRequest.responseText;
	}
}

// The email field
function callEmail() {
	var emailField = document.getElementById("emailField").value;				// Get the value of Name
	
	var myRandom=parseInt(Math.random()*99999999);								// add a random number on the url so browser doesnt get confused
	var url = "_php/_ajax/_email.php?email=";									// This is the main URL

	myRequest.open("GET", url + emailField+ "&rand=" + myRandom, true);			// Open the request
	myRequest.onreadystatechange = responseEmail;								// When we get a responsewe execute the function  responseName
	myRequest.send(null);														// Send NULL
}

function responseEmail() {
	if (myRequest.readyState<4) {
		document.getElementById("outputEmail").innerHTML = '';
	} else {
		document.getElementById("outputEmail").innerHTML = myRequest.responseText;
	}
}


// The comments field
function callComments() {
	var commentsField = document.getElementById("commentsField").value;			// Get the value of Name
	
	var myRandom=parseInt(Math.random()*99999999);								// add a random number on the url so browser doesnt get confused
	var url = "_php/_ajax/_comments.php?comments=";						// This is the main URL

	myRequest.open("GET", url + commentsField+ "&rand=" + myRandom, true);		// Open the request
	myRequest.onreadystatechange = responseComments;								// When we get a responsewe execute the function  responseName
	myRequest.send(null);														// Send NULL
}

function responseComments() {
	if (myRequest.readyState<4) {
		document.getElementById("outputComments").innerHTML = '';
	} else {
		document.getElementById("outputComments").innerHTML = myRequest.responseText;
	}
}






// The NEWSLETTER
function callNewsletter() {
	var newsletterField = document.getElementById("newsletterField").value;			// Get the value of Name
	
	var myRandom=parseInt(Math.random()*99999999);								// add a random number on the url so browser doesnt get confused
	var url = "_php/_ajax/_newsletter.php?email=";						// This is the main URL

	myRequest.open("GET", url + newsletterField+ "&rand=" + myRandom, true);		// Open the request
	myRequest.onreadystatechange = responseNewsletter;								// When we get a responsewe execute the function  responseName
	myRequest.send(null);														// Send NULL
}

function responseNewsletter() {
	if (myRequest.readyState<4) {
		document.getElementById("outputNewsletter").innerHTML = "Loading...";
	} else {
		document.getElementById("outputNewsletter").innerHTML = myRequest.responseText;
	}
}

