
var xmlHttp

function GetPoll(thisform)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/polls/polls.asp";
var formdata="";
//url=url+"?q="+str;
//get selected item
var pollChoice
if (thisform!=null) {
	for (i=0; i < thisform.length; i++){
	     //Build Send String
         if(thisform.elements[i].type == "text"){ //Handle Textbox's
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "textarea"){ //Handle textareas
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "checkbox"){ //Handle checkbox's
                 formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].checked + "&";
         }else if(thisform.elements[i].type == "radio"){ //Handle Radio buttons
                  if(thisform.elements[i].checked==true){
                     formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].value + "&";
                  }
         }else{
                  //finally, this should theoretically this is a select box.
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         } 	
	}
	//pollChoice = thisform.pollChoice.value;
	//alert (formdata);
	//alert (document.getElementById("pollChoice").value);
}
//url=url+"?pollChoice="+pollChoice;
//url=url+"?sid="+Math.random();

xmlHttp.onreadystatechange=stateChanged;
//xmlHttp.open("GET",url,true);
//xmlHttp.send(null);
//Make connection
    xmlHttp.open("POST", url);
    //Set Headers
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //Send data
    xmlHttp.send(formdata);
    //stops form from submitting normally
    return false;
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		if(xmlHttp.status==200)
		{
			var response = xmlHttp.responseText;
			document.getElementById("polls").innerHTML=response;
			document.getElementById("polls").setfocus;
		} else {
			alert("A problem occurred with communicating between "+
				  "the XMLHttpRequest object and the server program.");
		}
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


