$().ready(function() {
	
	// Pegando as linhas e colocando cores diferentes em cada linha	
	$('.corLinhas tr:odd').addClass('par');
	$('.corLinhas tr:even').addClass('impar');
	
	$(function() { 
	    $('.rollover').hover(function() { 
	        var currentImg = $(this).attr('src'); 
	        $(this).attr('src', $(this).attr('hover')); 
	        $(this).attr('hover', currentImg); 
	    }, function() { 
	        var currentImg = $(this).attr('src'); 
	        $(this).attr('src', $(this).attr('hover')); 
	        $(this).attr('hover', currentImg); 
	    }); 
	});
	
	$('.exibirFoto').innerfade({
		speed: 'slow', 
		timeout: 4000, 
		type: 'sequence',
		containerheight: '280px' ,
		outlineType: 'rounded-white'
	});
	
	// *************************************************** //
	// ************** CARREGANDO AS CIDADES ************** //
	
	var idEstado;
	var idCidade = $("#id_cidade").val();
	
	if($("#id_estado").val() != ''){
		idEstado = $("#id_estado").val();
	} else {
		idEstado = '';
	}
	
	$.post("carrega_cidade.php", {id_estado: idEstado, id_cidade: idCidade}, function (resposta){
		$("#div_carrega_cidade").html(resposta);									
	});
	
	// Pegando o id do estado para listar a cidade
	$("#id_estado").change(function(){
			
			idEstado = $("#id_estado").val();
			
			$.post("carrega_cidade.php", {id_estado: idEstado}, function (resposta){
				$("#div_carrega_cidade").html(resposta);									
			});
			
	});
	
});

/////////////////////////////////////////////////////////////////////////////////////////////////////////
	//Limita a quantidade de caracteres ao digitar
	
function limitChars(textid, limit, infodiv)
{

	var text = $('#'+textid).val(); 
	var textlength = text.length;

	if(textlength > limit)
	{
	
		$('#' + infodiv).html('Você não pode escrever mais que '+limit+' caracteres!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	} else {
		$('#' + infodiv).html('Você tem '+ (limit - textlength) +' caracteres restantes.');
		return true;
	}
}

// Gerando a data
function today() {
	var dias = new Array(
		'Domingo', 
		'Segunda-feira', 
		'Terça-feira', 
		'Quarta-feira', 
		'Quinta-feira', 
		'Sexta-feira',
		'Sábado');
		
	var meses = new Array(
		'Janeiro', 
		'Fevereiro', 
		'Março', 
		'Abril', 
		'Maio', 
		'Junho',
		'Julho',
		'Agosto',
		'Setembro',
		'Outubro',
		'Novembro',
		'Dezembro');	
	
	var today    = new Date(); // Inicia objeto DATA
	var diaAtual = dias[today.getDay()]; // Exibe dia da semana em português
	var mesAtual = meses[today.getMonth()]; // Exibe os meses em português
	var hora = today.getHours();
	var minuto = today.getMinutes();
	var segundo = today.getSeconds();
	
	if (minuto<10) minuto = "0" + minuto
	if (segundo<10) segundo = "0" + segundo 
	
	var tempo  =  hora + ':' + minuto + ':' + segundo;
	
	var diaHoje = today.getDate() + ' de ' + 
					mesAtual  + ' de ' + 
					today.getFullYear() + ', ' + 
					diaAtual + ' às ' + 
					tempo;
	
	document.getElementById("relogio").innerHTML = diaHoje;

	setTimeout("today()",1000) 
}
