//SISTEMA DE LOGIN
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){
/*abertura do jquery iniciando a leitura */

var senha=$("#senha"); /*pego o id do campo senha*/
var divlogin=$("#divlogin");
var loading=$("#loading");
   
$("#form").submit(function () { return false; });
/*deaabilito o submit d form*/

$("#login").blur(function() {
	/*o blur no campo login*/
	var login = $("#login").val();
	
	/*pega o valor no campo tipo o que cara digitou  */
		if(login!="") {
			/*se o campo login for diferente de vazio eu desabilto o campo senha*/
			senha.attr({disabled:''});
			/*aqui eu estou desabilitado o campo senha*/
        } else {
			//aviso.fadeIn("show");
			/*se o campo login estive vazio eu mostro o campo vazio que la em cima estava oculto */
			
			$("#form").addClass("current").effect(function() { $(this).removeClass("current"); });
			/*balanca o formulario e um efeito padrao  */
		}/*fechou o else :D*/
});
/*fechou a funcao do login*/


senha.blur(function() {
	var senha = $("#senha").val();
	/*o valor do campo senha*/
	var login = $("#login").val();
	/*pega o valor do login */
	
if(senha=="") {
	/*ser senha for igual a vazio*/
    									// aviso2.fadeIn("slow");
	/*exibo o campo do aviso */
	$("#form").addClass("current").effect(function() { $(this).removeClass("current"); });
	/*balanca o formulario e um efeito padrao  */
} 

else {

divlogin.fadeIn("slow");
loading.html('<img src="img/icones/loading.gif"> <br> <b>Aguarde...</b>').fadeIn("slow");
/*exibi o loading de validando o usuario  */

$.post("valida.login.php",{login:login,senha:senha}, function(data){
/*enviar por post o login e  a senha para a pagina ver.php */
var retorno = data;

	/*criei uma variavel chamada  retorno e peguei o retornou de data  */
	if(retorno) {
	/*se retornou algo que no caso eu espero senha invalida :D  */
	alert("Não encontramos nenhum usuário com as informações informadas! Por favor tente novamente!");divlogin.fadeOut(2000);
	$("#login").attr("value", ""); 
	$("#senha").attr("value", ""); 
	
	/*exibi o aviso com a senha invalida*/
	} else {
	 /*senao como nao retornou nada
	 so lembrando que na pagina  ver.php eu ja criei uma sessao :D */
	 
	 divlogin.fadeIn("slow").addClass("divlogin");
	 loading.html('<img src="img/icones/loading.gif"> <br> <b>Aguarde...</b>').fadeIn("slow");
	 
	 /*informou no loading que a senha passou */
	 
	 setTimeout("location.href='index.php'",2000);
	 /*aguarde um instante ja vai ser redirecionado para a pagina viu.php com o texto  911
	 lembrando que isso e a sessao criada no php */
     
}
    /*fechou o else */
}
/*fechou o segundo else */
)};
	  /*fechou a fucnao data aquela que pega os dados dos post */

});
/*fechar a funcao do blur da senha */


$("#filtro").click(function () {
      $("#div_topo").slideToggle("normal");
    });
	
	$("#filtroartigos").click(function () {
      $("#filtroartigosabre").slideToggle("normal");
    });
	
	
	$("#maisvideo").click(function () {
      $("#maisvideos").slideToggle("normal");
    });


	//Select all anchor tag with rel set to tooltip
	$('a[rel=videos]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});
	//Select all anchor tag with rel set to tooltip
	
	//Select all anchor tag with rel set to tooltip
	$('a[rel=eventosanime]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});
	//Select all anchor tag with rel set to tooltip
	
	
	//Select all anchor tag with rel set to tooltip
	$('a[rel=artigos]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});
	//Select all anchor tag with rel set to tooltip
	
	
	//Select all anchor tag with rel set to tooltip
	$('a[rel=outros]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});
	//Select all anchor tag with rel set to tooltip


});
/*fechou a leitura do jquery*/


$(function() {
    $(".anyClass").jCarouselLite({
		visible: 1,
		auto: 6000,
		speed: 700,
        btnNext: ".next",
        btnPrev: ".prev",
		circular: true
    });
});

$(function() {
	$(".publicidade").jCarouselLite({
		visible: 3,
		auto: 1500,
		speed: 400,
		btnNext: ".sobe",
		btnPrev: ".desce",
		vertical: true
	});
});

// COLORBOX
//exemplos:
// ABAIXO
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//This hides the inline content if JavaScript is supported.
document.write("<style type='text/css'>.hidden{display:none;}<\/style>");

$(document).ready(function(){
//Examples of Global Changes
$.fn.colorbox.settings.bgOpacity = "0.3";

/*
//Examples of how to assign the ColorBox event to elements.
$("a[rel='jack']").colorbox({transition:"fade"});
$(".colorbox").colorbox({transition:"none", fixedWidth:"75%",fixedHeight:"75%", initialWidth:"75%", initialHeight:"75%"});
*/

$("a[rel='artigos']").colorbox({transition:"elastic", contentCurrent:"{current} / {total}"});
$("a[title='verobras']").colorbox();
$("a[rel='impressao']").colorbox({fixedWidth:"80%", fixedHeight:"70%", iframe:true});
$("a[rel='textos']").colorbox({fixedWidth:"60%", fixedHeight:"50%", iframe:true});
$("a[rel='eventosanime']").colorbox({fixedWidth:"60%", fixedHeight:"60%", iframe:true});
$("a[rel='videos']").colorbox({fixedWidth:"570px", fixedHeight:"550px", iframe:true});

$("a[rel='painelnoticias']").colorbox({fixedWidth:"80%", fixedHeight:"80%", iframe:true});
$("a[rel='painelartigos']").colorbox({fixedWidth:"80%", fixedHeight:"80%", iframe:true});
$("a[rel='painelvideos']").colorbox({fixedWidth:"80%", fixedHeight:"80%", iframe:true});
$("a[rel='paineleventos']").colorbox({fixedWidth:"80%", fixedHeight:"80%", iframe:true});

/*
$("#flash").colorbox({href:"../content/flash.html"});
$("a[href='http://google.com']").colorbox({fixedWidth:"80%", fixedHeight:550, iframe:true});
$("#inline").colorbox({fixedWidth:"50%", inline:true, href:"#inline_example"});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){ 
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
});
*/
});

// SLIDE IMAGENS
//EXEMPLO DE COMO USAR
//<div id="menu">
//<div>Item 1</div>
//<div>Item 2</div>
//<div>Item 3</div>
//<div>Item 4</div>
//</div>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var currentItem = null;
var undoTimerHodler = false;
$(document).ready(
	function()
	{
		$('#menu div')
			.bind('mouseover', doItem);
		$('#menu')
			.bind('mouseout', undoItem);
	}
);
function doItem()
{
	if(undoTimerHodler)
		window.clearTimeout(undoTimerHodler);
	if(currentItem) {
		$(currentItem).animate({width: 100}, 200);
	} else {
		$('#menu div').not(this).animate({width: 100}, 200);
	}
	currentItem = this;
	$(currentItem).animate({width: 170}, 200);
}
function undoItem()
{
	undoTimerHodler = window.setTimeout(undoTimer, 100);
}
function undoTimer()
{
	$('#menu div').animate({width: 119}, 200);
	currentItem = null;
}

function cChange(div,clas) {
	var a = div.split(',');
	for(x=0;x<=a.length-1;x++) {
	document.getElementById(a[x]).className = clas;
	}
}

function ajaxLink(div,pag) {
	$.get(pag,{qazc:'1'}, function(retorno){ $("#"+div).html(retorno); });
}

function changeBox(div,pag,tel) {
	$.get(pag,{tela:tel}, function(retorno){ $("#"+div).html(retorno); });	
}

function abreDiv(dv) {
	$("#"+dv).slideToggle();
}

function SetF(id, vv) {
	try { $(id)[0].type; }
	catch(e) {return}
	if(!$(id)[0].type) {
		var type = $("input[@name="+id.replace("#","")+"]")[0].type;
		var o = $("input[@name="+id.replace("#","")+"]");
	} else {
		var type = $(id)[0].type;
		var o = $(id);
	}
	if(typeof vv == "string" || typeof vv == "number"){
		v = []; 
		v.push(vv); 
	}
	else v = vv;
	switch(type) {
		case "radio":
		case "checkbox":
		case "select-multiple":
		case "select-one":
				o.val(v);
				break;
		default:
			o.val(v.join(','));
	}
}

function UnSetF(slist) {
	var l = slist.split(',');
	for(var i=0; i < l.length; i++)	{
		SetF(l[i],'');
	}
}

function check_recover(oque) {
	if($("#fldEmail").val()=='') { 
	   $("#msgErro").html('Preencha seu e-mail');
	   return false;
	} else if(CheckMail($("#fldEmail").val())) {
		$("#msgErro").html('Preencha seu e-mail, corretamente');
		return false;
	} else {
		$("#fldSubmit").val("Enviando...");
		$("#fldSubmit").attr("disabled",true);
		$.get("_ajaxPeG.php",{tela:oque,email:$("#fldEmail").val()}, function(retorna){ $("#fldEmail").val(""); $("#fldSubmit").val("Enviar"); $("#fldSubmit").attr("disabled",false);  if(retorna==1) { $("#msgErro").html('Foi enviado um e-mail contendo seus dados!'); } else { $("#msgErro").html('Este e-mail não foi encontrado, verifique!'); } });
		return false;
	}
}

function menuhome(pag) {
	$("#menuhome").slideToggle();
	$("#flecha").html('Aguarde, Carregando...');
	$.get(pag,{qazc:'1'}, function(retorno){ $("#menuhover").html(retorno); 
																  $("#flecha").html('<img src="images/content/icones/16-arrow-down.png" width="16" height="16" />');
																  });
}

function ajaxLink(div,pag) {
	$("#carregaload").fadeIn("slow");
	$.get(pag,{qazc:'1'}, function(retorno){ $("#"+div).html(retorno); 
															 $("#carregaload").fadeOut("slow");
															 });
}

function veranime(div,pag) {
	$("#carregaload").fadeIn("slow");
	$.get(pag,{qazc:'1'}, function(retorno){ $("#"+div).html(retorno); 
															 $("#carregaload").fadeOut("slow");
															 });
}

function geralinks(div,pag) {
	$("#carregaload").fadeIn("slow");
	$.get(pag,{qazc:'1'}, function(retorno){ $("#"+div).html(retorno);
															 $("#carregaload").fadeOut("slow");
															 });
	}

function changeBox(div,pag,tel) {
	$.get(pag,{tela:tel}, function(retorno){ $("#"+div).html(retorno); 
															 });	
}

function abreDiv(dv) {
	$("#"+dv).slideToggle();
}

function montaFlash(swf, vars, width, height, id, wmode, cache) {
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param NAME=FlashVars value=\""+ vars +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"false\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\"  FlashVars=\""+ vars + "\" quality=\"high\" menu=\"false\" wmode=\""+ wmode +"\"  pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}