var xmlhttp
function updatedpolls(myid){
	
	
var r=confirm("Are you sure? your want to delete")
if (r==true)
  {
 // alert("You pressed OK!")
  }
else
  {
  return false;
  }	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  
  
var url="deletepolls.php";
url=url+"?deletedid="+myid;


xmlhttp.onreadystatechange=deletepolllists;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
}



function adminupdatedpolls(myid){
var r=confirm("Save your selection?")
if (r==true)
  {
 // alert("You pressed OK!")
  }
else
  {
  return false;
  }	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  
  
var url="deletepolls.php";
url=url+"?updatepolls="+myid;


xmlhttp.onreadystatechange=deletepoll;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
}






function addingmyvalues(){
var question=document.getElementById("question").value;
var first=document.getElementById("question1").value;
var second=document.getElementById("question2").value;
var third=document.getElementById("question3").value;
var fourth=document.getElementById("question4").value;



if((document.myindexform.question.value=="Enter question here") ||(document.myindexform.question.value=="")) {
		alert("Enter question here");
		document.myindexform.question.value="";
		document.myindexform.question.focus();
		return false; 
	}
	else if((document.myindexform.answerone1.value=="Enter first answer here") ||(document.myindexform.answerone1.value=="")){
		alert("Enter first answer here");
		document.myindexform.answerone1.value="";
		document.myindexform.answerone1.focus();
		return false;
	}
	else if((document.myindexform.answertw02.value=="Enter second answer here") ||(document.myindexform.answertw02.value=="")){
		alert("Enter second answer here");
		document.myindexform.answertw02.value="";
		document.myindexform.answertw02.focus();
		return false;
	}
	else if((document.myindexform.answerthree3.value=="Enter third answer here") ||(document.myindexform.answerthree3.value=="")){
		alert("Enter third answer here");
		document.myindexform.answerthree3.value="";
		document.myindexform.answerthree3.focus();
		return false;
	}


xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="myquestionadding.php";
url=url+"?question="+question.replace(/\?/,"QueANDstion")+"&first="+first.replace(/\?/,"QueANDstion")+"&second="+second.replace(/\?/,"QueANDstion")+"&third="+third.replace(/\?/,"QueANDstion")+"&fourth="+fourth.replace(/\?/,"QueANDstion");
url=url+"&sid="+Math.random();

//xmlhttp.onreadystatechange=addedsuccess;
//xmlhttp.open("POST",url,true);
//xmlhttp.send(null);
}



function showCustomer(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="newquestions.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=statemychanges;
xmlhttp.open("GET",url,true);
shog();
xmlhttp.send(null);
}


function shog(){
	 document.getElementById("poimage").style.display="";
	}



function hng(){
		 document.getElementById("poimage").style.display="none";
	}



function statemychanges()
{
if (xmlhttp.readyState==4)
  {
  
     
  
  document.getElementById("mainContainer").innerHTML=xmlhttp.responseText;
  hng();
  }
}



function deletepolllists(){
	
	if (xmlhttp.readyState==4)
  {
	window.location="polls.php";
  }
	
	
}




function deletepoll(){
	
	if (xmlhttp.readyState==4)
  {
	var mySplitResult = xmlhttp.responseText.split(",");
	document.getElementById(mySplitResult[0]).innerHTML=mySplitResult[4];
    document.getElementById(mySplitResult[1]).innerHTML=mySplitResult[5];
    document.getElementById(mySplitResult[2]).innerHTML=mySplitResult[6];
    document.getElementById(mySplitResult[3]).innerHTML=mySplitResult[7];
  }
	
	
}


function addedsuccess()
{
if (xmlhttp.readyState==4)
  {
	 
	  
	 //document.getElementById("mainContainer").innerHTML=xmlhttp.responseText;
  document.getElementById("mainContainer").innerHTML=xmlhttp.responseText;
  
  //mainContainer
  //document.
  }
}






function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
