function objAjax(){
  var xmlhttp = false;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
function axCargarPagina(pDiv, pUrl){
  var idConte;
  var pagina;
  
  idConte = document.getElementById(pDiv);
  pagina = pUrl + "&temp=" + Math.random();

  var miAjax = objAjax();
  miAjax.open("GET", pagina, true);
  miAjax.onreadystatechange = function() {
    if (miAjax.readyState == 4) {
      idConte.innerHTML = miAjax.responseText;
    }
  }
  miAjax.send(null);
}
function axEnviarValor(pele, pmod, pnom, pmai, purl, ptxt, pval) {
  var wdiv = 'divValor';
  var wpag = PPATH + 'addvalor.php';
  wpag += '?ele=' + encodeURIComponent(pele);
  wpag += '&mod=' + encodeURIComponent(pmod);
  wpag += '&nom=' + encodeURIComponent(pnom);
  wpag += '&mai=' + encodeURIComponent(pmai);
  wpag += '&url=' + encodeURIComponent(purl);
  wpag += '&txt=' + encodeURIComponent(ptxt);
  wpag += '&val=' + encodeURIComponent(pval);
  
  axCargarPagina(wdiv, wpag);
  return false;
}

//-------------------- funciones para canal oferta ----------------------------------------------------------------------------------

//-------------------- [Usuario] ----------------------------------------------------------------------------------------------

//-------------------- [Usuario - Ayuda] --------------------------------------------------------------------------------------

function axAyudaUsuar() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_usuario.php?mod=ayuda', { method: 'get', evalScripts: true });
}

//-------------------- [Usuario - Solicitudes] --------------------------------------------------------------------------------------

