/**
 * Arquivo de javascript do Site Multi Imoveis
 * 
 * @autor: Fabiano Chiaretto Fernandes
 * @empresa: Formula P
 * @ultimaAlteração: 11:45 15/06/2011
 * @contact chiaretto@gmail.com
 */

function mudaHref(idLink,href){
	var obj = document.getElementsByName('linkTvflash');

	for (i = 0; i < obj.length; i++) {
		obj[i].style.display = "none";
	}

	document.getElementById('linkTvflash'+href).style.display = "block";
}

function change(pag, id, idDiv){
		
	document.getElementById('cont').style.display = 'none';
	document.getElementById('load').style.display = 'block';
		
	$.ajax({
		url: "lan_"+pag+".php?codigo="+id,
	
	success: function(data){
		$('#cont').html(data);
		document.getElementById('cont').style.display = 'block';
		document.getElementById('load').style.display = 'none';
		}
	});


}

function exib(id){

	document.getElementById('capa').style.display = 'none';
	document.getElementById('imagens').style.display = 'none';
	document.getElementById('planta').style.display = 'none';
	
	document.getElementById(id).style.display = 'block';
}

function validarCpf(cpf) {
	cpf = cpf.replace(/^\s+|\s+$/g,"").replace(/-/gi,'').replace(/\./gi,"");
	if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111"
			|| cpf == "22222222222" || cpf == "33333333333"
			|| cpf == "44444444444" || cpf == "55555555555"
			|| cpf == "66666666666" || cpf == "77777777777"
			|| cpf == "88888888888" || cpf == "99999999999")
		return false;
	add = 0;
	for (i = 0; i < 9; i++)
		add += parseInt(cpf.charAt(i)) * (10 - i);
	rev = 11 - (add % 11);
	if (rev == 10 || rev == 11)
		rev = 0;
	if (rev != parseInt(cpf.charAt(9)))
		return false;
	add = 0;
	for (i = 0; i < 10; i++)
		add += parseInt(cpf.charAt(i)) * (11 - i);
	rev = 11 - (add % 11);
	if (rev == 10 || rev == 11)
		rev = 0;
	if (rev != parseInt(cpf.charAt(10)))
		return false;
	return true;
}

function validarEmail(mail) {
	var er = new RegExp(
			/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if (typeof (mail) == "string") {
		if (er.test(mail)) {
			return true;
		}
	} else if (typeof (mail) == "object") {
		if (er.test(mail.value)) {
			return true;
		}
	} else {
		return false;
	}
}

function limpa(field) {
	if (field.value == field.defaultValue) {
		field.value = ''
	}
}

function checa(field) {
	if (field.value == '' || field.value == ' ') {
		field.value = field.defaultValue
	}
}


