/** * */ var req; var elem; function retrieveURL( url, metodo, elemento ) { elem = elemento; if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); if( metodo == null ){ req.onreadystatechange = processStateChange; }else{ metodoExecute( req, metodo ); } try { req.open("GET", url, true); } catch (e) { alert(e); } req.send(null); } else if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { if( metodo == null ){ req.onreadystatechange = processStateChange; }else{ metodoExecute( req, metodo ); } req.open("GET", url, true); req.send(); } } } var historial = ""; var todos = false; function metodoExecute( req, metodo ){ if( metodo == 1 ){ historial = ""; req.onreadystatechange = tipoVehStateChange; }else if( metodo == 2 ){ historial = ""; req.onreadystatechange = tipoVehChange; }else if( metodo == 3 ){ historial = ""; req.onreadystatechange = marcaVehStateChange; }else if( metodo == 4 ){ historial = ""; req.onreadystatechange = modeloVehStateChange; }else if( metodo == 5 ){ historial = ""; req.onreadystatechange = versionVehStateChange; }else if( metodo == 6 ){ historial = ""; req.onreadystatechange = colorVehStateChange; }else if( metodo == 10 ){ historial = "Historial"; req.onreadystatechange = tipoVehChange; }else if( metodo == 11 ){ historial = "Historial"; req.onreadystatechange = marcaVehStateChange; }else if( metodo == 12 ){ historial = "Historial"; req.onreadystatechange = modeloVehStateChange; }else if( metodo == 13 ){ historial = "Historial"; req.onreadystatechange = versionVehStateChange; }else if( metodo == 14 ){ historial = "Historial"; req.onreadystatechange = colorVehStateChange; }else if( metodo == 20 ){ req.onreadystatechange = processStateChange2; }else if( metodo == 30 ){ req.onreadystatechange = nombreComprador; }else if( metodo == 40 ){ req.onreadystatechange = validaCP; }else if( metodo == 41 ){ req.onreadystatechange = validaCPReactivacion; }else if( metodo == 100 ){ // Se especifica un elemento diferente req.onreadystatechange = processStateChangeOfElement; } } function processStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response document.getElementById("idElemento").innerHTML = req.responseText; } else { alert("Problem: " + req.statusText); } } } /////////////////////////////////////////////////////////////////////////////////////////////// function processStateChange2() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response var respuesta = req.responseText; //alert( "logn "+ respuesta.length +" - Resp: " + respuesta.substring(0, 1) + " - Mensaje: " + respuesta.substring(1, respuesta.length - 1 )); //alert(respuesta + " - " +respuesta.length); var indice = respuesta.indexOf( "," ); var isValido = respuesta.substr( 0, indice ); respuesta = respuesta.substr( indice + 1, respuesta.length ); indice = respuesta.indexOf( "," ); var accion = respuesta.substr( 0, indice ); var msg = respuesta.substr( indice + 1, respuesta.length ); //alert( isValido + " - " + accion + " - " + msg.length ); if( msg.length <= 2 ){ if( isValido == 1){ movValido= true; forma.operacion.value = accion; }else{ alert("No puede realizar la operacion"); forma.clInvGNPCS.focus(); movValido= false; forma.operacion.value = accion; } }else { if( isValido == 1 ){ alert( msg ); movValido= true; forma.operacion.value = accion; } else { alert( msg ); forma.clInvGNPCS.focus(); movValido= false; forma.operacion.value = accion; } } }else { alert("Problem: " + req.statusText); } } } var movValido = false; /*******************************************************************************/ marcaInfo = ''; modeloInfo = ''; versionInfo = ''; marcaInfoHist = ''; modeloInfoHist = ''; versionInfoHist = ''; function tipoVehStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response if( document.getElementById("idTipoVeh") != null ){ document.getElementById("idTipoVeh").innerHTML = req.responseText; }if( document.getElementById("idMarcaVeh") != null ){ document.getElementById("idMarcaVeh").innerHTML = marcaInfo; }if( document.getElementById("idModeloVeh") != null ){ document.getElementById("idModeloVeh").innerHTML = modeloInfo; }if( document.getElementById("idVersionVeh") != null ){ document.getElementById("idVersionVeh").innerHTML = versionInfo; } } else { alert("Problem: " + req.statusText); } } } function tipoVehChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response /* alert( historial + (historial == "Historial" ) + " - " + req.responseText ); alert( historial + (historial == "Historial" ? marcaInfoHist : marcaInfo ) + " - " + marcaInfoHist ); alert( historial + (historial == "Historial" ? modeloInfoHist : modeloInfo ) + " - " + modeloInfoHist ); alert( historial + (historial == "Historial" ? versionInfoHist : versionInfo ) + " - " + versionInfoHist ); */ if( document.getElementById("idTipoVeh" + historial) != null ){ document.getElementById("idTipoVeh" + historial).innerHTML = req.responseText; }if( document.getElementById("idMarcaVeh" + historial) != null ){ document.getElementById("idMarcaVeh" + historial).innerHTML = (historial == "Historial") ? marcaInfoHist : marcaInfo; }if( document.getElementById("idModeloVeh" + historial) != null ){ document.getElementById("idModeloVeh" + historial).innerHTML = (historial == "Historial") ? modeloInfoHist : modeloInfo; }if( document.getElementById("idVersionVeh" + historial) != null ){ document.getElementById("idVersionVeh" + historial).innerHTML = (historial == "Historial") ? versionInfoHist : versionInfo; } } else { alert("Problem: " + req.statusText); } } } function marcaVehStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response /* alert( historial + (historial == "Historial" ) + " - " + req.responseText ); alert( historial + (historial == "Historial" ? modeloInfoHist : modeloInfo ) + " - " + modeloInfoHist ); alert( historial + (historial == "Historial" ? versionInfoHist : versionInfo ) + " - " + versionInfoHist ); */ if( document.getElementById("idMarcaVeh" + historial) != null ){ document.getElementById("idMarcaVeh" + historial).innerHTML = req.responseText; }if( document.getElementById("idModeloVeh" + historial) != null ){ document.getElementById("idModeloVeh" + historial).innerHTML = (historial == "Historial") ? modeloInfoHist : modeloInfo; }if( document.getElementById("idVersionVeh" + historial) != null ){ document.getElementById("idVersionVeh" + historial).innerHTML = ("idVersionVeh" + historial).innerHTML = (historial == "Historial") ? versionInfoHist : versionInfo; } } else { alert("Problem: " + req.statusText); } } } function modeloVehStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response /* alert( historial + (historial == "Historial" ) + " - " + req.responseText ); alert( historial + (historial == "Historial" ? versionInfoHist : versionInfo ) + " - " + versionInfoHist ); */ if( document.getElementById("idModeloVeh" + historial) != null ){ document.getElementById("idModeloVeh" + historial).innerHTML = req.responseText; }if( document.getElementById("idVersionVeh" + historial) != null ){ document.getElementById("idVersionVeh" + historial).innerHTML = ("idVersionVeh" + historial).innerHTML = (historial == "Historial") ? versionInfoHist : versionInfo; } } else { alert("Problem: " + req.statusText); } } } function versionVehStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response /* alert( historial + (historial == "Historial" ) + " - " + req.responseText ); */ if( document.getElementById("idVersionVeh" + historial) != null ){ document.getElementById("idVersionVeh" + historial).innerHTML = req.responseText; } } else { alert("Problem: " + req.statusText); } } } function colorVehStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response if( document.getElementById("idColorVeh" + historial) != null ){ document.getElementById("idColorVeh" + historial).innerHTML = req.responseText; } } else { alert("Problem: " + req.statusText); } } } function nombreComprador(){ if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response var respuesta = req.responseText; //alert( "logn "+ respuesta.length +" - Resp: " + respuesta.substring(0, 1) + " - Mensaje: " + respuesta.substring(1, respuesta.length - 1 )); //alert(respuesta + " - " +respuesta.length); var indice = respuesta.indexOf( "," ); var isValido = respuesta.substr( 0, indice ); respuesta = respuesta.substr( indice + 1, respuesta.length ); indice = respuesta.indexOf( "," ); var accion = respuesta.substr( 0, indice ); var msg = respuesta.substr( indice + 1, respuesta.length ); //alert( "-> " + isValido ); //alert( isValido + " - " + accion + " - " + msg.length ); if( isValido == 2 ){ document.getElementById("idElemento").innerHTML = msg; compradorValido = true; }else{ alert( msg ); compradorValido = false; } }else { alert("Problem: " + req.statusText); } } } function validaCP(){ if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response var respuesta = req.responseText; //alert( "logn "+ respuesta.length +" - Resp: " + respuesta.substring(0, 1) + " - Mensaje: " + respuesta.substring(1, respuesta.length - 1 )); //alert(respuesta + " - " +respuesta.length); var indice = respuesta.indexOf( "," ); var isValido = respuesta.substr( 0, indice ); respuesta = respuesta.substr( indice + 1, respuesta.length ); indice = respuesta.indexOf( "," ); var accion = respuesta.substr( 0, indice ); var msg = respuesta.substr( indice + 1, respuesta.length ); //alert( "-> " + isValido ); //alert( isValido + " - " + accion + " - " + msg.length ); //alert( !!isValido ); if( isValido == 1 ){ //alert( msg ); cpValido = true; }else{ alert( msg ); cpValido = false; } }else { alert("Problem: " + req.statusText); } } } function validaCPReactivacion(){ if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response var respuesta = req.responseText; //alert( "logn "+ respuesta.length +" - Resp: " + respuesta.substring(0, 1) + " - Mensaje: " + respuesta.substring(1, respuesta.length - 1 )); //alert(respuesta + " - " +respuesta.length); var indice = respuesta.indexOf( "," ); var isValido = respuesta.substr( 0, indice ); respuesta = respuesta.substr( indice + 1, respuesta.length ); indice = respuesta.indexOf( "," ); var accion = respuesta.substr( 0, indice ); var msg = respuesta.substr( indice + 1, respuesta.length ); //alert( "-> " + isValido ); //alert( isValido + " - " + accion + " - " + msg.length ); //alert( !!isValido ); if( isValido == 1 ){ //alert( msg ); cpValido = true; }else{ // alert( msg ); cpValido = false; } }else { // alert("Problem: " + req.statusText); } } } function processStateChangeOfElement() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response document.getElementById( elem ).innerHTML = req.responseText; } else { alert("Problem: " + req.statusText); } }else{ //alert( req.readyState ); } }