document.write('<scr'+'ipt type="text/javascript" src="http://extra.mtv.it/gui/scripts/jQuery/jquery-1.3.2.min.js"></scr'+'ipt>')

//rollover lanci
if (window.addEventListener) 
	window.addEventListener('load', initRollover, false);
else if (window.attachEvent) //per ie
	window.attachEvent('onload', initRollover);

function initRollover() {
	var lancio = getElementsByClassName("lancio");
	
	for (var i=0; i < lancio.length; i++){
		lancio[i].onmouseover = on;
		lancio[i].onmouseout = off;
	}
	
	//mouseover
	function on() {
		a = this.getElementsByTagName("a");

		a[0].style.borderColor = "#ffffff";
		a[1].style.color = "#ffffff";
		if(a[2]!=null)
			a[2].style.color = "#ffffff";
	}
	
	//mouseout
	function off() {
		a = this.getElementsByTagName("a");
		
		a[0].style.borderColor = "#5491f3";
		a[1].style.color = "#5491f3";
		if(a[2]!=null)
			a[2].style.color = "#999999";
	}
}

/*==================================================================
	Submit ajax voto instantpoll
==================================================================*/
function submitVoto(){
	if(validate_form()){
		$.ajax({
			type: "POST",
			url: "vote_poll_ajax.asp",
			data: $(".instantPoll").serialize(),
			beforeSend: function(){
				$('.vota').hide();
				$('.loadingPool').show();
				$.post("resultsPoll.asp", function(risultati){
					$("#results").html(risultati);
				});
			},
			//Evento di riuscita
			success: function(response){
				if(response == "ok")
				{
					$(".instantPoll").hide();
					var larghezze = new Array();
					$("#results > li").each( function(index){	   
						larghezze[index] = $(this).find(".stat").css("width");	
						$(this).find(".stat").css({width:"0px"});
					});
					$("#results").fadeIn("slow");
					$("#results > li").each( function(index){								   
						$(this).find(".stat").animate( { width:"" + larghezze[index] + "" }, 1500);
					});
				}
				else
				{
					$('.instantPoll').fadeOut("slow");
					$('.error').fadeIn("slow");
				}	
			},
			//nel caso di errore
			error: function(){
				$('.instantPoll').fadeOut("fast");
				$('.error').fadeIn("fast");
			}
		 });
	}
}	
function validate_form(){
	var choose = false;
	$(".instantPoll input:checked").each(function(){
		choose = true;
	});
	if(choose){
		$(".vota").removeClass("noActive");
		$(".vota").addClass("active");
	} 
	else{
		$(".vota").removeClass("active");
		$(".vota").addClass("noActive");
	} 
	return choose;
}
function votaAncora(){
	$("#results").hide();
	$("#results").html("");
	$(".loadingPool").hide();
	$(".instantPoll").fadeIn("slow");
	$('.vota').fadeIn("slow");
}
