function ajax(url,params,destino){
	if(window.XMLHttpRequest){ // Não-IE
		xmlhttp = new XMLHttpRequest();
	}else if(window.ActiveXObject){ // Internet Explorer
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.open("GET", url+"?"+params,true);
	
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			response = xmlhttp.responseText;
			document.getElementById(destino).innerHTML = unescape(response);
		}
	}
	
	xmlhttp.send(null);
}
function updateMenuList(obj){
	var opt 	= new Array(document.getElementById("negocio"),document.getElementById("imovel"),document.getElementById("cidade"),document.getElementById("bairro"),document.getElementById("quartos"),document.getElementById("buscar"))
	var len 	= opt.length-1;
	var loading = obj+1;
	var destino = opt[loading].name.substr(0,4);
	var params	= "";
	
	if(obj<4){
		opt[5].disabled = true;
		
		if(opt[obj].options[0].value==-1) opt[obj].options[0] = null;
		
		for(i=loading;i<len;i++){
			opt[i].options.length = 0;
			opt[i].disabled  = true;
		}
		
		for(i=0;i<=obj;i++){
			if(params!="") params += "&";
			params += opt[i].name+"="+escape(opt[i].value);
		}
		
		if(opt[2].value=="todos"){
			opt[3].options[0] = new Option('Todos',-1);
			opt[4].options[0] = new Option('Carregando os dados... ',-1);
			params3 = params + "&opt=show";
			ajax("update.php",params3,"quar");
		}else{
			opt[loading].options[0] = new Option('Carregando os dados... ',-1);
			params1 = params + "&opt="+opt[obj].name;
			ajax("update.php",params1,destino);
		} 
	}else{
		if(opt[4].options[0].value==-1) opt[4].options[0] = null;
	}
	
	if(obj>1 && opt[obj].value!=-1){
		opt[5].disabled  = false;
	}else{
		opt[5].disabled  = true;
	}
}
function pg(irPara)
{ var moz = !(document.all);
  
  if ( moz )
  { var frm = document.getElementById("formSearch"); }
  else
  { var frm = document.formSearch; }
  
  frm.page.value = irPara;
  frm.submit();
}
function detalhes(irPara)
{ var window_width = 600;
  var window_height = 500;
  var window_top = (screen.height-window_height)/2;
  var window_left = (screen.width-window_width)/2;
  newWindow=window.open('detalhes.php?id='+irPara,'detalhes','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',statusbar=1,scrollbars=1');
  newWindow.focus();
}