var request;
var queryString; //will hold the POSTed data
function sendData(url) {
 //var url="email.php";
 httpRequest("POST",url,true);
}
 
/* Initialize a Request object that is already constructed
reqType: The HTTP request type such as "GET" or "POST." 
url: The URL of the server program.
isAsynch: Whether to send the request asynchronously or not. */
function initReq(reqType,url,isAsynch){
 /* Specify the function that will handle the HTTP response */
 request.onreadystatechange=handleResponse;
 request.open(reqType,url,isAsynch);
 /* set the Content-Type header for a POST request */
 request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
 request.send(queryString);
}
 
/* Wrapper function for constructing a Request object.
 Parameters:
 reqType: The HTTP request type such as GET or POST.
 url: The URL of the server program.
 asynch: Whether to send the request asynchronously or not. */
 
function httpRequest(reqType,url,asynch){
 //Mozilla-based browsers
 if(window.XMLHttpRequest) {
  request = new XMLHttpRequest();
  initReq(reqType,url,asynch);
 } else if (window.ActiveXObject) {
  request=new ActiveXObject("Msxml2.XMLHTTP");
  if (! request) {
   request=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(request) {
  initReq(reqType,url,asynch);
  /* Unlikely to branch here, as IE uses will be able to use either 
  one of the constructors*/
  } else {
  alert("Your browser does not permit the use of all "+"of this application's features!");}
 } else {
  alert("Your browser does not permit the use of all "+"of this application's features!");}
}
 
//event handler for XMLHttpRequest
function handleResponse(){
 if(request.readyState == 4) {
  if(request.status == 200) {
   //document.getElementById('result').innerHTML=request.responseText;
    document.getElementById('display1').innerHTML = request.responseText;
  } else {
   alert("A problem occurred with communicating between "+"the XMLHttpRequest object and the server program.");
  }
 }//end outer if
}
 
 
 
function setQueryString(div,ID){
 //initialize the top-level variable; also reset the variable to cover when
 //the user clicks multiple times
 
  queryString="";
  
  var frm = document.getElementById(div);
  var numberElements = frm.elements.length;
  for(var i = 0; i < numberElements; i++) {
   if(frm[i].type=="radio") {
    if(frm[i].checked) {
     queryString = "pollAnswer="+frm.elements[i].value+"&pollId="+ID;
    }
 
   }
  }
  

 
 
 
}


