function Validatevote () {
      var form = document.getElementById("vote_form");
      for ( var i = 0; i < form.length; i++ ) {
      if ( form[i].checked ){var check=form[i].value;
      break;}}
var ar = new Array();
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var xx=xmlhttp.responseText;
ar=xx.split("^");
var titel=ar[0];var ok=ar[1];var no=ar[2];var idont=ar[3];var widthok=ar[4];var widthno=ar[5];var widthidont=ar[6];var num=ar[7];
if(num<=0){widthok=0;widthno=0;widthidont=0;}else{widthok= Math.round(widthok*100/num);
widthno= Math.round(widthno*100/num);
widthidont= Math.round(widthidont*100/num);}
document.getElementById('voteshow').innerHTML=titel+'<br><label dir="ltr">'+widthok+'%&nbsp;&nbsp;'+ok+'</label><br><img border="0" src="pic/yes.gif" width="'+widthok+'%" height="7"><br><label dir="ltr">'+widthno+'%&nbsp;&nbsp;'+no+'</label><br><img border="0" src="pic/no.gif" width="'+widthno+'%" height="7"><br><label dir="ltr">'+widthidont+'%&nbsp;&nbsp;'+idont+'</label><br><img border="0" src="pic/idont.gif" width="'+widthidont+'%" height="7"><br><img border="0" src="pic/1.png" width="56" height="24" onclick="back()">';}}
xmlhttp.open("GET","votescript.php?test=vote&u="+check+"&sid="+Math.random(),true);
xmlhttp.send();
  return false;};
function result () {
var ar = new Array();
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var xx=xmlhttp.responseText;
ar=xx.split("^");
var titel=ar[0];var ok=ar[1];var no=ar[2];var idont=ar[3];var widthok=ar[4];var widthno=ar[5];var widthidont=ar[6];var num=ar[7];
if(num<=0){widthok=0;widthno=0;widthidont=0;}
else{widthok= Math.round(widthok*100/num);
widthno= Math.round(widthno*100/num);
widthidont= Math.round(widthidont*100/num);}
 document.getElementById('voteshow').innerHTML=titel+'<br><label dir="ltr">'+widthok+'%&nbsp;&nbsp;'+ok+'</label><br><img border="0" src="pic/yes.gif" width="'+widthok+'%" height="7"><br><label dir="ltr">'+widthno+'%&nbsp;&nbsp;'+no+'</label><br><img border="0" src="pic/no.gif" width="'+widthno+'%" height="7"><br><label dir="ltr">'+widthidont+'%&nbsp;&nbsp;'+idont+'</label><br><img border="0" src="pic/idont.gif" width="'+widthidont+'%" height="7"><br><img border="0" src="pic/1.png" width="56" height="24" onclick="back()">';}}
xmlhttp.open("GET","votescript.php?test=result&sid="+Math.random(),true);
xmlhttp.send();
  return false;};
function back () {
var ar = new Array();
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var xx=xmlhttp.responseText;
ar=xx.split("^");
var titel=ar[0];var ok=ar[1];var no=ar[2];var idont=ar[3];
document.getElementById('voteshow').innerHTML='<form id="vote_form">'+titel+'<br><label dir="rtl"><input type="radio" value="yes" name="vote">'+ok+'</label><br><label dir="rtl"><input type="radio" value="noo" name="vote">'+no+'</label><br><label dir="rtl"><input type="radio" value="idont" name="vote">'+idont+'</label><br><input type="image" border="0" src="pic/3.png" width="56" height="22" onclick="return Validatevote()"><input type="image" border="0" src="pic/2.png" width="56" height="22" onclick="return result()"></form>';}}
xmlhttp.open("GET","votescript.php?test=result&sid="+Math.random(),true);
xmlhttp.send();};