function axListarSolic() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_usuario.php?mod=solic', { method: 'get', evalScripts: true });
}
function axFormularioSolic(id_con) {
  var div = 'ajax_all';
  var url = GPATH + 'ax_usuario.php?mod=solic&ope=formulariosolic';
  new Ajax.Updater(div, url, { method: 'get', evalScripts: true });
}
function axDetallesSolic(id_sol) {
  var div = $('sol_' + id_sol);
  if (div.idf == 'Detalles') {
    div.style.display = 'none';
    div.idf = '';
    div.innerHTML = '';
  } else {
    div.style.display = 'block';
    div.idf = 'Detalles';
    var url = GPATH + 'ax_usuario.php?mod=solic&ope=versolic&id=' + id_sol;
    new Ajax.Updater(div, url, { method: 'get' });
  }
  return false;
}
function axListarConte(id_sol) {
  var div = $('sol_' + id_sol);
  if (div.idf == 'Contestacion') {
    div.style.display = "none";
    div.innerHTML = '';
    div.idf = '';
  } else {
    div.style.display = "block";
    div.idf = 'Contestacion';
    var url = GPATH + 'ax_usuario.php?mod=solic&ope=listarconte&id=' + id_sol;
    new Ajax.Updater(div, url, { method: 'get' });
  }
  return false;
}
function axAgregarSolic() {
  if (axChequearSolic(0)) {
    var query = 'mod=solic&ope=agregar&' + $('frm_add_solic').serialize();
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarSolic });
  }
  return false;
}
function axAgregarSolicLibre() {
  var r = false;
  if (axChequearSolic(1)) {
    r = true;
  }
  return r;
}
function axChequearSolic(libre) {
  var query = 'mod=verif&pai=' + $F('pai') + '&des=' + $F('des') + '&tip=' + $F('tip');
  var url = GPATH + 'ax_lugar.php';
  new Ajax.Request(url, { postBody: query, asynchronous: false, onSuccess: axVerificarDestino });
  var r = false;
  if ($F('tal_1')==null && $F('tal_2')==null && $F('tal_3')==null && $F('tal_4')==null) {
    alert(txtA[0]);
  } else if ($F('tre_1')==null && $F('tre_2')==null && $F('tre_3')==null && $F('tre_4')==null && $F('tre_5')==null) {
    alert(txtA[1]);
  } else if (!$F('fee')) {
    alert(txtA[2]);
  } else if (!$F('fes')) {
    alert(txtA[3]);
  } else if (!$F('des')) {
    alert(txtA[4]);
  } else if ($F('lug')==0) {
    alert(txtA[5]);
  } else {
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
    
    var arrFee = $F('fee').split('-');
    var feea = parseInt(arrFee[2], 10);
    var feem = parseInt(arrFee[1], 10);
    var feed = parseInt(arrFee[0], 10);
    feem -= 1;
    var fechaFee = new Date(feea, feem, feed);
    
    var arrFes = $F('fes').split('-');
    var fesa = parseInt(arrFes[2], 10);
    var fesm = parseInt(arrFes[1], 10);
    var fesd = parseInt(arrFes[0], 10);
    fesm -= 1;
    var fechaFes = new Date(fesa, fesm, fesd);
    
    if (fechaFee < fechaHoy) {
      alert(txtA[6]);
    } else if (fechaFes <= fechaFee) {
      alert(txtA[7]);
    } else if (libre) {
      if (!$F('nom')) {
        alert(txtA[8]);
      } else if (!$F('mai')) {
        alert(txtA[9]);
      } else {
        r = true;
      }
    } else {
      r = true;
    }
  }
  return r;
}
function axVerificarDestino(r) {
  $('lug').value = r.responseText;
}
function axAgregarSolicHotel() {
  if (axChequearSolicHotel(0)) {
    var query = 'mod=solic&ope=agregarhotel&' + $('frm_add_solic').serialize();
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axIrAListarSolic });
  }
  return false;
}
function axAgregarSolicHotelLibre() {
  var r = false;
  if (axChequearSolicHotel(1)) {
    r = true;
  }
  return r;
}
function axIrAListarSolic() {
  window.location = PPATH + 'usuario.php'
}
function axIrAListarSolic() {
  window.location = PPATH + 'usuario.php'
}
function axChequearSolicHotel(libre) {
  var r = false;
  
  $('fec_ok').innerHTML = 0;
  if ($F('fee') && $F('fes')) {
    var query = 'mod=verif_cierre&id=' + $F('id_hot') + '&fee=' + $F('fee') + '&fes=' + $F('fes');
    var url = GPATH + 'ax_establecimientos.php';
    new Ajax.Updater('fec_ok', url, { postBody: query, asynchronous: false });
  }
  
  var tre_ok = false;
  for (var i=1; i<=5; ++i) {
    var nom = 'tre_' + i;
    if ($(nom) != null) {
      if ($F(nom) != null) {
        tre_ok = true;
      }
    }
  }
  if (!tre_ok) {
    alert(txtA[1]);
  } else if (!$F('fee')) {
    alert(txtA[2]);
  } else if (!$F('fes')) {
    alert(txtA[3]);
  } else if ($('fec_ok').innerHTML != '1') {
    alert(txtA[10]);
  } else {
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
    
    var arrFee = $F('fee').split('-');
    var feea = parseInt(arrFee[2], 10);
    var feem = parseInt(arrFee[1], 10);
    var feed = parseInt(arrFee[0], 10);
    feem -= 1;
    var fechaFee = new Date(feea, feem, feed);
    
    var arrFes = $F('fes').split('-');
    var fesa = parseInt(arrFes[2], 10);
    var fesm = parseInt(arrFes[1], 10);
    var fesd = parseInt(arrFes[0], 10);
    fesm -= 1;
    var fechaFes = new Date(fesa, fesm, fesd);
    
    if (fechaFee < fechaHoy) {
      alert(txtA[6]);
    } else if (fechaFes <= fechaFee) {
      alert(txtA[7]);
    } else if (libre) {
      if (!$F('nom')) {
        alert(txtA[8]);
      } else if (!$F('mai')) {
        alert(txtA[9]);
      } else {
        r = true;
      }
    } else {
      r = true;
    }
  }
  return r;
}
function axAgregarSolicOferta(lofcod) {
  if (axChequearOferta(lofcod)) {
    var div = 'ajax_all';
    var query = 'mod=solic&ope=agregaroferta&lofcod=' + lofcod + '&' + $('frm_sel_oferta_' + lofcod).serialize();
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Updater(div, url + '?' + query, { method: 'get', evalScripts: true });
  }
  return false;
}
function axAgregarSolicLugar() {
  if (axChequearSolicLugar(0)) {
    var query = 'mod=solic&ope=agregarlugar&' + $('frm_add_solic').serialize();
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axIrAListarSolic });
  }
  return false;
}
function axAgregarSolicLugarLibre() {
  var r = false;
  if (axChequearSolicLugar(1)) {
    r = true;
  }
  return r;
}
function axChequearSolicLugar(libre) {
  var r = false;
  if ($F('tal_1')==null && $F('tal_2')==null && $F('tal_3')==null && $F('tal_4')==null) {
    alert(txtA[0]);
  } else if ($F('tre_1')==null && $F('tre_2')==null && $F('tre_3')==null && $F('tre_4')==null && $F('tre_5')==null) {
    alert(txtA[1]);
  } else if (!$F('fee')) {
    alert(txtA[2]);
  } else if (!$F('fes')) {
    alert(txtA[3]);
  } else {
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
    
    var arrFee = $F('fee').split('-');
    var feea = parseInt(arrFee[2], 10);
    var feem = parseInt(arrFee[1], 10);
    var feed = parseInt(arrFee[0], 10);
    feem -= 1;
    var fechaFee = new Date(feea, feem, feed);
    
    var arrFes = $F('fes').split('-');
    var fesa = parseInt(arrFes[2], 10);
    var fesm = parseInt(arrFes[1], 10);
    var fesd = parseInt(arrFes[0], 10);
    fesm -= 1;
    var fechaFes = new Date(fesa, fesm, fesd);
    
    if (fechaFee < fechaHoy) {
      alert(txtA[6]);
    } else if (fechaFes <= fechaFee) {
      alert(txtA[7]);
    } else if (libre) {
      if (!$F('nom')) {
        alert(txtA[8]);
      } else if (!$F('mai')) {
        alert(txtA[9]);
      } else {
        r = true;
      }
    } else {
      r = true;
    }
  }
  return r;
}
function axCancelarSolic(id_sol) {
  if (confirm(txtC[0])) {
    var query = 'mod=solic&ope=cancelar&id=' + id_sol;
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarSolic });
  }
  return false;
}
function axDescartarConte(id_con) {
  if (confirm(txtC[1])) {
    var query = 'mod=solic&ope=descartarconte&id=' + id_con;
    var url = GPATH + 'ax_usuario.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarSolic });
  }
  return false;
}
function axFormularioAceptar(id_con) {
  var div = 'ajax_all';
  var url = GPATH + 'ax_usuario.php?mod=solic&ope=formularioaceptar&id=' + id_con;
  new Ajax.Updater(div, url, { method: 'get' });
}
function axReservar() {
  if (axChequearDatosUsuario()) {
    var query = $('frm_ace_confir').serialize();
    $('div_ace_confir').innerHTML = 'Complete el proceso de pago.';
    var url_ventana = SPATH + 'v_reserva.php?' + query;
    window.open(url_ventana, 'v', 'scrollbars=no,width=800,height=475');
  }
  return false;
}
function axChequearDatosUsuario() {
  var r = false;
  
  if (!$F('nom')) {
    alert(txtA[11]);
  } else if (!$F('pdi')) {
    alert(txtA[12]);
  } else if (!$F('pcp')) {
    alert(txtA[13]);
  } else if (!$F('plo')) {
    alert(txtA[14]);
  } else if (!$F('ppr')) {
    alert(txtA[15]);
  } else if (!$F('ppa')) {
    alert(txtA[16]);
  } else if (!$F('tel')) {
    alert(txtA[17]);
  } else if (!$F('dni')) {
    alert(txtA[18]);
  } else {
    r = true;
  }
  return r;
}

