// JavaScript Document

$(function(){
	
	$(".bLightBox").lightBox({
		fixedNavigation:true,
		imageLoading:'images/loading.gif',
		imageBtnPrev:'images/A.jpg',
		imageBtnNext:'images/B.jpg',	
		imageBtnClose:'images/C.jpg'
	});
	
	/*
	$(".jInput1Dt").mask("99/99/9999");
	$(".jInput1Tel").mask("(99) 9999-9999");
	$(".jInput1Cep").mask("99999-999");
	$(".jInput1Cpf").mask("999999999999");
	$(".jInput1Rg").mask("111.111.111-11");
	*/
	
	$("#dir1_uf").change(function(){
		$("#retornocidades").html("Carregando cidades...");
		$.get("RetornaCidade.php", {uf: $(this).val(), name: $(this).attr('title') } , function(data){
			$("#retornocidades").html(data);
		});
	});
	$("#dir2_uf").change(function(){
		$("#retornocidades2").html("Carregando cidades...");
		$.get("RetornaCidade.php", {uf: $(this).val(), name: $(this).attr('title') } , function(data){
			$("#retornocidades2").html(data);
		});
	});
	
});

function getCidadesUf(uf, title, id_cidade)
{
	$("#retornocidades").html("Carregando cidades...");
	$.get("RetornaCidade.php?uf="+uf+"&name="+title+'&cidade='+id_cidade, function(data){
		$("#retornocidades").html(data);
	});
}

var str="";
function getBoletins()
{
	str	="<img src='imgs/informacoes/icone.gif' border='0' alt='' align='absbottom'> <a href='pdf/TV_Fronteira_Jogos_de_Verao_2010_Boletim_1.pdf' target='_blank'>Boletim 1</a><br><br>";
	str+="<img src='imgs/informacoes/icone.gif' border='0' alt='' align='absbottom'> <a href='pdf/TV_Fronteira_Jogos_de_Verao_2010_Boletim_2.pdf' target='_blank'>Boletim 2</a>";
	$("#texto").html(str);
}

function getForm(Id,este)
{
	$(".abas_form").hide();
	$("#"+Id).show();
	
	$(".jmenu2").css('background-color','');
	$(este).css('background-color','#f2f2f2');
}

function ConfirmaPostForm()
{
	var ObjEuAceito = document.getElementById('euaceito');
	if(ObjEuAceito.checked==true){
		document.form1.submit();
	}else{
		alert('A confirmação da declaração de participação é obrigatório!');
	}
	
}


/// valida cpf
function validaCPF(cpf) 
{
erro = new String;
var cpfTemp = cpf.value;
cpf.value = cpf.value.replace('.', '');
cpf.value = cpf.value.replace('.', '');
cpf.value = cpf.value.replace('-', '');
if (cpf.value.length == 11)
{    
var nonNumbers = /\D/;
if (nonNumbers.test(cpf.value)) 
{
erro = "A verificacao de CPF suporta apenas números!"; 
}
else
{
if (cpf.value == "00000000000" || 
cpf.value == "11111111111" || 
cpf.value == "22222222222" || 
cpf.value == "33333333333" || 
cpf.value == "44444444444" || 
cpf.value == "55555555555" || 
cpf.value == "66666666666" || 
cpf.value == "77777777777" || 
cpf.value == "88888888888" || 
cpf.value == "99999999999") {
erro = "Número de CPF inválido!"
}
var a = [];
var b = new Number;
var c = 11;
for (i=0; i<11; i++){
a[i] = cpf.value.charAt(i);
if (i < 9) b += (a[i] * --c);
}
if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
b = 0;
c = 11;
for (y=0; y<10; y++) b += (a[y] * c--); 
if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
if ((cpf.value.charAt(9) != a[9]) || (cpf.value.charAt(10) != a[10])) {
erro = "Número de CPF inválido.";
}
}
}
else
{
if(cpf.value.length == 0)
return false
else
erro = "Número de CPF inválido.";
}
cpf.value = cpfTemp;
if (erro.length > 0) {
alert(erro);
cpf.focus();
return false;
}     
return true;    
}
