Event.observe(window,'load',startPoll);

	function startPoll(){		
		
		new Ajax.Request("/lib/polls/sbpoll.asp",
		{	
			method: 'post', 
			parameters: "",
			evalScripts: true,
			onComplete: function(requester){	
				var txt = requester.responseText;		
				txt = txt.replace("{{titoloBlocco}}", titoloBox);			
				if (txt.indexOf('@@@2@@@')>=0){
					//popup					
					getPopup(txt);					
				}else{	
					//fascia							
					$('boxSondaggio').innerHTML = txt;		
				}
				return;
			}
		});		
	}
	
	
	function checkV(f){
	
		for (i=0;i < f.idrisposta.length;i++){
			if (f.idrisposta[i].checked){
				sSend = true;
				break;
			}else{
				sSend = false;
			}
		}

		if (sSend == true){
			var params = getParams(f) ;		
			var url	= f.action;						
			new Ajax.Request(url,
			{	
				method: 'post', 
				parameters: params,
				evalScripts: true,
				onComplete: function(requester){					
					var txt = requester.responseText;		
					txt = txt.replace("{{titoloBlocco}}", titoloBox);				
					if (txt.indexOf('@@@2@@@')>=0){
						//popup						
						getPopup(txt);								
					}else{	
						//fascia							
						$('boxSondaggio').innerHTML = txt;		
					}
					return;
				}
			});	
		}else{
			alert("scegliere una delle risposte disponibili");
		}
	}

	
	
	function gotoRisultati(f){

		f.azione.value='risultati'; 		
	
		var params = getParams(f) ;		
		var url	= f.action;				
		new Ajax.Request(url,
		{	
			method: 'post', 
			parameters: params,
			evalScripts: true,
			onComplete: function(requester){					
				var txt = requester.responseText;		
				txt = txt.replace("{{titoloBlocco}}", titoloBox);				
				if (txt.indexOf('@@@2@@@')>=0){
					//popup
					getPopup(txt);
				}else{	
					//fascia							
					$('boxSondaggio').innerHTML = txt;		
				}

				return;
			}
		});	
	
	}
	
	
	function removeBoxPoll(){
		if ($('boxSondaggioPop')!=null){
			$('boxSondaggioPop').remove();
		}
		if ($('TotalFadePoll')!=null){
			$('TotalFadePoll').remove();
		}
	}	
	
	
	function chiudiPop(f){

		f.azione.value='NOvoto'; 			
		var params = getParams(f) ;		
		var url	= f.action;			
		new Ajax.Request(url,
		{	
			method: 'post', 
			parameters: params,
			evalScripts: true,
			onComplete: function(requester){					
				removeBoxPoll();
				//$('boxSondaggioPop').remove();
				return;
			}
		});	
	
	}


	function getPopup(htmlTxt){
		removeBoxPoll();
		new Insertion.Top($('frameBox'),htmlTxt);	
		return(document.body.down());		
	}


	
	
	function myEncode(str){		
		var strRet = str;		
		if ((str == "") || (str==null)){
			strRet = str;
		}else{
			strRet = encodeURIComponent(str);
		}
		return strRet;
	}



	function Sel()
	{
		document.form_poll.idrisposta[form_poll.idrisposta.length-1].checked = true;
	}




