 $(document).ready(function(){
	$("#div_ilogo").click(function(event){
		top.location.href="/z3portal/";
	});
	$("#esqueci_senha").click(function(event){
		top.location.href="/z3portal/recover_password";
	});
	$("#div_banner_1").click(function(event){
		top.location.href="/z3portal/how_it_works";
	});
	$("#div_banner_2").click(function(event){
		top.location.href="http://www.hotmedia.com.br/";
	});
	$("#div_banner_3").click(function(event){
		top.location.href="/z3portal/how_it_works";
	});
	$("#div_banner_4").click(function(event){
		top.location.href="http://webcast.hotmedia.com.br/testdrive/";
	});
	$("#form_ticket").submit(function(event){
		return valida_form_ticket();
	});
	$("#form_login").submit(function(event){
		return valida_form_login();
	});
	$("#btn_alert_close").click(function(event){
		$("#div_alert").toggle();
	});
	
	$("#btn_solicitar_inscricao").click(function(event){
		if(!$("#accept_tou").attr('checked')){
			alert('Você deve aceitar os termos de uso para continuar.');
			return false;
		}
	});
	
	buscaNoticias();
 });

 function valida_form_login(){
	if($("#email").attr('value') != "" && $("#senha").attr('value') != ""){
		return true;
	}
	else{
	 	$("#div_alert_content").html("Você deve preencher o formulário com seu e-mail e sua senha.");
		$("#div_alert").toggle();
		setTimeout("$('#div_alert').toggle();", 2000);
		return false;
	}
 }
 function valida_form_ticket(){
	if($("#ticket").attr('value') != ""){
		return true;
	}
	else{
	 	$("#div_alert_content").html("Você deve preencher o formulário com seu ticket.");
		$("#div_alert").toggle();
		setTimeout("$('#div_alert').toggle();", 2000);
		return false;
	}
 }
 

 function buscaNoticias(){
 	i = 0;
	$.ajax({
		type: "GET",  
		url: "/z3portal/lib/getNews/index.php",  
		dataType: "xml",  
		success: function(xml) {  
			text_events = "";
			text_news = "";
			$(xml).find("item").each(function(){  
				var title = $(this).find("title").text();  
				var url = $(this).find("link").text();  
				if(i <= 4){
					text_news += "<a href=\""+url+"\" target=\"_blank\">"+title+"</a><br /><br />";
				}
				i++;
			}); //close each(  
			$("#div_conteudo_noticias").html(text_news);  
		}  
	});
} 
