$(document).ready(function(){
	

	/*$(".trcidade").bind("click",function(){	
		
		$(this).find("td").toggleClass("minus");
		var idTr = $(this).attr("id");
		alert(idTr);
		$("." + idTr).toggleClass("displayNone");
	
	}).css("cursor","pointer");	*/
	
	$(".fotosPlacas").fancybox();
	
	
	$("h3.accordion").bind("click",function(){
		$(this).next().slideToggle("fast");
		$(this).toggleClass("minus");
	}).css("cursor","pointer");	
	
	
	$("select[name=bisemana]").bind("change",function(){
		pegaPlacas($(this).val());
	});	 	
	
	$("input[name=email],input[name=senha]").bind("focus",function(){
		$(this).attr("value","");															   
	});
	
	 
	$("#cepCadastro").bind("blur",function(){
		var valor = $(this).val().replace(/-/i,"");
		var destino = $("#loadCep");
		if(valor != "") {
			if(valor.length == 8) {
				destino.html("<img src=\"util/img/load.gif\" alt=\"Carregando endereço...\" />");
				$.ajax({
					type: "GET",
					url: "library/class/cep.class.php",
					data: "cep=" + valor,
					success: function(msg) {
						destino.html("&nbsp;");
						eval("var arr = " + msg); 
						$("#endereco").val(arr.rua);
						$("#bairro").val(arr.bairro);
						$("#cidade").val(arr.cidade);
						$("#estado").val(arr.uf);
					}
				});
			} else {
				destino.html("<span class=\"erro\">Cep inválido</span>");	
			}
		}
	});
	
	
});

function pegaPlacas(bisemana) {
	var destino = $("#recebePlacas");
	destino.html("Carregando informações...");
	$.ajax({
		type: "GET",
		url: "library/common/placas.php",
		data: "bisemana=" + bisemana,
		success: function(msg) {
			destino.html(msg);
		}
	});
}

function popUpHidden() {
	var obj = document.getElementById("popUpHome");
	obj.style.display = "none";
}

