var intervalo = window.setInterval(function() {
	$("div#locutor").html("<img src='images/ajax_load_snake.gif' />").fadeOut("fast");
	$("div#locutor").load("views/locutor.php div#locutor").fadeIn("slow");
}, 1800000);
var mostraLoad = function(id)
{
	$("#"+id).html("<img src='images/ajax_load_snake.gif' />").fadeIn("fast");    
}
var escondeLoad = function(id)
{
	$("#"+id).html("<img src='images/ajax_load_snake.gif' />").fadeOut("fast");
}
var cache = [];
var preLoadImages = function() {
	var args_len = arguments.length;
	for (var i = args_len; i--;) {
		var cacheImage = document.createElement('img');
		cacheImage.src = arguments[i];
		cache.push(cacheImage);
	}
}
$(document).ready(function(){
	$("div#locutor").html("<img src='images/ajax_load_snake.gif' />").fadeOut("fast");
	$("div#locutor").load("views/locutor.php div#locutor").fadeIn("slow");
	$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	$('#galeriaFotos').jcarousel({visible: 8});	
	$("#enquete").load('views/enquete.php');
	$("#enqResultado").live("click", function() {
		$.ajax({ 
			url: "views/enquete.php",
			type: "GET",
			beforeSend: mostraLoad('enquete'),
			data: 'resultado=true',
			cache: false,
			success: function(conteudo){
			  $('#enquete').html(conteudo);
			}
		});
	});
	$("#enqVoltar").live("click", function() {
		$.ajax({ 
			url: "views/enquete.php",
			type: "GET",
			beforeSend: mostraLoad('enquete'),
			cache: false,
			success: function(conteudo){
			  $('#enquete').html(conteudo);
			}
		});
	});
	$("#enqAtualizar").live("click", function() {
		$.ajax({ 
			url: "views/enquete.php",
			type: "GET",
			beforeSend: mostraLoad('enquete'),
			cache: false,
			success: function(conteudo){
			  $('#enquete').html(conteudo);
			  $("#enqAtualizar").attr("disabled", "disabled");
			  alert('Aguarde 30 segundos para atualizar novamente a enquete.');
			  setTimeout(function(){ $("#enqAtualizar").attr("disabled", false); }, 30000);
			}
		});
	});
	var config = {    
		sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
		interval: 1, // number = milliseconds for onMouseOver polling interval    
		over: makeTall, // function = onMouseOver callback (REQUIRED)    
		timeout: 500, // number = milliseconds delay before onMouseOut    
		out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	$('.topMusicas li').hoverIntent(config);

});
function makeTall(){ 
	$('.topMusicas li').animate({"height":40}, { queue: false, duration: 50 });
	$('.topMusicas li').removeClass("destaque");
	$(this).animate({"height": 65},{ queue: false, duration: 50 });
	$(this).addClass("destaque");
}
function makeShort(){ return true; }

var abreChat = function (url) {
	window.open('inc/chat.html', 'ChatZonaDez', 'width=868, height=577');
}
var janela = {
	parent:"body",
	windowId:null,
	titulo:null,
	url:null,
	width:null,
	height:null,
	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i");
		if (document.cookie.match(re))
			return document.cookie.match(re)[0].split("=")[1];
		return null;
	},
	setCookie:function(name, value){
		document.cookie = name + "=" + value + "; path=/";
	},	
	close:function()
	{
		$("#"+this.windowId+"_janela").remove();
		janela.setCookie(this.windowId, 0);
	},
	open:function()
	{
		janela.setCookie(this.windowId, 1);
		var id = janela.getCookie(this.windowId);
		if(id)
			janela.close();
		var modal = "";
		modal += "<div id=\"" + this.windowId + "_janela\" class=\"modal-window\" style=\"display:none; width:" + this.width +"px; height:" + (this.height + 50) +"px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += "<div align='center' class='modaltitulo'>" + this.titulo + "<a class=\"close-window\" title=\"Fechar Janela\"></a></div><iframe frameborder='0' name='" + this.windowId + "'  id='" + this.windowId + "' src='" + this.url + "' width='" + this.width + "' height='" + this.height + "' style='margin-top: 10px;'> </iframe>";
		modal += "</div>";
		$(this.parent).append(modal);
		$(".close-window").click(function(){janela.close();});
		$(".modal-window").draggable();
		$(".modal-window").show();
	}
};

var redimensiona = function(div, multiplicador)
{
	$("#"+div).css("font-size", (parseFloat($("#"+div).css("font-size")) + multiplicador) + "px");
};

var enviaRecado = function()
{
	janela.windowId = "Recado";
	janela.titulo = "Envie já seu Recado!";
	janela.width = 360;
	janela.height = 320;
	janela.url = "inc/envia_recado.php";
	janela.open();
};

var interatividade = function(id)
{
	janela.windowId = "interatividade";
	janela.titulo = "Interatividade!";
	janela.width = 390;
	janela.height = 300;
	janela.url = "inc/interatividade.php?tipo="+id;
	janela.open();
};

var comentarNoticia = function(id)
{
	janela.windowId = "comentar";
	janela.titulo = "Comentar Notícia!";
	janela.width = 405;
	janela.height = 370;
	janela.url = "inc/comentar.php?id="+id;
	janela.open();
};

var abreGaleria = function(id)
{
	janela.windowId = "galeria";
	janela.titulo = "Galeria de Fotos!";
	janela.width = 680;
	janela.height = 410;
	janela.url = "inc/galeria.php?id="+id;
	janela.open();
};
var af = function(id)
{
	$("#"+id).toggle("slow");
};
function sizeIFrame() {
	var helpFrame = jQuery("#ifrm");
	var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
	helpFrame.height(innerDoc.body.scrollHeight + 35);
}
/*
ddaccordion.init({
	headerclass: "headerbar", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "mouseover", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: true, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){
	},
	onopenclose:function(header, index, state, isuseractivated){
	}
});
ddaccordion.init({
	headerclass: "headerbar2", //Shared CSS class name of headers group
	contentclass: "submenu2", //Shared CSS class name of contents group
	revealtype: "mouseover", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: true, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){
	},
	onopenclose:function(header, index, state, isuseractivated){
	}
});

var af = function(id)
{
	$("#"+id).toggle("slow");
};

var fa = function(id,id2)
{
	if($("#"+id).is(":hidden"))
	{
		$("#"+id).show("slow");
		$("#"+id2).text("Esconder");
	}else{
		$("#"+id).hide("slow");
		$("#"+id2).text("Mostrar");
	}
};*/