var flag;
var chk_map;
var counter=0;
function sendRequest(url,params,HttpMethod) {
	if(!HttpMethod) { HttpMethod="GET"; }
	req=null;
	if(window.XMLHttpRequest){req=new XMLHttpRequest; }
	else if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP");} 
		if(req) {req.onreadystatechange=onReadyState;req.open(HttpMethod,url,true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.send(params);}} 


    
		function onReadyState() { var ready=req.readyState;var data=null;if(ready==4){
		data=req.responseText;
		
		if(flag==2){
			var pointDiv = document.getElementById('load');
   pointDiv.style.visibility = 'hidden';
   pointDiv.style.display = 'none';
				var El = document.getElementById('result');
				El.innerHTML=data;
				//window.setTimeout('getdata()',5000);
				}

if(flag==3){
				var El = document.getElementById('polling');
				El.innerHTML=data;
				//window.setTimeout('getdata()',5000);
				}
			}
			}
		function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
	}  
function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function getdata(){

var pointDiv = document.getElementById('load');
   pointDiv.style.visibility = 'visible';
   pointDiv.style.display = 'block';

	for (var i=0; i < document.opinion.radio1.length; i++)
   {
   if (document.opinion.radio1[i].checked)
      {
      var radio1 = document.opinion.radio1[i].value;
      }
   }

	var id=document.opinion.id.value;

	flag=2;
	var sss=0;
	var vik=new Date();
	
	sendRequest('graph.jsp?flag='+flag+'&vik='+vik+'&radio1='+radio1+'&id='+id);
	
}

function getpoll(){

	
	flag=3;
	var sss=0;
	var vik=new Date();
	
	sendRequest('poll.jsp?flag='+flag+'&vik='+vik);
	
}

/*function checkForm(){
	var radio_choice = false; 
	for (counter=0;counter<opinion.radio1.length; counter++)
	{
		if (opinion.radio1[counter].checked)
			radio_choice = true;
		
		} 
		if (!radio_choice) { 
			alert('Please select an option!!!');
			return(false);
			}
			return (true);			
			} */

		
			
			
function aaaa() { 
	
getdata();


		}