 // ------------------------------------------ funkce pro anketu
        function send_xmlhttprequest(obsluha, method, url, content, headers) 
            { 
              var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false)); 
              if (!xmlhttp) { return false; } 
              xmlhttp.open(method, url); 
              xmlhttp.onreadystatechange = function() 
              { obsluha(xmlhttp); }; 
              if (headers) { 
                for (var key in headers) { 
                  xmlhttp.setRequestHeader(key, headers[key]); 
                } 
              } 
              xmlhttp.send(content); 
              return true; 
            } 
             
        function anketa_hlasovat(formular,id_anketa){ 
              // odeslání požadavku na aktualizaci dat
			  var id_odpoved;
			  id_odpoved="";
			  for (i=0;i<=4;i++){
				  if (formular.anketa[i].checked) {id_odpoved="A"+(i+1);}
			  }
			  
			  if (id_odpoved=="") {
			  	alert ("CHYBA: vyberte prosím alespoň jednu možnost!");
				return true;
			  }else{
				  if (!send_xmlhttprequest(anketa_obsluha, 'GET', 'anketa_hlasuj.asp?id_anketa=' + id_anketa+'&id_odpoved='+id_odpoved)) { return false; } 
        	      document.getElementById('q_status').innerHTML = 'Probíhá hlasování'; 
            	  return true; 
				}
         } 
            
        function anketa_obsluha(xmlhttp) { 
             if (xmlhttp.readyState == 4) { 
                 //aktualizace odpovědí na základě aktuálního stavu  
                var odpovedi = xmlhttp.responseXML.getElementsByTagName('odpoved');
                var status = xmlhttp.responseXML.getElementsByTagName('anketa');
                
                if (status[0].getAttribute('status_text')=="ok") {
					document.getElementById('q_status').innerHTML = "Děkujeme za hlas.";
					for (var i=0; i < odpovedi.length; i++) { 
						if (odpovedi[i].getAttribute('lenght')!=0){
					  		document.getElementById("anketa_"+(i+1)).className = "hidden";
							document.getElementById("hlasuj").className = "hidden";
							document.getElementById("hlasuj_line").className = "hidden";
							document.getElementById("anketa_graf"+(i+1)).style.width = odpovedi[i].getAttribute('lenght')+"px" ; 
							document.getElementById("anketa_procenta"+(i+1)).innerHTML = odpovedi[i].firstChild.data+"%";
						}
                	}
					
                }else{
					document.getElementById('q_status').innerHTML = "V této anketě jste již hlasoval.";
				}
				
              } 
        } 

   