// Java Document

function Open_Proposta(cod_imovel) {
            f_dialogOpen("pop_proposta.asp?p=1&cod_imovel=" + cod_imovel, 'popproposta', 'width=600,height=530');
         }

function Open_Indique(cod_imovel) {
            f_dialogOpen("pop_indique.asp?p=1&cod_imovel=" + cod_imovel, 'popindique', 'scrollbars=yes,width=600,height=530');
         }

function Open_Imprime(cod_imovel) {
            f_dialogOpen("pop_imprime.asp?p=1&cod_imovel=" + cod_imovel, 'popimprime', 'scrollbars=yes,width=673,height=530');
         }

function Open_Selecao() {
            f_dialogOpen("pop_selecao_email.asp", 'popselecao', 'scrollbars=yes,width=673,height=530');
         }


 function mOvr(src,clrOver) {
    if (!src.contains(event.fromElement)) {
	  src.style.cursor = 'hand';
	  src.bgColor = clrOver;
	}
  }
  function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	  src.style.cursor = 'default';
	  src.bgColor = clrIn;
	}
  }
  function mClk(src) {
    if(event.srcElement.tagName=='TD'){
	  src.children.tags('A')[0].click();
    }
  }

function MouseClique(src) {
    if(event.srcElement.tagName=='TD'){
	  src.children.tags('A')[0].click();
    }
  }
  
  
  function MouseOverSC(src,corOver,corBorda,size) {
    if (!src.contains(event.fromElement)) {
      src.style.border = "solid " + size + "px " + corBorda
	  src.style.cursor = 'hand';
	  src.bgColor = corOver;
	}
  }
  function MouseOutSC(src,corOut,corBorda,size) {
	if (!src.contains(event.toElement)) {
      src.style.border = "solid 1px " + corBorda
	  src.style.cursor = 'hand';
	  src.style.cursor = 'default';
	  src.bgColor = corOut;
	}
  }


function doCheck3(cadastro)
 // Verificar o preenchimento
{
if ( (document.cadastro.cod_cidade[document.cadastro.cod_cidade.selectedIndex].value == 0))
	{
           alert("Escolha uma cidade para continuar.");
           document.cadastro.cod_cidade.focus();
           return false;  }

/*
if ( (document.cadastro.cod_bairro[document.cadastro.cod_bairro.selectedIndex].value == 0))
	{
           alert("Escolha um BAIRRO");
           document.cadastro.cod_bairro.focus();
           return false;  }
*/



    	return true
}



function doCheck4(busca_codigo)    // Verificar o preenchimento
{
if (document.busca_codigo.cod_imovel.value == 'Código')
	{
           alert("Digite o Código do Imóvel.");
           document.busca_codigo.cod_imovel.focus();
           return false;  }

    	return true
}

function doCheck5(busca_palavra)    // Verificar o preenchimento
{
if (document.busca_palavra.palavra.value == 'Palavra Chave')
	{
           alert("Digite uma palavra para pesquisar.");
           document.busca_palavra.palavra.focus();
           return false;  }

    	return true
}




function checkVazio(pCampo,pMsg)
{
	if (pCampo.value == "")
	{
		alert(pMsg);
		pCampo.focus();
		return false
	}
	return true
}

function MM_openBrWindow(theURL,winName,features)
 { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
function right(e) {
var msg = "Desculpe, Proibido a cópia das Fotos.";
if (navigator.appName == 'Netscape' && e.which == 3) {
//alert(msg);  // Delete this line to disable but not alert user
return false;
 }
 else
 if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
 //alert(msg); // Delete this line to disable but not alert user
 return false;
 }
return true;
}
document.onmousedown = right;
*/


// description: draggable modal windows
// coding: softcomplex.com
// data: 09/21/2007

var N_BASEZINDEX =10000;
var RE_PARAM = /^\s*(\w+)\s*\=\s*(.*)\s*$/;

