$(document).ready(function(){					

	$("#cpf").mask("999.999.999-99");
	$("#senha, #cpf").keyup(function () {
		var cpf = $("#cpf").val();
			cpf = cpf.replace(/[\.|\-|_]/g, "");
		var senha = $("#senha").val();
		$("#cpfsenha").attr("value", $.md5(cpf+senha) );
		$("#cpffinal").attr("value", cpf );
	});
	
	var left = $(".topicos").css("left");				
	var atual = 0;
	var ultimo = 3;
	
	function sobe(){
		if (atual == 0)
		{
			ultimo = 3;
		} else if (ultimo == 3){
			ultimo = 1;
		} else {
		ultimo++;
		}
		if (atual == 3){
			atual = 1;
		} else {
		atual++;
		}
	}
	
	function desce(){
		if (atual == 1){
			atual = 3;
		} else if (atual == 0){
			atual = 2;
			ultimo = 2;
		} else {
			atual--;
		}
		if (ultimo == 1){
			ultimo = 3;
		} else {
		ultimo--;
		}
	}
	

	$("#slidenav .proximo").click( function(){	
		if (atual != 0){
			$("#not"+atual).animate({"left": "+=1200px"}, 0);
			$("#slidenoticias .topicos").animate({"width": "+=400px"}, 0);
		} else {							
			
		}
		$(".topicos .noticias").animate({"left": "-=400px"}, "slow", "easeInOutCirc");										
		sobe();	
		$("#info").html("Primeiro: "+atual+" - Ultimo:"+ultimo);
	});				
	
	$("#slidenav .voltar").click( function(){					
		if (atual == 0){
			$("#not3").animate({"left": "-=1200px"}, 0);
			$("#not2").animate({"left": "-=1200px"}, 0);
		}
		else { 
			$("#not"+ultimo).animate({"left": "-=1200px"}, 0);
		}															
		$(".topicos .noticias").animate({"left": "+=400px"}, "slow", "easeInOutCirc");	
		desce();					
		$("#info").html("Primeiro: "+atual+" - Ultimo:"+ultimo);
	});						
	
	$("#info").html("Primeiro: "+atual+" - Ultimo:"+ultimo);
	
	//$("#printpage").click(function(){ window.print(); return false; });
	
	$("#senha").keypress(function (e) {
      //alert("deu enter!");
	  if (e.which == 13 ){
		$("#formespaco").submit();
	  }	  
	});
	
});		