//-------------------- [Usuario - Datos] --------------------------------------------------------------------------------------

function axDatosUsuar() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_usuario.php?mod=datos', { method: 'get', evalScripts: true });
}
function axEnviarDatosUsuar() {
  if ($F('cla') == $F('cla2')) {
    var query = 'mod=datos&ope=enviar&' + $('frm_datos').serialize();
    var url = GPATH + 'ax_usuario.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axDatosUsuar });
  } else {
    alert(txtA[19]);
  }
  return false;
}

//-------------------- [Usuario - Reservas] --------------------------------------------------------------------------------------

function axListarReserUsuar() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_usuario.php?mod=reser', { method: 'get', evalScripts: true });
}
function axDetallesReser(id_res) {
  var url_ventana = 'v_pdf_usuar.php?id=' + id_res;
  window.open(url_ventana, 'v');
  return false;
}

//-------------------- [Usuario - Reservas - Comentarios] ------------------------------------------------------------------------

function axComentUsuar(id_res) {
  var div = $('res_det_' + id_res);
  if (div.title == 'Comentario') {
    div.title = '';
    div.display = 'none';
    div.innerHTML = '';
  } else {
    div.display = 'block';
    div.title = 'Comentario';
    new Ajax.Updater(div, GPATH + 'ax_usuario.php?mod=reser&ope=comentario&id=' + id_res, { method: 'get', evalScripts: true });
  }
  return false;
}
function axEnviarComentUsuar() {
  var query = 'mod=reser&ope=comentario_enviar&' + $('frm_com_datos').serialize();
  var url = GPATH + 'ax_usuario.php';
  $('ajax_all').innerHTML = 'Actualizando datos';
  new Ajax.Request(url, { postBody: query, onSuccess: axListarReserUsuar });
  return false;
}
function axEliminarComentUsuar(id_res) {
  if (confirm(txtC[2])) {
    var query = 'mod=reser&ope=comentario_eliminar&id=' + id_res;
    var url = GPATH + 'ax_usuario.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarReserUsuar });
  }
  return false;
}

