

function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		 request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		 request_ = new XMLHttpRequest();
	}
	return request_;
}


var http = createRequestObject();


function getInfo(){
	http.open('get', 'test.php?id='+ document.form_select.select_select.selectedIndex);

	http.onreadystatechange = handleInfo;

	http.send(null);
}

var flag=0;


//=====================================================================================//

function Popup(url) {                                                                        
		var width = 300;
		var height = 450;
		
		var left = 100;
		var top = 100;
		
		window.open(url,'webphone', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');                   
}                                                                                                                     


// JavaScript Document

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;





//=====================================================================================//


function busca5() {
	if (flag==1){
		window.setTimeOut('busca5()', 20);
		return;
	}
	http.open('get','./busca_subcat.php?cat_id=' + document.add_imovel.tipo_imovel.value);
	http.onreadystatechange = handleInfo5;
        http.send(null);

}

function handleInfo5(){
		if(http.readyState == 1){
		//document.Add_Content.seleciona_cidade.value = 'Verificando...';
		//document.getElementById('subcat').innerHTML =  = 'Aguarde...';
	}

	if(http.readyState == 4){
		
		var response5 = http.responseText;
		//window.alert(response3);
		//var proximo = response3;
		//proximo++;
		//window.alert(proximo);
		//document.new_product.resultado_matricula.value=response3;
		document.getElementById('div_sub_tipo_imovel').innerHTML = response5;
	}
}

 


//=====================================================================================//
function Limpar(valor, validos) {

// retira caracteres invalidos da string

var result = "";

var aux;

for (var i=0; i < valor.length; i++) {

aux = validos.indexOf(valor.substring(i, i+1));

if (aux>=0) {

result += aux;

}

}

return result;

} 

//=====================================================================================//

// formata moeda

function FormataMoeda(campo,tammax,teclapres,decimal) {
var tecla = teclapres.keyCode;
vr = Limpar(campo.value,"0123456789");
tam = vr.length;
dec=decimal
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 <= dec )
{ campo.value = vr ; }
if ( (tam > dec) && (tam <= 5) ){
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 6) && (tam <= 8) ){
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
}

if ( (tam >= 9) && (tam <= 11) ){
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 12) && (tam <= 14) ){
campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 15) && (tam <= 17) ){
campo.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 ) ;}
}

} 
//=====================================================================================//