var time_variable;
 
function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object
 
function ajaxPostSubmit() {
  var getdate = new Date();  //Used to prevent caching during ajax call
  
  if(xmlhttp) {
	var polltext = document.getElementById("polltext");
	var user_name = document.getElementById("user_name");
	var user_email = document.getElementById("user_email");
	var question_id = document.getElementById("question_id");
	var user_cap = document.getElementById("user_cap");
	
		
    xmlhttp.open("POST","../../jtabs/polltest.php",true); //calling testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send("polltext=" + polltext.value + "&user_name=" + user_name.value + "&user_email=" + user_email.value + "&question_id=" + question_id.value + "&user_cap=" + user_cap.value);
    
	// xmlhttp.send("polltext=" + polltext.value); //Posting txtname to PHP File
	// xmlhttp.send("&user_name=" + user_name.value);
	// xmlhttp.send("&user_email=" + user_email.value);
  }
  document.getElementById("PollCommentsCont2").innerHTML = "";
}
 
function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("PollDynamic").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}

function swapCaptcha()
{
	$("captcha").src = "../../poll_captcha.php?"+(new Date()).getTime();
}

function showComInputs()
{
document.getElementById("comment_input1").style.visibility = "visible";
document.getElementById("comment_input2").style.visibility = "visible";
}