//-------------------- [Usuario - Reservas - Cancelacion] ------------------------------------------------------------------------

function axCancelReserUsuar(id_res) {
  var div = $('res_det_' + id_res);
  if (div.title == 'Cancelacion') {
    div.title = '';
    div.display = 'none';
    div.innerHTML = '';
  } else {
    div.display = 'block';
    div.title = 'Cancelacion';
    new Ajax.Updater(div, GPATH + 'ax_usuario.php?mod=reser&ope=cancelar&id=' + id_res, { method: 'get', evalScripts: true });
  }
  return false;
}
function axEnviarCancelReserUsuar(id_res) {
  if (confirm(txtC[3])) {
    var query = 'mod=reser&ope=cancelar_enviar&id=' + id_res;
    var url = GPATH + 'ax_usuario.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarReserUsuar });
  }
  return false;
}

//-------------------- [Hotel] ---------------------------------------------------------------------------------------------------

//-------------------- [Hotel - Peticiones] --------------------------------------------------------------------------------------

function axListarPetic() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=petic', { method: 'get', evalScripts: true });
}
function axDetallesPetic(id_pet) {
  var div = $('pet_' + id_pet);
  if (div.idf == 'Detalles') {
    div.style.display = 'none';
    div.innerHTML = '';
    div.idf = '';
  } else {
    div.style.display = 'block';
    div.idf = 'Detalles';
    var url = GPATH + 'ax_hoteles.php?mod=petic&ope=verpetic&id=' + id_pet;
    new Ajax.Updater(div, url, { method: 'get', evalScripts: true });
  }
  return false;
}
function axListarConteHotel(id_pet) {
  var div = $('pet_' + id_pet);
  if (div.idf == 'Contestaciones') {
    div.style.display = 'none';
    div.innerHTML = '';
    div.idf = '';
  } else {
    div.style.display = 'block';
    div.idf = 'Contestaciones';
    var url = GPATH + 'ax_hoteles.php?mod=petic&ope=listarconte&id=' + id_pet;
    new Ajax.Updater(div, url, { method: 'get' });
  }
  return false;
}
function axCancelarConte(id_con) {
  if (confirm(txtC[4])) {
    var query = 'mod=petic&ope=cancelarconte&id=' + id_con;
    var url = GPATH + 'ax_hoteles.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarPetic });
  }
  return false;
}
function axDescartarPetic(id_pet) {
  if (confirm(txtC[5])) {
    var query = 'mod=petic&ope=descartar&id=' + id_pet;
    var url = GPATH + 'ax_hoteles.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarPetic });
  }
  return false;
}
function axAgregarConte() {
  if (axChequearConte()) {
    var query = 'mod=petic&ope=agregarconte&' + $('frm_add_conte').serialize();
    var url = GPATH + 'ax_hoteles.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarPetic });
  }
  return false;
}
function axChequearConte() {
  var r = false;
  var vpre = 0;
  var mpre = 0;
  var wdia = 0;
  var msg = '';
  var fechaHoy = new Date();
  fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
  
  wdia = parseFloat($F('dias'));
  vpre = parseFloat($F('pre'));
  mpre = parseFloat($F('pre_max'));
  if (!isNaN(vpre)) {
    if (vpre > 0 && (vpre <= mpre || mpre == 0)) {
      $('pre').value = vpre;
      r = true;
    } else {
      alert(txtA[20]);
    }
  } else {
    alert(txtA[21]);
  }
  if (r) {
    r = false;
    if (!$F('fel')) {
      alert(txtA[22]);
    } else {
      var arrFel = $F('fel').split('-');
      var fela = parseInt(arrFel[2], 10);
      var felm = parseInt(arrFel[1], 10);
      var feld = parseInt(arrFel[0], 10);
      felm -= 1;
      var fechaFel = new Date(fela, felm, feld);
      
      var arrFee = $F('csolfee').split('-');
      var feea = parseInt(arrFee[2], 10);
      var feem = parseInt(arrFee[1], 10);
      var feed = parseInt(arrFee[0], 10);
      feem -= 1;
      var fechaFee = new Date(feea, feem, feed);
      
      if (fechaFel >= fechaHoy) {
        if (fechaFel <= fechaFee) {
          r = true;
          msg += txtA[38] + ': ' + $F('csolfee') + '\n';
          msg += txtA[39] + ': ' + $F('csolfes') + '\n';
          msg += txtA[40] + ': ' + $F('csoladu') + '\n';
          msg += txtA[41] + ': ' + $F('csolnin') + '\n';
          msg += txtA[42] + ': ' + $F('csolhab') + '\n';
          msg += txtA[43] + ': ' + $('reg').options[$('reg').selectedIndex].text + '\n';
          msg += txtA[44] + ': ' + wdia + '\n';
          msg += txtA[45] + ': ' + vpre + ' euros.' + '\n\n';
          msg += txtA[46] + ': ' + (wdia * vpre) + ' euros.';
          r = confirm(msg);
        } else {
          alert(txtA[47] + $F('csolfee'));
        }
      } else {
        alert(txtA[23]);
      }
    }
  }
  return r;
}

