// JavaScript Document
function createRequestObject() {

   var req;

   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      alert('Problem creating the XMLHttpRequest object');
   }

   return req;

} 

// Make the XMLHttpRequest object
var http = createRequestObject(); 

function sendRequest(varPage,varString, vResponce) {
//sendRequest('desired page', 'variables to pass to page', function for handling responce);

   // Open PHP script for requests
   //http.abort;
   http.open('post', varPage);
   http.onreadystatechange = vResponce; 
   http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   http.send(varString);

}


function refresh()
{
	window.location.reload( false );
}

/* ####################### AJAX Responce Functionc #########################*/

function handleResponse() {

   if(http.readyState == 4 && http.status == 200){

      // Text returned FROM the PHP script
      var response = http.responseText;

      if(response) {
         // UPDATE ajaxTest content
         //document.getElementById("ajaxTest").innerHTML = response;
		 alert(response);
		 refresh();
      }

   }

}

function signupResponce(){
	
	   if(http.readyState == 4 && http.status == 200){

      // Text returned FROM the PHP script
      var response = http.responseText;

      if(response) {
		//change the contents of the form to thank the user for 		
		/* Change the from to a thank you */
		document.getElementById('sgnpfrm').innerHTML = "<div align='center'><br>Thank you for your interest in the Tour de PEI.</div>";
				
      }

   }
	
}

/* ####################### END AJAX Responce Functionc #########################*/
