var xmlHttp = new Object();
var idCont;
var tmpidMenu;

function _jsPage() {
	if (_jsPage.arguments.length == 1) idCont = "tdCont";
	else idCont = _jsPage.arguments[1];
	page = _jsPage.arguments[0];

	if (window.XMLHttpRequest) xmlHttp=new XMLHttpRequest()
	else if (window.ActiveXObject) xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	xmlHttp.onreadystatechange = _jsDone
	xmlHttp.open("GET", page, true)
	xmlHttp.send(null)
}

function _jsDone() { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById(idCont).innerHTML = xmlHttp.responseText;
	}
	else {
		document.getElementById(idCont).innerHTML = "<img src=\"../img/imgCarregando.gif\">";
	}
}

function _jsGeraSelect(tabName, fieldName, searchKey, searchValue, paramJs, paramCss, fieldValue, resultText, resultValue, idCont) {
	_jsPage("../inc/geraSelect.php?tabName="+tabName+"&fieldName="+fieldName+"&searchKey="+searchKey+"&searchValue="+searchValue+"&paramJs="+paramJs+"&paramCss="+paramCss+"&fieldValue="+fieldValue+"&resultText="+resultText+"&resultValue="+resultValue,idCont)
}

function _jsDetalheAnun(Imovel_Id) {
	popup('anuncioDetalhe.php?Imovel_Id='+Imovel_Id,'','684','530','no')
}

function _jsDetalheAnunVideo(Imovel_Id) {
	popup('anuncioDetalhe.php?flgVideo=1&Imovel_Id='+Imovel_Id,'','684','530','no')
}

function _jsFicha(Imovel_Id){
	popup('fichaImovel.php?Imovel_Id='+Imovel_Id,'','680','550','yes')
}

