var linkBusca = '../lib/Others/Ajax.php'; var codempresa = 'C00145'; var valores = new Array(2); var flag = false; valores["A"] = new Array(); valores["V"] = new Array(); function getCod(codNetImoveis, sistema, url) { var opt = { // Use POST method: 'get', // Send this lovely data parameters: "codNetImoveis="+codNetImoveis+"&sistema="+sistema, onLoading: function(t) { }, // Handle successful response onSuccess: function(t) { if(t.responseText != "falso"){ window.open(url.replace(codNetImoveis,t.responseText), "_blank"); }else{ window.open(url,'_blank'); } }, // Handle 404 on404: function(t) { alert('Erro 404: local "' + t.statusText + '" não foi encontrado.'); }, // Handle other errors onFailure: function(t) { alert('Erro ' + t.status + ' -- ' + t.statusText); } } return opt; } function abrirEmobili(url){ if(url.indexOf("&codimovel=")>1){ var urlFormatada = url.split("&codimovel="); if(urlFormatada[1].toUpperCase().charAt(0) != "I"){ new Ajax.Request("ajaxNetImoveis.php", getCod(urlFormatada[1], emobili.sistemaAtual, url)); }else{ window.open(url, "_blank"); } }else{ window.open(url, "_blank"); } } function carregaItens(){ } var sistemaAtual; function getOpt(nomeCampo, codsistema, acao, campocodigo, campovalor, ultimo) { if(ultimo=="") ultimo = 0; var opt = { // Use POST method: 'get', // Send this lovely data parameters: "codempresa="+codempresa+"&codsistema="+codsistema+"&acao="+acao, onLoading: function(t) { //window.status='carregando'; }, // Handle successful response onSuccess: function(t) { valores[codsistema][nomeCampo] = new Array(); results = t.responseXML; var root = results.getElementsByTagName('DataGrid')[0]; var items = root.getElementsByTagName("Row"); for (var i = 0 ; i < items.length ; i++) { valores[codsistema][nomeCampo][i] = new Array(); // get one item after another var item = items[i]; // now we have the item object, time to get the contents // get the name of the item var codigo = item.getElementsByTagName(campocodigo)[0].firstChild.nodeValue; // get the quantity var valor = item.getElementsByTagName(campovalor)[0].firstChild.nodeValue; valores[codsistema][nomeCampo][i]["valor"] = valor; valores[codsistema][nomeCampo][i]["codigo"] = codigo; } if(ultimo==1){ $("buscaDiv").style.display='block'; $("processandoDiv").style.display='none'; mostraItens('A'); } }, // Handle 404 on404: function(t) { alert('Erro 404: local "' + t.statusText + '" não foi encontrado.'); }, // Handle other errors onFailure: function(t) { alert('Erro ' + t.status + ' -- ' + t.statusText); } } return opt; } function enviaForm(f) { if($('codimovel').value != "Codigo" && $('codimovel').value.toUpperCase().charAt(0) != "I"){ new Ajax.Request("ajaxNetImoveis.php", getCod($('codimovel').value, sistemaAtual, f)); return false; }else{ if($('codimovel').value == "Codigo"){ $('codimovel').value = ""; } f.submit(); if($('codimovel').value == ""){ $('codimovel').value = "Codigo"; } return false; } } function setSelectDefault(nomeCampo, valorPadrao) { campo = $(nomeCampo); selectedItem = 0; for (var i = 0; i < campo.length; i++) { if (campo.options[i].text.toUpperCase() == valorPadrao.toUpperCase()) { selectedItem = i; } } campo.options[selectedItem].selected = true; }