//-------------------- [Hotel - Datos] --------------------------------------------------------------------------------------

function axDatosHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos', { method: 'get', evalScripts: true });
}
function axEnviarDatosHotel() {
  if ($F('cla') == $F('cla2')) {
    var query = 'mod=datos&ope=enviar&' + $('frm_h_datos').serialize();
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axDatosHotel });
  } else {
    alert(txtA[19]);
  }
  return false;
}
function axContacHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=contacto', { method: 'get', evalScripts: true });
}
function axEnviarContacHotel() {
  var query = 'mod=datos&ope=contacto_enviar&' + $('frm_h_datos').serialize();
  var url = GPATH + 'ax_hoteles.php';
  $('ajax_all').innerHTML = 'Actualizando datos';
  new Ajax.Request(url, { postBody: query, onSuccess: axContacHotel });
  return false;
}
function axServicHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=servicios', { method: 'get', evalScripts: true });
}
function axEnviarServicHotel() {
  var query = 'mod=datos&ope=servicios_enviar&' + $('frm_h_datos').serialize();
  var url = GPATH + 'ax_hoteles.php';
  $('ajax_all').innerHTML = 'Actualizando datos';
  new Ajax.Request(url, { postBody: query, onSuccess: axServicHotel });
  return false;
}
function axUbicarHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=ubicar', { method: 'get', evalScripts: true });
}
function axEnviarUbicarHotel() {
  if (axChequearUbicacion()) {
    var query = 'mod=datos&ope=ubicar_enviar&' + $('frm_h_datos').serialize();
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axUbicarHotel });
  }
  return false;
}
function axChequearUbicacion() {
  var query = 'mod=verif&pai=' + $F('pai') + '&des=' + $F('des') + '&tip=A';
  var url = GPATH + 'ax_lugar.php';
  new Ajax.Request(url, { postBody: query, asynchronous: false, onSuccess: axVerificarDestino });
  var r = false;
  if (!$F('des')) {
    alert(txtA[24]);
  } else if ($F('lug')==0) {
    alert(txtA[24]);
  } else {
    r = true;
  }
  return r;
}
function axFotosHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=fotos', { method: 'get', evalScripts: true });
}
function axEliminarFotosHotel(id_him) {
  if (confirm(txtC[6])) {
    var query = 'mod=datos&ope=fotos_eliminar&id=' + id_him;
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axFotosHotel });
  }
  return false;
}
function axCancelacionHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=cancelacion', { method: 'get', evalScripts: true });
}
function axEnviarCancelacionHotel() {
  var query = 'mod=datos&ope=cancelacion_enviar&' + $('frm_h_datos').serialize();
  var url = GPATH + 'ax_hoteles.php';
  $('ajax_all').innerHTML = 'Actualizando datos';
  new Ajax.Request(url, { postBody: query, onSuccess: axCancelacionHotel });
  return false;
}
function axContratoHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=contrato', { method: 'get', evalScripts: true });
}
function axEnviarContratoHotel() {
  var query = 'mod=datos&ope=contrato_enviar&' + $('frm_h_datos').serialize();
  if ($F('fsol')) {
    alert(txtA[25]);
  }
  var url = GPATH + 'ax_hoteles.php';
  $('ajax_all').innerHTML = 'Actualizando datos';
  new Ajax.Request(url, { postBody: query, onSuccess: axContratoHotel });
  return false;
}
function axCierreHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=datos&ope=cierre', { method: 'get', evalScripts: true });
}
function axAddCierreHotel() {
  if (axChequearCierre()) {
    var query = 'mod=datos&ope=cierre_enviar&' + $('frm_datos_cierre').serialize();
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axCierreHotel });
  }
  return false;
}
function axEliminarCierreHotel(id_clo) {
  if (confirm(txtC[7])) {
    var query = 'mod=datos&ope=cierre_eliminar&id=' + id_clo;
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axCierreHotel });
  }
  return false;
}
function axChequearCierre() {
  var r = false;
  if (!$F('fei')) {
    alert(txtA[26]);
  } else if (!$F('fef')) {
    alert(txtA[27]);
  } else {
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());

    var arrFei = $F('fei').split('-');
    var feia = parseInt(arrFei[2], 10);
    var feim = parseInt(arrFei[1], 10);
    var feid = parseInt(arrFei[0], 10);
    feim -= 1;
    var fechaFei = new Date(feia, feim, feid);

    var arrFef = $F('fef').split('-');
    var fefa = parseInt(arrFef[2], 10);
    var fefm = parseInt(arrFef[1], 10);
    var fefd = parseInt(arrFef[0], 10);
    fefm -= 1;
    var fechaFef = new Date(fefa, fefm, fefd);

    if (fechaFef < fechaHoy) {
      alert(txtA[28]);
    } else if (fechaFef <= fechaFei) {
      alert(txtA[29]);
    } else {
      r = true;
    }
  }
  return r;
}

