$(function(){
//posta
	$("h1").css("letter-spacing", "-1px");
	$("div#acorda-tv h1, div#podcasts .podcast h1, div.info h1").css("letter-spacing", "0");
	$("#btVotar").click(function() {
		if ($("[name=id_resposta]:checked").val() !=  undefined) {							  
			if (($("#id_enquete").attr("value") != '') && ($("#id_enquete").attr("value") !=  '<?=$_COOKIE["mairifm-enquete"]?>')) {
				$.ajax({
				type: "POST",
				url: "_inc/ajax_enquetes.php",
				data: $("form").serialize(),
				beforeSend: function(){
										$(".enquete").hide();
										$("#resultado").html('<table width="273" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle" height="220" ><img src="imagens/load.gif" width="32" height="32" /></td></tr></table>');
									},
				success: function(msg){
				$("#resultado").html(msg);
				$("form")[ 0 ].reset();
				}
				});
			} else {
				$("#mensagemVoto").slideDown(300,function(){
					setTimeout(function(){
						$('#mensagemVoto').slideUp(300);
					},2000);
				});
			}
		}else{
			$("#mensagemOpcao").slideDown(300,function(){
				setTimeout(function(){
					$('#mensagemOpcao').slideUp(300);
				},2000);
			});
		}
	});

	$("#btResultado").click(function(){
		$.ajax({
		type: "POST",
		url: "_inc/ajax_enquetes.php?acao=resultado",
		data: $("form").serialize(),
		beforeSend: function(){
								$(".enquete").hide();
								$("#resultado").html('<table width="273" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle" height="220" ><img src="imagens/load.gif" width="32" height="32" /></td></tr></table>');
							},
		success: function(msg){
		$("#resultado").html(msg);
		$("form")[ 0 ].reset();
		}
		});
	});
	
	// Fade out the suggestions box when not active
	 $("#busca").blur(function(){
	 	$('#suggestions').fadeOut();
	 });

});

function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}

function UR_Start(){
	UR_Nu = new Date;
	//UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
	UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes());
	document.getElementById("ur").innerHTML = UR_Indhold;
	setTimeout("UR_Start()",1000);
}

/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
google.setOnLoadCallback(function()
{
	// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard
		'-webkit-box-shadow' : '#888 5px 10px 10px', // Safari
		'-moz-box-shadow' : '#888 5px 10px 10px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);

});

function lookup(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		$.post("/rpc.php", {s: ""+inputString+""}, function(data) {
			if(data!=''){
			// Do an AJAX call
				$('#suggestions').fadeIn(); // Show the suggestions box
				$('#suggestions').html(data); // Fill the suggestions box
			}else{
				$('#suggestions').hide();
			}
		});
	}
}

function abre_pop(pagina,largura,altura) {
	w = screen.width;
	h = screen.height;
	
	meio_w = w/2;
	meio_h = h/2;
	
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;
	
	window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+''); 
}

function trocaTamanhoMais(elemento) {
	var elemento = document.getElementById(elemento);
	var tamanho = elemento.style.fontSize;
	if (tamanho == '14px')
		elemento.style.fontSize = '18px';
}


 function trocaTamanhoMenos(elemento) {
	var elemento = document.getElementById(elemento);
	var tamanho = elemento.style.fontSize;
	if (tamanho == '18px')
		elemento.style.fontSize = '14px';
	
}
