Event.observe(window, 'load', function() { Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv); AddEditCuentaBancariaListeners = function(e) { var el = e.element(); var del = el.hasClassName('spanDelete'); var id = el.identify(); if(del == true) { DeleteCuentaBancariaPopup(id); return; } del = el.hasClassName('spanEdit'); if(del == true) { EditCuentaBancariaPopup(id); } del = el.hasClassName('spanView'); if(del == true) { ViewCuentaBancariaPopup(id); } } $('contenido').observe("click", AddEditCuentaBancariaListeners); }); function AddCuentaBancariaDiv(id) { grayOut(true); if(id == 0) { $('fview').hide(); grayOut(false); return; } $('fview').show(); new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: {type: "addCuentaBancaria"}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; FViewOffSet(response); Event.observe($('agregarCuentaBancaria'), "click", AddCuentaBancaria); Event.observe($('fviewclose'), "click", function(){ AddCuentaBancariaDiv(0); }); }, onFailure: function(){ alert('Something went wrong...') } }); } function AddCuentaBancaria() { new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: $('agregarCuentaBancariaForm').serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "fail") { ShowStatusPopUp(splitResponse[1]); } else { ShowStatusPopUp(splitResponse[1]); $('contenido').innerHTML = splitResponse[2]; Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv); HideFview(); } }, onFailure: function(){ alert('Something went wrong...') } }); } function EditCuentaBancariaPopup(id) { grayOut(true); $('fview').show(); if(id == 0) { $('fview').hide(); grayOut(false); return; } new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: {type: "editCuentaBancaria", id:id}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; FViewOffSet(response); Event.observe($('closePopUpDiv'), "click", function(){ AddCuentaBancariaDiv(0); }); Event.observe($('editarCuentaBancaria'), "click", EditarCuentaBancaria); }, onFailure: function(){ alert('Something went wrong...') } }); } function EditarCuentaBancaria() { new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: $('editarCuentaBancariaForm').serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "fail") { ShowStatusPopUp(splitResponse[1]) } else { ShowStatusPopUp(splitResponse[1]) $('contenido').innerHTML = splitResponse[2]; Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv); HideFview(); } }, onFailure: function(){ alert('Something went wrong...') } }); } function ViewCuentaBancariaPopup(id) { grayOut(true); $('fview').show(); new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: {type: "viewCuentaBancaria", id:id}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; FViewOffSet(response); Event.observe($('closePopUpDiv'), "click", function(){ AddCuentaBancariaDiv(0); }); Event.observe($('btnClose'), "click", function(){ AddCuentaBancariaDiv(0); }); }, onFailure: function(){ alert('Something went wrong...') } }); } function DeleteCuentaBancariaPopup(id) { var message = "Realmente deseas eliminar esta cuenta bancaria?"; if(!confirm(message)) { return; } new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php', { method:'post', parameters: {type: "deleteCuentaBancaria", id: id}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); ShowStatus(splitResponse[1]) $('contenido').innerHTML = splitResponse[2]; Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv); HideFview(); }, onFailure: function(){ alert('Something went wrong...') } }); }