function popup(x,n,w,h,s) {
    var l = ((window.screen.width  - w) / 2);
    var t = ((window.screen.height - h) / 2);
   janelinha = window.open(x,n,'leftmargin=-15,topmargin=-15,marginheight=0,marginwidth=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+s+',resizable=no,top='+t+',left='+l+',screenX='+l+',screenY='+t+',copyhistory=no,height='+h+',width='+w+'');
}

function _jsPreview03(imgSrc,displayType,divName,imgName) {
	document.getElementById(divName).style.display = displayType;	
	document.getElementById(imgName).src = imgSrc;	
}

function _jsPreview(Veiculo_Nome) {
	if (document.getElementById(Veiculo_Nome).value) {
		document.getElementById("td"+Veiculo_Nome).style.display = '';
		document.getElementById("img"+Veiculo_Nome).src = 'file://'+document.getElementById(Veiculo_Nome).value;
	}
	else{
		document.getElementById("td"+Veiculo_Nome).style.display = 'none';
	}
}

function mascaraData(campoData, id){
	var campo = campoData;
	var data = campoData.value;
	if (data.length == 2){
		data = data + '/';
		document.getElementById(id).value = data;
		return true;
	}              
	if (data.length == 5){
		data = data + '/';
		document.getElementById(id).value = data;
		return true;
	}         
}

function FormataValor(id,tammax,teclapres) {
   
    if(window.event) 
	{ // Internet Explorer
	 var tecla = teclapres.keyCode; 
	}
	else if(teclapres.which) 
	{ // Nestcape / firefox
	 var tecla = teclapres.which;
    }
	vr = document.getElementById(id).value;
	vr = vr.toString().replace( "/", "" );
	vr = vr.toString().replace( "/", "" );
	vr = vr.toString().replace( ",", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	tam = vr.length;
	
	if (tam < tammax && tecla != 8){ tam = vr.length + 1; }
		if (tecla == 8 ){ tam = tam - 1; }
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
		document.getElementById(id).value = vr; }
		if ( (tam > 2) && (tam <= 5) ){
		document.getElementById(id).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
		if ( (tam >= 6) && (tam <= 8) ){
		document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
		if ( (tam >= 9) && (tam <= 11) ){
		document.getElementById(id).value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
		if ( (tam >= 12) && (tam <= 14) ){
		document.getElementById(id).value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
		if ( (tam >= 15) && (tam <= 17) ){
		document.getElementById(id).value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );}
	}
}

function Mascara(tipo, campo, teclaPress) {
	if (window.event)
	{
		var tecla = teclaPress.keyCode;
	} else {
		tecla = teclaPress.which;
	}
 
	var s = new String(campo.value);
	// Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
	s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');
 
	tam = s.length + 1;
 
	if ( tecla != 9 && tecla != 8 ) {
		switch (tipo)
		{
		case 'CPF' :
			if (tam > 3 && tam < 7)
				campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
			if (tam >= 7 && tam < 10)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
			if (tam >= 10 && tam < 12)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
		break;
 
		case 'CNPJ' :
 
			if (tam > 2 && tam < 6)
				campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
			if (tam >= 6 && tam < 9)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
			if (tam >= 9 && tam < 13)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
			if (tam >= 13 && tam < 15)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
		break;
 
		case 'TELEFONE' :
			if (tam > 2 && tam < 4)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
			if (tam >= 7 && tam < 11)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
		break;
 
		case 'DATA' :
			if (tam > 2 && tam < 4)
				campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
			if (tam > 4 && tam < 11)
				campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
		break;
		
		case 'CEP' :
			if (tam > 5 && tam < 9)
				campo.value = s.substr(0,5) + '-' + s.substr(5,tam-4);
		break;
		}
	}
}

function _jsVerSolicite(Solicite_Id) {
	popup('verSolicitacao.php?Solicite_Id='+Solicite_Id,'','380','450','no')
}

function _jsfrmNews() {
	erro = false;
	if (document.frmNews.Newsletter_Email.value == '') {
		alert('O e-mail precisa ser preenchido');
		document.frmNews.Newsletter_Email.focus();
		erro = true;
		return false;
	}
	
	if (document.frmNews.checkNews.checked == false) {
		alert('Você deve autorizar o recebimento de Informativos para se cadastrar');
		document.frmNews.checkNews.focus();
		erro = true;
		return false;
	}
	if (!erro) document.frmNews.submit();
}

function _jsChangeCidade(Cidade_Id) {
	_jsPage("acoes.php?Acao=2&Cidade_Id="+Cidade_Id,"lblRevendas01");
}

function _jsChangeEstado(Estado_Id) {
	document.getElementById("lblRevendas01").innerHTML = '<select name=\"Revenda_Id\" id=\"Revenda_Id\" class=\"comboVerde\"><option value=\"\" selected=\"selected\">Anunciante --------------</option></select>';
	_jsPage("acoes.php?Acao=15&Estado_Id="+Estado_Id,"lblCidades");
}

function _jsRevenda(Revenda_Id) {
	if (Revenda_Id != '0') location.href = 'index.php?ir=anunciante.php&Revenda_Id='+Revenda_Id;
	else {
		location.href = 'index.php?ir=resultadoBusca.php&Revenda_Tipo=2&tmpCidade_Id='+document.getElementById("RCidade_Id").value;
	}
}

function _jsFav(Imovel_Id) {
	_jsPage("acoes.php?Acao=11&Imovel_Id="+Imovel_Id,"tdFav");
}

function _jsDesFav(Imovel_Id) {
	_jsPage("acoes.php?Acao=12&Imovel_Id="+Imovel_Id,"tdFav");
}

function _jsFav02(Imovel_Id) {
	_jsPage("acoes.php?Acao=13&Imovel_Id="+Imovel_Id,"tdFav"+Imovel_Id);
}

function _jsDesFav02(Imovel_Id) {
	_jsPage("acoes.php?Acao=14&Imovel_Id="+Imovel_Id,"tdFav"+Imovel_Id);
}

function _jsFav03(Imovel_Id) {
	_jsPage("acoes.php?Acao=20&Imovel_Id="+Imovel_Id,"tdFav"+Imovel_Id);
}

function _jsDesFav03(Imovel_Id) {
	_jsPage("acoes.php?Acao=21&Imovel_Id="+Imovel_Id,"tdFav"+Imovel_Id);
}

function _jsTvVideo(Imovel_Id) {
	_jsPage("inc.tvyoutube.php?Imovel_Id="+Imovel_Id,"tdYouTube");
	document.getElementById("tdTvVideoBg"+Imovel_Id).bgColor='#ffddb3';
	if (document.getElementById("TvVideo_Tmp").value == ''){
		document.getElementById("TvVideo_Tmp").value = "tdTvVideoBg"+Imovel_Id;
	}
	else{
		var tmp;
		tmp = document.getElementById("TvVideo_Tmp").value;
		document.getElementById(tmp).bgColor = '#ffddb3';
		document.getElementById("TvVideo_Tmp").value = "tdTvVideoBg"+Imovel_Id;
	}
}

function _jsTvVideo2(Imovel_Id) {
	_jsPage("inc.tvyoutube.php?Imovel_Id="+Imovel_Id,"tdYouTube");
	document.getElementById("tdTvVideoBg"+Imovel_Id).bgColor='#C4C4C4';
	if (document.getElementById("TvVideo_Tmp").value == ''){
		document.getElementById("TvVideo_Tmp").value = "tdTvVideoBg"+Imovel_Id;
	}
	else{
		var tmp;
		tmp = document.getElementById("TvVideo_Tmp").value;
		document.getElementById(tmp).bgColor = '#ffebd2';
		document.getElementById("TvVideo_Tmp").value = "tdTvVideoBg"+Imovel_Id;
	}
}


// Busca do index ---------------- //
function _jsBuscaTipo(Finalidade_Id, Tipo_Busca, Cont) {
	if (Tipo_Busca == ''){
	document.getElementById("divTipo").innerHTML = '<select name=\"Tipo_Id\" id=\"Tipo_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	//document.getElementById("divEstado").innerHTML = '<select name=\"Estado_Id\" id=\"Estado_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	//document.getElementById("divCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	//document.getElementById("divBairro").innerHTML = '<select name=\"Bairro_Id\" id=\"Bairro_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=3&Finalidade_Id="+Finalidade_Id+"&Tipo_Busca="+Tipo_Busca, Cont);
}

function _jsBuscaEstado(Tipo_Id, Estado_Busca, Cont) {
	if (Estado_Busca == ''){
	document.getElementById("divEstado").innerHTML = '<select name=\"Estado_Id\" id=\"Estado_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divBairro").innerHTML = '<select name=\"Bairro_Id\" id=\"Bairro_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=4&Tipo_Id="+Tipo_Id+"&Estado_Busca="+Estado_Busca, Cont);
}

function _jsBuscaCidade(Estado_Id, Cidade_Busca, Cont) {
	if (Cidade_Busca == ''){
	document.getElementById("divCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divBairro").innerHTML = '<select name=\"Bairro_Id\" id=\"Bairro_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=5&Estado_Id="+Estado_Id+"&Cidade_Busca="+Cidade_Busca, Cont);
}

function _jsBuscaBairro(Cidade_Id, Bairro_Busca, Cont) {
	if (Bairro_Busca == ''){
	document.getElementById("divBairro").innerHTML = '<select name=\"Bairro_Id\" id=\"Bairro_Id\" class=\"comboVerde\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=6&Cidade_Id="+Cidade_Id+"&Bairro_Busca="+Bairro_Busca, Cont);
}


// Busca do Anunciante nas ofertas ---------------- //
function _jsAnunTipo(Anunciante_Id, Finalidade_Id, Tipo_Busca, Cont) {
	if (Tipo_Busca == ''){
	document.getElementById("divaTipo").innerHTML = '<select name=\"aTipo_Id\" id=\"aTipo_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Tipo -------------------------</select>';
	document.getElementById("divaEstado").innerHTML = '<select name=\"aEstado_Id\" id=\"aEstado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Estado --------------------</select>';
	document.getElementById("divaCidade").innerHTML = '<select name=\"aCidade_Id\" id=\"aCidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Cidade --------------------</select>';
	document.getElementById("divaBairro").innerHTML = '<select name=\"aBairro_Id\" id=\"aBairro_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Bairro ----------------------</select>';
	}
	_jsPage("acoes.php?Acao=7&Finalidade_Id="+Finalidade_Id+"&Tipo_Busca="+Tipo_Busca+"&Anunciante_Id="+Anunciante_Id, Cont);
}

function _jsAnunEstado(Anunciante_Id, Tipo_Id, Estado_Busca, Cont) {
	if (Estado_Busca == ''){
	document.getElementById("divaEstado").innerHTML = '<select name=\"aEstado_Id\" id=\"aEstado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Estado --------------------</select>';
	document.getElementById("divaCidade").innerHTML = '<select name=\"aCidade_Id\" id=\"aCidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Cidade --------------------</select>';
	document.getElementById("divaBairro").innerHTML = '<select name=\"aBairro_Id\" id=\"aBairro_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Bairro ----------------------</select>';
	}
	_jsPage("acoes.php?Acao=8&Tipo_Id="+Tipo_Id+"&Estado_Busca="+Estado_Busca+"&Anunciante_Id="+Anunciante_Id, Cont);
}

function _jsAnunCidade(Anunciante_Id, Estado_Id, Cidade_Busca, Cont) {
	if (Cidade_Busca == ''){
	document.getElementById("divaCidade").innerHTML = '<select name=\"aCidade_Id\" id=\"aCidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Cidade --------------------</select>';
	document.getElementById("divaBairro").innerHTML = '<select name=\"aBairro_Id\" id=\"aBairro_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Bairro ----------------------</select>';
	}
	_jsPage("acoes.php?Acao=9&Estado_Id="+Estado_Id+"&Cidade_Busca="+Cidade_Busca+"&Anunciante_Id="+Anunciante_Id, Cont);
}

function _jsAnunBairro(Anunciante_Id, Cidade_Id, Bairro_Busca, Cont) {
	if (Bairro_Busca == ''){
	document.getElementById("divaBairro").innerHTML = '<select name=\"aBairro_Id\" id=\"aBairro_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Bairro ----------------------</select>';
	}
	_jsPage("acoes.php?Acao=10&Cidade_Id="+Cidade_Id+"&Bairro_Busca="+Bairro_Busca+"&Anunciante_Id="+Anunciante_Id, Cont);
}
// -----------------------------------------------


// ------- BUSCA DA TV ---------------------------
function _jsTvTipo(Finalidade_Id, Tipo_Busca, Cont) {
	if (Tipo_Busca == ''){
	document.getElementById("divTvTipo").innerHTML = '<select name=\"Tipo_Id\" id=\"Tipo_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divTvEstado").innerHTML = '<select name=\"Estado_Id\" id=\"Estado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divTvCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=17&Finalidade_Id="+Finalidade_Id+"&Tipo_Busca="+Tipo_Busca, Cont);
}

function _jsTvEstado(Tipo_Id, Estado_Busca, Cont) {
	if (Estado_Busca == ''){
	document.getElementById("divTvEstado").innerHTML = '<select name=\"Estado_Id\" id=\"Estado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divTvCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=18&Tipo_Id="+Tipo_Id+"&Estado_Busca="+Estado_Busca, Cont);
}

function _jsTvCidade(Estado_Id, Cidade_Busca, Cont) {
	if (Cidade_Busca == ''){
	document.getElementById("divTvCidade").innerHTML = '<select name=\"Cidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\" disabled=\"disabled\" ><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=19&Estado_Id="+Estado_Id+"&Cidade_Busca="+Cidade_Busca, Cont);
}
//------------------------------------------------

// ------- BUSCA DA REFORMA E CONSTRUÇÃO ---------
function _jsRefCategoria(Tipo_Id, Categoria_Busca, Cont) {
	if (Categoria_Busca == ''){
	document.getElementById("divRefCategoria").innerHTML = '<select name=\"refCategoria_Id\" id=\"Categoria_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefEstado").innerHTML = '<select name=\"refEstado_Id\" id=\"Estado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefCidade").innerHTML = '<select name=\"refCidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=24&Tipo_Id="+Tipo_Id+"&Categoria_Busca="+Categoria_Busca, Cont);
}

function _jsRefEstado(Categoria_Id, Estado_Busca, Cont) {
	if (Estado_Busca == ''){
	document.getElementById("divRefEstado").innerHTML = '<select name=\"refEstado_Id\" id=\"refEstado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefCidade").innerHTML = '<select name=\"refCidade_Id\" id=\"refCidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=25&Categoria_Id="+Categoria_Id+"&Estado_Busca="+Estado_Busca, Cont);
}

function _jsRefCidade(Estado_Id, Cidade_Busca, Cont) {
	if (Cidade_Busca == ''){
	document.getElementById("divRefCidade").innerHTML = '<select name=\"refCidade_Id\" id=\"refCidade_Id\" class=\"comboVerde\" disabled=\"disabled\" ><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=26&Estado_Id="+Estado_Id+"&Cidade_Busca="+Cidade_Busca, Cont);
}
//------------------------------------------------

// ------- BUSCA DA REFORMA E CONSTRUÇÃO ORCAMENTO ---------
function _jsRefCategoriaOrc(Tipo_Id, Categoria_Busca, Cont) {
	if (Categoria_Busca == ''){
	document.getElementById("divRefCategoriaOrc").innerHTML = '<select name=\"refCategoria_Id\" id=\"Categoria_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefEstadoOrc").innerHTML = '<select name=\"refEstado_Id\" id=\"Estado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefCidadeOrc").innerHTML = '<select name=\"refCidade_Id\" id=\"Cidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=68&Tipo_Id="+Tipo_Id+"&Categoria_Busca="+Categoria_Busca, Cont);
}

function _jsRefEstadoOrc(Categoria_Id, Estado_Busca, Cont) {
	if (Estado_Busca == ''){
	document.getElementById("divRefEstadoOrc").innerHTML = '<select name=\"refEstado_Id\" id=\"refEstado_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	document.getElementById("divRefCidadeOrc").innerHTML = '<select name=\"refCidade_Id\" id=\"refCidade_Id\" class=\"comboVerde\" disabled=\"disabled\"><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=69&Categoria_Id="+Categoria_Id+"&Estado_Busca="+Estado_Busca, Cont);
}

function _jsRefCidadeOrc(Estado_Id, Cidade_Busca, Cont) {
	if (Cidade_Busca == ''){
	document.getElementById("divRefCidadeOrc").innerHTML = '<select name=\"refCidade_Id\" id=\"refCidade_Id\" class=\"comboVerde\" disabled=\"disabled\" ><option value=\"\">Selecione ----------------</select>';
	}
	_jsPage("acoes.php?Acao=70&Estado_Id="+Estado_Id+"&Cidade_Busca="+Cidade_Busca, Cont);
}
//------------------------------------------------


function imovelZoom(){
	var srcGrande;
	document.getElementById('imgGrande').src = "../img/imgCarregando2.gif";
	document.getElementById('divFundo').style.visibility = 'visible'; 
	document.getElementById('divImg').style.visibility = 'visible'; 
	document.getElementById('divFechar').style.visibility = 'visible'; 
	srcGrande = document.getElementById('imgPrincipal').src;
	srcGrande = srcGrande.replace("nW=400&nH=300&flagMarca=1", "nW=640&nH=480&flagMarca=2");
	document.getElementById('imgGrande').src = srcGrande;	
}

function imovelZoomOut(){
	var srcGrande;
	document.getElementById('divFundo').style.visibility = 'hidden'; 
	document.getElementById('divImg').style.visibility = 'hidden'; 
	document.getElementById('divFechar').style.visibility = 'hidden'; 
	document.getElementById('imgGrande').src = "../img/imgCarregando2.gif";
}

function _jsIndicar() {
	if (document.getElementById("divIndicar").style.display == 'none') {
		document.getElementById("divIndicar").style.display = '';
		document.getElementById("divDetalhes").style.display = 'none';
		document.getElementById("divProposta").style.display = 'none';
	} else {
		document.getElementById("divIndicar").style.display = 'none';
		document.getElementById("divDetalhes").style.display = '';
	}
}

function _jsProposta() {
	if (document.getElementById("divProposta").style.display == 'none') {
		document.getElementById("divProposta").style.display = '';
		document.getElementById("divDetalhes").style.display = 'none';
		document.getElementById("divIndicar").style.display = 'none';
	} else {
		document.getElementById("divProposta").style.display = 'none';
		document.getElementById("divDetalhes").style.display = '';
	}
}

function _jsDetalheTvVideo(){
	if (document.getElementById("divFotos").style.display == 'none') {
		document.getElementById("divFotos").style.display = '';
		document.getElementById("divVideo").style.display = 'none';
	}
	else
	{
		document.getElementById("divFotos").style.display = 'none';
		document.getElementById("divVideo").style.display = '';
	}
}

function mostraMapa()
{
	var todos_os_mapas = document.getElementsByName("botMapa") 
	for (var i=0; i<todos_os_mapas.length; i++){
	  var elemento = todos_os_mapas[i];
	  elemento.style.visibility = "visible";
	}
}


function _jsBuscaRef(Imovel_Ref) {
	if (!Imovel_Ref) alert('Você deve digitar uma referência de Imóvel');
	else {
		if (window.XMLHttpRequest) xmlHttp= new XMLHttpRequest()
		else if (window.ActiveXObject) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
		xmlHttp.onreadystatechange = _jsBuscaDone
		xmlHttp.open("GET", "acoes.php?Acao=53&Imovel_Referencia="+Imovel_Ref, true)
		xmlHttp.send(null)
	}
}

function _jsBuscaDone() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		if (xmlHttp.responseText) _jsDetalheAnun(xmlHttp.responseText);
		else alert('Não há imóveis no portal com esta referência.');
	}
	document.getElementById("Imovel_Ref").value = '';
}


function _jsPer(valor) {
	if (valor == 2 && document.getElementById("tdCidades").style.display == 'none') {
		document.getElementById("tdCidades").style.display = ''
	}
	if (valor == 1 && document.getElementById("tdCidades").style.display == '') {
		document.getElementById("tdCidades").style.display = 'none'
		_jsGeraSelect('tabcidades','Cidade_Id','Estado_Id','','','adminInput','','Cidade_Nome','Cidade_Id','tdCidade');
		document.getElementById("Estado_Id").value = '';
	}
}

function _jsAnuncieClassificados(opcao){
	document.getElementById('Plano01').value = opcao; 
	document.getElementById('Classificados').style.display = 'none';	
	document.getElementById('CPFClassificados').style.display = '';
	document.getElementById('OfertaEspecial').style.display = '';	
	document.getElementById('CPFOfertaEspecial').style.display = 'none';
	document.getElementById('VideoAnuncio').style.display = '';	
	document.getElementById('CPFVideoAnuncio').style.display = 'none';
}

function _jsAnuncieOfertaEspecial(opcao){
	document.getElementById('Plano02').value = opcao; 
	document.getElementById('OfertaEspecial').style.display = 'none';	
	document.getElementById('CPFOfertaEspecial').style.display = '';
	document.getElementById('Classificados').style.display = '';	
	document.getElementById('CPFClassificados').style.display = 'none';		
	document.getElementById('VideoAnuncio').style.display = '';	
	document.getElementById('CPFVideoAnuncio').style.display = 'none';	
}

function _jsAnuncieVideoAnuncio(opcao){
	document.getElementById('Plano03').value = opcao; 
	document.getElementById('VideoAnuncio').style.display = 'none';	
	document.getElementById('CPFVideoAnuncio').style.display = '';
	document.getElementById('Classificados').style.display = '';	
	document.getElementById('CPFClassificados').style.display = 'none';	
	document.getElementById('OfertaEspecial').style.display = '';	
	document.getElementById('CPFOfertaEspecial').style.display = 'none';	
}

 
function _jsValidaCPF(CPF){ 
 	var i; 
	s = CPF  
	var c = s.substr(0,9); 
	var dv = s.substr(9,2); 
	var d1 = 0; 
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(10-i); 
	} 
	 
	if (d1 == 0) { 
		return false; 
	} 
	  
	d1 = 11 - (d1 % 11); 
	if (d1 > 9) d1 = 0; 
	if (dv.charAt(0) != d1) { 
 		return false;   
	} 
	  
	d1 *= 2; 	  
	for (i = 0; i < 9; i++)  {   
		d1 += c.charAt(i)*(11-i); 
	} 
	  
	d1 = 11 - (d1 % 11); 

	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1) { 
		return false; 
	} 
	  
	return true; 
}

function _jsSubmitAnuncie01() {
	if (!_jsValidaCPF(document.getElementById('Particular_CPF01').value)) {
		alert('Você deve digitar o seu CPF corretamente, sem pontos, virgulas ou traços.\nEx: 12345678900');
		return false;
	}
}

function _jsSubmitAnuncie02() {
	if (!_jsValidaCPF(document.getElementById('Particular_CPF02').value)) {
		alert('Você deve digitar o seu CPF corretamente, sem pontos, virgulas ou traços.\nEx: 12345678900');
		return false;
	}
}

function _jsSubmitAnuncie03() {
	if (!_jsValidaCPF(document.getElementById('Particular_CPF03').value)) {
		alert('Você deve digitar o seu CPF corretamente, sem pontos, virgulas ou traços.\nEx: 12345678900');
		return false;
	}
}

function _jsChangeEstado05(Estado_Id) {
	_jsPage("acoes.php?Acao=58&Estado_Id="+Estado_Id,"lblCidade05");
}

function _jsAddFav(){
    var url = "http://www.portalwebimoveis.com.br";
    var title = "Portalwebimoveis";
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else if (document.all) {
        window.external.AddFavorite(url, title);
    } else if (window.opera && window.print) {
  		return true;
	}
}

function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
	if((tecla > 47 && tecla < 58) || (tecla > 95 && tecla < 106))
		return true;
    else{
    	if ((tecla != 8 && tecla != 46)) 
			return false;
    	else 
			return true;
    }
}
// -->