//-------------------- [Hotel - Reservas] --------------------------------------------------------------------------------------

function axListarReserHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=reser', { method: 'get', evalScripts: true });
}
function axNoshowReserHotel(id_res) {
  var div = $('res_det_' + id_res);
  if (div.display == 'block') {
    div.display = 'none';
    div.innerHTML = '';
  } else {
    div.display = 'block';
    new Ajax.Updater(div, GPATH + 'ax_hoteles.php?mod=reser&ope=noshow&id=' + id_res, { method: 'get', evalScripts: true });
  }
  return false;
}
function axEnviarNoshowReserHotel(id_res) {
  var imp = 0;
  if (confirm(txtC[8])) {
    if ($('imp')) {
      imp = $F('imp');
    }
    var query = 'mod=reser&ope=noshow_enviar&id=' + id_res + '&imp=' + imp;
    var url = GPATH + 'ax_hoteles.php';
    $('ajax_all').innerHTML = 'Actualizando datos';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarReserHotel });
  }
  return false;
}
function axDetallesReserHotel(id_res) {
  var url_ventana = 'v_pdf_hotel.php?id=' + id_res;
  window.open(url_ventana, 'v');
  return false;
}

//-------------------- [Hotel - Facturas] --------------------------------------------------------------------------------------

function axListarFactuHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=factu', { method: 'get', evalScripts: true });
}