// this function makes the document numb to the mouse events by placing the transparent layer over it
function f_putScreen (b_show) {

	if (b_show == null && !window.b_screenOn)
		return;

	if (!b_show) {
		//window.b_screenOn = false;
		if (e_screen) {
            e_screen.style.display = 'none';

            // attach event
            if (document.removeEventListener) {
                document.removeEventListener('mousemove', f_dragProgress, false);
                window.removeEventListener('resize', f_putScreen, false);
                window.removeEventListener('scroll', f_putScreen, false);
            }
            if (window.detachEvent) {
                document.detachEvent('onmousemove', f_dragProgress);
                window.detachEvent('onresize', f_putScreen);
                window.detachEvent('onscroll', f_putScreen);
            }
            else {
                document.onmousemove = undefined;
                window.onresize = undefined;
                window.onscroll = undefined;
            }
            document.body.removeChild(e_screen);
            window.e_screen = null;
        }
        return;
	}

	// create the layer if doesn't exist
	if (window.e_screen == null) {
        window.e_screen = document.createElement("div");
		e_screen.innerHTML = "&nbsp;";
		document.body.appendChild(e_screen);

		e_screen.style.position = 'absolute';
		e_screen.id = 'eScreen';

		// attach event
		if (document.addEventListener) {
			document.addEventListener('mousemove', f_dragProgress, false);
			window.addEventListener('resize', f_putScreen, false);
			window.addEventListener('scroll', f_putScreen, false);
		}
		if (window.attachEvent) {
			document.attachEvent('onmousemove', f_dragProgress);
			window.attachEvent('onresize', f_putScreen);
			window.attachEvent('onscroll', f_putScreen);
		}
		else {
			document.onmousemove = f_dragProgress;
			window.onresize = f_putScreen;
			window.onscroll = f_putScreen;
		}
	}

	// set properties
	var a_docSize = f_documentSize();
	e_screen.style.left = a_docSize[2] + 'px';
	e_screen.style.top = a_docSize[3] + 'px';
	e_screen.style.width = a_docSize[0] + 'px';
	e_screen.style.height = a_docSize[1] + 'px';
	e_screen.style.zIndex = N_BASEZINDEX + a_windows.length * 2 - 1;
	e_screen.style.display = 'block';
}

// returns the size of the document
function f_documentSize () {

var n_scrollX = 0,
	n_scrollY = 0;

	if (typeof(window.pageYOffset) == 'number') {
		n_scrollX = window.pageXOffset;
		n_scrollY = window.pageYOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop )) {
		n_scrollX = document.body.scrollLeft;
		n_scrollY = document.body.scrollTop;
	}
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		n_scrollX = document.documentElement.scrollLeft;
		n_scrollY = document.documentElement.scrollTop;
	}

	if (typeof(window.innerWidth) == 'number')
		return [window.innerWidth, window.innerHeight, n_scrollX, n_scrollY];
	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		return [document.documentElement.clientWidth, document.documentElement.clientHeight, n_scrollX, n_scrollY];
	if (document.body && (document.body.clientWidth || document.body.clientHeight))
		return [document.body.clientWidth, document.body.clientHeight, n_scrollX, n_scrollY];
	return [0, 0];
}

