//initiate XMLHttpReguest

function changestatus(strURL){
    var xmlHttpReq = false;    var self = this;   
	// Mozilla/Safari
    if (window.XMLHttpRequest)
	  {
        self.xmlHttpReq = new XMLHttpRequest();
      }
    // IE
    else if (window.ActiveXObject)
	      {
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
          }
		  
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
	  {
        if (self.xmlHttpReq.readyState == 4)
		  {
           // updatepage(self.xmlHttpReq.responseText);
          }
      }
    self.xmlHttpReq.send(getquerystring());
  }


function xmlhttpPost(strURL,div,div2,message,sw)
  {
    var xmlHttpReq = false;
    var self = this;
      
    // Mozilla/Safari
    if (window.XMLHttpRequest)
	  {
        self.xmlHttpReq = new XMLHttpRequest();
      }
    // IE
    else if (window.ActiveXObject)
	  {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
      }
    
	self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
	  {
        if (self.xmlHttpReq.readyState == 4)
	      {
            if(sw)
			  {
			    updatepage(message+self.xmlHttpReq.responseText,div);		
			    if(div2!='')      		
			      updatepage(self.xmlHttpReq.responseText,div2);
			  }
		  }
      }
    self.xmlHttpReq.send(getquerystring());
  }
  


function getquerystring()
  {
  }

function updatepage(str,div)
  {
   document.getElementById(div).innerHTML = str;
  }

//some functions for other functions


function answer(question_id,answer) 
{
 // xmlhttpPost("q.php?question_id="+question_id+"&answer="+answer,'question','','',1);  
  id2=question_id;
  id2++;
  if(id2<25)
  {
    xmlhttpPost("q.php?question_id="+question_id+"&answer="+answer,'question','','',1); 	  
    document.getElementById("questionno").innerHTML="Question "+id2+" of 24 - Click the Correct Answer";
  }
  else
  {
    xmlhttpPost("e.php?question_id="+question_id+"&answer="+answer,'question','','',1);  	  
    document.getElementById("questionno").innerHTML="";
  }
}


function submitemail() {

  email=document.getElementById("email").value;
  state=document.getElementById("state").value;
  
  xmlhttpPost("sendemail.php?email="+email+"&state="+state,"submitemail",'','',1);    
}