//-------------------- [Hotel - Ofertas] --------------------------------------------------------------------------------------

function axListarOfertHotel() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=ofert', { method: 'get', evalScripts: true });
}
function axFormularioOfertHotel(id_ofe) {
  new Ajax.Updater('ajax_all', GPATH + 'ax_hoteles.php?mod=ofert&ope=formulario&id=' + id_ofe, { method: 'get', evalScripts: true });
  return false;
}
function axEliminarOfertHotel(id_ofe) {
  if (confirm(txtC[9])) {
    $('ajax_all').innerHTML = 'Actualizando datos';
    var query = 'mod=ofert&ope=eliminar&id=' + id_ofe;
    var url = GPATH + 'ax_hoteles.php';
    new Ajax.Request(url, { postBody: query, onSuccess: axListarOfertHotel });
  }
  return false;
}
//-------------------- [Hotel - Ayuda] -----------------------------------------------------------------------------------
function axObtenerAyuda(mod, ope){
  new Ajax.Updater('hot_ayu', GPATH + 'ax_ayuda.php?mod=' + mod + '&ope=' + ope, { method: 'get', evalScripts: false });  
}

//-------------------- [Establecimientos] --------------------------------------------------------------------------------------

function axListarEstablec() {
  new Ajax.Updater('ajax_all', GPATH + 'ax_establecimientos.php', { method: 'get', evalScripts: true });
}
function axDetallesEstablec(id_hot) {
  new Ajax.Updater('ajax_all', GPATH + 'ax_establecimientos.php?id=' + id_hot , { method: 'get', evalScripts: true });
}
function axChequearBuscarHotel() {
  var r = false;
  if ($F('des')) {
    var query = 'mod=verif&pai=' + $F('pai') + '&des=' + $F('des') + '&tip=' + $F('tip');
    var url = GPATH + 'ax_lugar.php';
    new Ajax.Request(url, { postBody: query, asynchronous: false, onSuccess: axVerificarDestino });
    if ($F('lug')==0) {
      alert(txtA[30]);
    } else {
      r = true;
    }
  } else {
    r = true;
  }
  return r;
}
function axOfertasEstablec(id_hot) {
  var e = $('est_ofe_' + id_hot);
  if (e.style.display != "none") {
    e.innerHTML = "";
    e.style.display = "none";
  } else {
    e.style.display = "block";
    var div = 'est_ofe_' + id_hot;
    var url = GPATH + 'ax_establecimientos.php?mod=ofert&id=' + id_hot;
    new Ajax.Updater(div, url, { method: 'get' });
  }
  return false;
}

//-------------------- [Ofertas] --------------------------------------------------------------------------------------