function f_dialogOpenDiv (divToShow, s_title, s_features) {
    if (!window.a_windows)
		window.a_windows = [];

	// parse parameters
	var a_featuresStrings = s_features.split(',');
	var a_features = [];
	for (var i = 0; i < a_featuresStrings.length; i++)
		if (a_featuresStrings[i].match(RE_PARAM))
			a_features[String(RegExp.$1).toLowerCase()] = RegExp.$2;

	// create element for window
	var n_nesting = a_windows.length;

	var e_window = document.createElement("div");
	e_window.style.position = 'absolute';
	var n_width  = a_features.width  ? parseInt(a_features.width)  : 300;
	var n_height = a_features.height ? parseInt(a_features.height) : 200;
	var a_docSize = f_documentSize ();
	e_window.style.left = (a_features.left ? parseInt(a_features.left) : ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
	e_window.style.top  = (a_features.top  ? parseInt(a_features.top)  : ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
	e_window.style.zIndex = N_BASEZINDEX + a_windows.length * 2 + 2;

      var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    e_window.innerHTML = divToShow.innerHTML;
	document.body.appendChild(e_window);
	a_windows[n_nesting] = e_window;

    // put the screen
	f_putScreen(true);
}

function f_dialogOpen (s_url, s_title, s_features) {
	if (!window.a_windows)
		window.a_windows = [];

	// parse parameters
	var a_featuresStrings = s_features.split(',');
	var a_features = [];
	for (var i = 0; i < a_featuresStrings.length; i++)
		if (a_featuresStrings[i].match(RE_PARAM))
			a_features[String(RegExp.$1).toLowerCase()] = RegExp.$2;

	// create element for window
	var n_nesting = a_windows.length;

	var e_window = document.createElement("div");
	e_window.style.position = 'absolute';
	var n_width  = a_features.width  ? parseInt(a_features.width)  : 300;
	var n_height = a_features.height ? parseInt(a_features.height) : 200;
	var a_docSize = f_documentSize ();
	e_window.style.left = (a_features.left ? parseInt(a_features.left) : ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
	e_window.style.top  = (a_features.top  ? parseInt(a_features.top)  : ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
	e_window.style.zIndex = N_BASEZINDEX + a_windows.length * 2 + 2;

      var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    e_window.innerHTML =
		'<table border="0" class="' +
		(a_features.css ? a_features.css : 'dialogWindow') +
		'" style="z-index:10;"><tr><td><iframe frameBorder="0" name="'+s_title+'" style = "border:0 solid black" scrolling="' + (a_features.scrollbars ? a_features.scrollbars : "no")  +  '" width="' + n_width +
		'" height="' + n_height + (s_url!=''?'" src="' + s_url + '"':'')+'>  </iframe></td></tr></table>';
 //  alert(e_window.innerHTML);
	document.body.appendChild(e_window);
    var txt = document.createTextNode(" ");
    document.body.appendChild(txt);

    a_windows[n_nesting] = e_window;

    // put the screen
	f_putScreen(true);
}


function f_dialogClose () {

	var n_nesting = a_windows.length - 1;
	// destroy element
	if (a_windows[n_nesting].removeNode)
		a_windows[n_nesting].removeNode(true);
	else if (document.body.removeChild)
		document.body.removeChild(a_windows[n_nesting]);
	a_windows[n_nesting] = null;
	a_windows.length = n_nesting;

    var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "visible";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "visible";
    }
    // move the screen

    f_putScreen(n_nesting);

}


// drag'n'drop functions
function f_dragStart (s_name, e_event) {
	if (!e_event && window.event) e_event = window.event;

	// save mouse coordinates
	window.n_mouseX = e_event.clientX;
	window.n_mouseY = e_event.clientY;
	window.e_draggedWindow = window.a_windows[s_name];
	return false;
}
function f_dragProgress (e_event) {
	if (!e_event && window.event) e_event = window.event;
	if (!e_event || window.e_draggedWindow == null) return;

	var n_newMouseX = e_event.clientX;
	var n_newMouseY = e_event.clientY;

	window.e_draggedWindow.style.left = (parseInt(window.e_draggedWindow.style.left) - window.n_mouseX + n_newMouseX) + 'px';
	window.e_draggedWindow.style.top  = (parseInt(window.e_draggedWindow.style.top)  - window.n_mouseY + n_newMouseY) + 'px';

	window.n_mouseX = n_newMouseX;
	window.n_mouseY = n_newMouseY;
}

function f_dragEnd () {
	window.e_draggedWindow = null;
}

// end draggable modal windows











/**  Seleciona a aba.
 *  
 * Param:
 * 		'tabPrefix' - Prefixo id da aba.
 *		'contentPrefix' - Prifixo id do conteudo da aba, caso exista um para cada aba.
 *		'tabNumber' - Numero da aba a ser selecionada.
 *		'totalTabs' - Numero total de abas.
 * 
 **/


function switchTab(tabPrefix, contentPrefix, tabNumber, totalTabs) {
	var field = tabNumber;
	var i = 1;
	var totalTabs = parseInt(totalTabs)
	for( i ; i <= totalTabs; i++ ) {
		if( i == parseInt(field) ){
			document.getElementById(tabPrefix+field).className = "selected";
			document.getElementById(tabPrefix+field).style.zIndex = totalTabs;
			
			if(contentPrefix != "") {
				document.getElementById(contentPrefix+field).style.display = "";
			}
			
		} else {
			document.getElementById(tabPrefix+i.toString()).className = "";
			document.getElementById(tabPrefix+i.toString()).style.zIndex = totalTabs-i;
			
			if(contentPrefix != "") {
				document.getElementById(contentPrefix+i.toString()).style.display = "none";
			}
		}
	}				
}



////////////////////////////////////////////////////////////
// Documento Java Script                                  //
// Francisco C Paulino - Tofinha - [EMAIL PROTECTED] //
// 06/11/2002                                             //
////////////////////////////////////////////////////////////

 function FormataReais(fld, milSep, decSep, e) {
 var sep = 0;
 var key = '';
 var i = j = 0;
 var len = len2 = 0;
 var strCheck = '0123456789';
 var aux = aux2 = '';
 var whichCode = (window.Event) ? e.which : e.keyCode;
 if (whichCode == 13) return true;

var t = new String(fld.value);
if (whichCode == 8){
fld.value = t.substring(0, t.length-1);
} 

 key = String.fromCharCode(whichCode);  // Valor para o código da Chave
 if (strCheck.indexOf(key) == -1) return false;  // Chave inválida
 len = fld.value.length;
 for(i = 0; i < len; i++)
 if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != 
decSep)) 
 break;
 aux = '';
 for(; i < len; i++)
 if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += 
fld.value.charAt
 (i);
 aux += key;
 len = aux.length;
 if (len == 0) fld.value = '';
 if (len == 1) fld.value = '0'+ decSep + '0' + aux;
 if (len == 2) fld.value = '0'+ decSep + aux;
 if (len > 2) {
 aux2 = '';
 for (j = 0, i = len - 3; i >= 0; i--) {
 if (j == 3) {
 aux2 += milSep;
 j = 0;
 }
 aux2 += aux.charAt(i);
 j++;
 }
 fld.value = '';
 len2 = aux2.length;
 for (i = len2 - 1; i >= 0; i--)
 fld.value += aux2.charAt(i);
 fld.value += decSep + aux.substr(len - 2, len);
 }
 return false;
 }

//-->

//FUNCAO DE MASCARA DE VALOR COM EXPRESSAO REGULAR. CROSS BROWSER SERVE QUALQUER NAVEGADOR
// CHAMAR onkeypress="mascara(this,mvalor)"

/* Máscaras ER */  
function mascara(o,f){  
     v_obj=o  
     v_fun=f  
     setTimeout("execmascara()",1)  
 }  

 function execmascara(){  
     v_obj.value=v_fun(v_obj.value)  
 }  


function mvalor(v){  
v=v.replace(/\D/g,"");//Remove tudo o que não é dígito  
v=v.replace(/(\d)(\d{8})$/,"$1.$2");//coloca o ponto dos milhões  
v=v.replace(/(\d)(\d{5})$/,"$1.$2");//coloca o ponto dos milhares  
   
v=v.replace(/(\d)(\d{2})$/,"$1,$2");//coloca a virgula antes dos 2 últimos dígitos  
return v;  
} 



<!--

//funcoes abaixo para gerenciar cadastramento da newsletter.

function trim(str){str = str.replace(/^\s*$/, '');return str;}
function $Npro(field){var element =  document.getElementById(field);return element;return false;}
function emailvalidation(field, errorMessage) {
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos=field.value.indexOf("@");dotpos=field.value.lastIndexOf(".");lastpos=field.value.length-1;	var badEmail = (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);
	if (goodEmail && !badEmail) {return true;}
	else {/*alert(errorMessage);*/$Npro("Error").innerHTML=errorMessage;$Npro("Error").style.display="inline";field.focus();field.select();return false;}
}
function emptyvalidation(entered, errorMessage) {
	$Npro("Error").innerHTML="";
	with (entered) {
	if (trim(value)==null || trim(value)=="Nome" || trim(value)=="") {/*alert(errorMessage);*/$Npro("Error").innerHTML=errorMessage;$Npro("Error").style.display="inline";return false;}
	else {return true;}} //with
}	//emptyvalidation

function formvalidation(thisform) {
with (thisform) {
if (emptyvalidation(nome,"Digite o seu nome completo")==false) {nome.focus(); return false;};
if (emailvalidation(email,"Digite seu e-mail corretamente")==false) {email.focus(); return false;};
 }
}
//-->



