$("document").ready(function() {		
	$("#pollps").load("/poll/pollid.php?nocache="+Math.random(), function(r, estado, xhr) {
		$("#pollloading").hide();			
		if(estado == "error") {		
			$(this).html("Ha habido un error "+xhr.status+".<br />Si sigues viendo este error, contacta con el Webmaster.");
			return false;
		}
		else {				
			$("#formpoll input:radio").click(function() {								
				$("#formpoll input:submit").show("fast");
			});
			$("#formpoll").submit(function() {
				$("#pollps").hide();
				$("#pollloading").show();			
				var opt = parseInt($("#formpoll input:radio:checked").val());					
				if(typeof opt == "undefined" || isNaN(opt)) opt = 0;				
				$("#pollps").load("/poll/pollid.php?nocache="+Math.random(),{option: opt, botpoll: true}, function(r, estado, xhr) {
					$("#pollloading").hide();
					$("#pollps").fadeIn(1000);
					if(estado == "error") {		
						$(this).html("Ha habido un error "+xhr.status+".<br />Vuelve a intentarlo.");
						return false;
					}
					muestraVotos();
				});												
				return false;
			});
			muestraVotos();
		}
	});									
});
function muestraVotos() {
	$(".pollbar").mouseenter(function() {
		$(this).toggle();
		$(this).next().toggle();
	});
	$(".pollbarvots").mouseleave(function() {
		$(this).toggle();
		$(this).prev().toggle();
	});
}