function axListarOfertas(p) {
  if (axChequearListarOfert()) {
    if (isNaN(p)) {
      p = 0;
    }
    var query = $('frm_bus_ofe').serialize();
    new Ajax.Updater('ajax_ofertas', GPATH + 'ax_ofertas.php?pag=' + p + '&' + query, { method: 'get', evalScripts: true });
  }
  return false;
}
function axSaberMasOferta(id_ofe) { 
  var e = $('ofe_lis_lin_' + id_ofe);
  if (e.style.display != "none") {
    e.innerHTML = "";
    e.style.display = "none";
  } else {
    e.style.display = "block";
    var div = 'ofe_lis_lin_' + id_ofe;
    var pre = $F('pre');
    if (isNaN(pre)) {
      pre = 0;
    }
    var tre1 = $F('tre_1');
    if (tre1 == null) { tre1 = 0; }
    var tre2 = $F('tre_2');
    if (tre2 == null) { tre2 = 0; }
    var tre3 = $F('tre_3');
    if (tre3 == null) { tre3 = 0; }
    var tre4 = $F('tre_4');
    if (tre4 == null) { tre4 = 0; }
    var tre5 = $F('tre_5');
    if (tre5 == null) { tre5 = 0; }
    var url = GPATH + 'ax_ofertas.php?mod=saber_mas&id=' + id_ofe + '&pre=' + pre + '&tre1=' + tre1 + '&tre2=' + tre2 + '&tre3=' + tre3 + '&tre4=' + tre4 + '&tre5=' + tre5;
    new Ajax.Updater(div, url, { method: 'get', evalScripts: true  });
  }
  return false;
}
function axSaberMasOfertaLugar(id_ofe) { 
  var e = $('ofe_lis_lin_' + id_ofe);
  if (e.style.display != "none") {
    e.innerHTML = "";
    e.style.display = "none";
  } else {
    e.style.display = "block";
    var div = 'ofe_lis_lin_' + id_ofe;
    var url = GPATH + 'ax_ofertas.php?mod=saber_mas&id=' + id_ofe + '&pre=0&tre1=1&tre2=1&tre3=1&tre4=1&tre5=1';
    new Ajax.Updater(div, url, { method: 'get', evalScripts: true  });
  }
  return false;
}
function axDetalleOferta(id_ofe) { 
  var e = $('ofe_' + id_ofe);
  if (e.style.display != "none") {
    e.innerHTML = "";
    e.style.display = "none";
  } else {
    e.style.display = "block";
    var div = 'ofe_' + id_ofe;
    var url = GPATH + 'ax_ofertas.php?mod=detalles&id=' + id_ofe;
    new Ajax.Updater(div, url, { method: 'get', evalScripts: true  });
  }
  return false;
}
function axSeleccionarOferta(lofcod) {
  if (axChequearOferta(lofcod)) {
    //var div = 'ofe_' + lofcod;
    var div = "ajax_all";
    var url = GPATH + 'ax_ofertas.php?mod=seleccionar&' + $('frm_sel_oferta').serialize() + '&lofcod=' + lofcod;  
    new Ajax.Updater(div, url, { method: 'get', evalScripts: true  });    
  }
  return false;
}
function axChequearOferta(lofcod) {
  var r = false;

  if (!$F('fee_' + lofcod)) {
    alert(txtA[2]);
  } else if (!$F('fes_' + lofcod)) {
    alert(txtA[3]);
  } else {
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
    
    var arrFee = $F('fee_' + lofcod).split('-');
    var feea = parseInt(arrFee[2], 10);
    var feem = parseInt(arrFee[1], 10);
    var feed = parseInt(arrFee[0], 10);
    feem -= 1;
    var fechaFee = new Date(feea, feem, feed);
    
    var arrFes = $F('fes_' + lofcod).split('-');
    var fesa = parseInt(arrFes[2], 10);
    var fesm = parseInt(arrFes[1], 10);
    var fesd = parseInt(arrFes[0], 10);
    fesm -= 1;
    var fechaFes = new Date(fesa, fesm, fesd);
    
    if (fechaFee < fechaHoy) {
      alert(txtA[6]);
    } else if (fechaFes <= fechaFee) {
      alert(txtA[7]);
    } else {
      r = true;
    }
  }
  return r;
}
function axChequearListarOfert() {
  var r = false;
  if ($F('des')) {
    var query = 'mod=verif&pai=' + $F('pai') + '&des=' + $F('des') + '&tip=' + $F('tip');
    var url = GPATH + 'ax_lugar.php';
    new Ajax.Request(url, { postBody: query, asynchronous: false, onSuccess: axVerificarDestino });
    if ($F('lug')==0) {
      alert(txtA[30]);
    } else {
      r = true;
    }
  } else {
    $('lug').value = 0;
    r = true;
  }
  return r;
}


//----------------------------------------------------------------------------------------------------------------------------------
function axChequearOferta_v1(lofcod) {
  var r = false;

  if (!$F('fee_' + lofcod)) {
    alert(txtA[2]);
  } else if (!$F('fes_' + lofcod)) {
    alert(txtA[3]);
  } else {
    //Chequear la fecha de entrada
    var fechaHoy = new Date();
    fechaHoy = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
    var arrFec = $F('fee_' + lofcod).split('-');
    var fa = parseInt(arrFec[2], 10);
    var fm = parseInt(arrFec[1], 10);
    fm -= 1;
    var fd = parseInt(arrFec[0], 10);
    var fechaComparada = new Date(fa, fm, fd);
    if (fechaComparada < fechaHoy) {
      alert(txtA[6]);
      return false;
    }
    r = true;
  }
  return r;
}
function axFallo() {
  alert('Fallo');
}

