DWBookingHotel = {
   /** Idetra actual */
   idetra:null,

   /** Obejto que almacena el array de toda la información */
   lisHotel:new Array(),

   hotel:{
      codser:null,
      nomser:null,
      codsca:null,
      codzge:null,
      imptot:null,
      cupest:null,
      lissmo:new Array()
   },

   mod:{
      id:null,
      coddis:null,
      codsmo:null,
      codcha:null,
      cupest:null,
      lisral:new Array()
   },

   ral:{
      id:null,
      codral:null,
      imptot:null,
      lisofe:new Array()
   },

   ofe:{
      nomofe:null
   },

   selHotel:null,

   /* efectos */
   fx:null,


   /** Objeto para realizar las peticiones Ajax. */
   xhr:null,

   /**
    * Carga de datos a partir del xml, se redefine en la xsl.
    */
   loadData:function () {
      return false;
   },

   /**
    * Inicialización de componentes.
    */
   init:function () {
      dome.include("DWCommon", "ESP/js/");
      dome.include("DWFilter", "ESP/js/");
      dome.include("dome.util.Event");
      dome.include("dome.util.Dom");
      dome.include("dome.util.Xhr");
      dome.include("dome.fx.Anim");

      var loadOk = DWBookingHotel.loadData();
      if (loadOk) {
         DWBookingHotel.fx = {};
         DWFilter.createFilterImptot();
         dome.util.Event.addListener(document.forms["frmHotelFilter"], "submit", DWBookingHotel.filter);
      }
   },

   /**
    * Realiza el filtrado mediante Ajax.
    */
   filter:function (ev) {
      var qs = DWFilter.getQueryString();

      var url;
      url = document.forms["frmHotelFilter"].action + "?";
      url += "ajax=S&";
      url += qs;
      url = url.replace(/(idetra=)[0-9+]/, "$1" + DWBookingHotel.idetra);

      DWBookingHotel.fetchResult(url);

      dome.util.Event.stopEvent(ev ? ev : event);

      return false;
   },

   /**
    * Realiza la paginación mediante Ajax.
    */
   paginate:function (ev) {
      var Event = dome.util.Event;

      var url;
      url = Event.getEventTarget(ev ? ev : event).href;
      /* controla si está en modo lista */
      if (DWBookingHotel.hotel.codser) {
         url += "&chklist=on";
      }
      url += "&ajax=S";
      url = url.replace(/(idetra=)[0-9+]/, "$1" + DWBookingHotel.idetra);

      DWBookingHotel.fetchResult(url);

      Event.stopEvent(ev ? ev : event);
      return false;
   },

   /**
    * Recupera los resultados por ajax.
    */
   fetchResult:function (url) {
      DWCommon.scrollTo("bookingHotelContent", 30);
      DWBookingHotel.showWaiting();
      DWBookingHotel.xhr = new dome.util.Xhr({url:url});
      DWBookingHotel.xhr.successEvent.subscribe(
            function () {
               DWBookingHotel.refreshResult();
               DWBookingHotel.hideWaiting();
            }
      );
      DWBookingHotel.xhr.failureEvent.subscribe(
            function () {
               DWBookingHotel.hideWaiting();
            }
      );
      DWBookingHotel.xhr.open();
      DWBookingHotel.xhr.send();
   },

   refreshResult:function () {
      var Dom = dome.util.Dom;

      var xmlRoot = DWBookingHotel.xhr.getResponseXML();
      DWBookingHotel.updateIdetra(Dom.getChildTextTrim(xmlRoot, "idetra"));
      var node = document.getElementById("bookingHotelContent");
      var loadData = Dom.getChildText(xmlRoot, "loadData");
      /* Para recargar la información de los tooltip. */
      eval(loadData);
      var loadOk = DWBookingHotel.loadData();
      node.innerHTML = Dom.getChildText(xmlRoot, "xhtml");
   },

   fetchRates:function (ev) {
      var Event = dome.util.Event;
      var Dom = dome.util.Dom;

      var target = Event.getEventTarget(ev ? ev : event);
      /* El id del target es linkHotelRoomOptions_{$idhot} */
      var idhot = target.id.substring(21);

      if (Dom.hasChildren(document.getElementById("hotelRoomOptions_" + idhot))) {
         /* Ocultar */
         target.innerHTML = 'Mostrar tipos de habitación y regímenes';
         DWBookingHotel.hideRates(idhot);
      } else {
         /* Mostar */
         target.innerHTML = 'Ocultar tipos de habitación y regímenes';

         var url;
         url = target.href;
         url += "&ajax=S";
         url = url.replace(/(idetra=)[0-9+]/, "$1" + DWBookingHotel.idetra);

         DWBookingHotel.showWaitingRates(idhot);
         DWBookingHotel.xhr = new dome.util.Xhr({url:url});
         DWBookingHotel.xhr.successEvent.subscribe(
               function () {
                  DWBookingHotel.showRates(idhot);
               }
         );
         DWBookingHotel.xhr.failureEvent.subscribe(
               function () {
                  DWBookingHotel.hideRates(idhot);
               }
         );
         DWBookingHotel.xhr.open();
         DWBookingHotel.xhr.send();

      }

      Event.stopEvent(ev ? ev : event);
      return false;
   },

   showRates:function (idhot) {
      var Common = dome.util.Common;
      var Dom = dome.util.Dom;
      var Anim = dome.fx.Anim;

      var xmlRoot = DWBookingHotel.xhr.getResponseXML();
      DWBookingHotel.updateIdetra(Dom.getChildTextTrim(xmlRoot, "idetra"));

      var node = document.getElementById("hotelRoomOptions_" + idhot);
      var hini = Common.getSize(node)[1];
      Dom.setStyle(node, "height", hini + "px");
      Dom.setStyle(node, "overflow", "hidden");
      Dom.setStyle(node, "opacity", "0");
      Dom.removeChildren(node);

      var oDiv = document.createElement("div");
      oDiv.innerHTML = Dom.getChildText(xmlRoot, "xhtml");
      Dom.appendChild(node, oDiv);
      var hfin = Common.getSize(oDiv)[1] + 10;
      /* 10 para que deje un pequeño márgen */

      var fx = new Anim({
                           element:node,
                           duration:0.5,
                           attribute:{
                              opacity:{ from:0, to:1},
                              height:{ from:hini, to:hfin, unit:"px" }
                           }
                        });
      fx.endEvent.subscribe(function () {
         Dom.setStyle(node, "overflow", "visible");
      });
      fx.start();

      /* Actualizar radios a partir del refres. */
      var inpRefres = document.getElementById("refres_" + idhot);
      var tknRefres = inpRefres.value.split("#");
      var numhab = tknRefres.length - 2;

      for (var i = 1; i <= numhab; i++) {
         var oInp = document.getElementById(i + "_" + tknRefres[i + 1] + "_" + idhot);
         oInp.checked = true;
      }
   },

   hideRates:function (idhot) {
      var Dom = dome.util.Dom;
      var Common = dome.util.Common;
      var Anim = dome.fx.Anim;

      var node = document.getElementById("hotelRoomOptions_" + idhot);
      var h = Common.getSize(node)[1];
      Dom.setStyle(node, "overflow", "hidden");
      var fx = new Anim({
                           element:node,
                           duration:0.5,
                           attribute:{
                              opacity:{ from:1, to:0},
                              height:{ from:h, to:0, unit:"px" }
                           }
                        });
      fx.endEvent.subscribe(function () {
         Dom.removeChildren(node);
         Dom.setStyle(node, "height", "auto");
         Dom.setStyle(node, "overflow", "visible");
         Dom.setStyle(node, "opacity", "1");
      });
      fx.start();

   },

   fetchDetails:function (ev) {
      var Event = dome.util.Event;
      var Dom = dome.util.Dom;

      var target = Event.getEventTarget(ev ? ev : event);

      /* El id del target es linkHotelDetails_{$idhot} */
      var idhot = target.id.substring(17);

      var url;
      url = target.href;
      url += "&ajax=S";

      DWBookingHotel.showDetails();
      DWBookingHotel.xhr = new dome.util.Xhr({url:url});
      DWBookingHotel.xhr.successEvent.subscribe(
            function () {
               DWBookingHotel.loadDetails();
            }
      );
      DWBookingHotel.xhr.failureEvent.subscribe(
            function () {
               DWBookingHotel.hideDetails();
            }
      );
      DWBookingHotel.xhr.open();
      DWBookingHotel.xhr.send();

      return false;
   },

   showDetails:function () {
      dome.include("DWPopupHotel", "ESP/js/");

      var Dom = dome.util.Dom;
      var Event = dome.util.Event;
      var Common = dome.util.Common;
      var wSize = Common.getWindowSize();
      var wScroll = Common.getScroll();

      var bg = DWCommon.createBackground("DWBookingHotelDetails_bg");
      Event.addListener(bg, "click", DWBookingHotel.hideDetails);

      var oDiv = document.createElement("div");
      oDiv.id = "DWBookingHotelDetails";
      oDiv.className = "DWBookingHotelDetails_waiting";
      Dom.appendChild(document.body, oDiv);

      Dom.setStyle(oDiv, "position", "absolute");
      Dom.setStyle(oDiv, "top", ((wScroll[1] + (wSize[1] - 200) / 2) + "px"));
      Dom.setStyle(oDiv, "left", ((wSize[0] - 200) / 2) + "px");
      Dom.setStyle(oDiv, "width", "200px");
      Dom.setStyle(oDiv, "height", "200px");

   },

   loadDetails:function () {
      var Common = dome.util.Common;
      var Event = dome.util.Event;
      var Dom = dome.util.Dom;
      var Anim = dome.fx.Anim;
      var wSize = Common.getWindowSize();
      var wScroll = Common.getScroll();

      var xmlRoot = DWBookingHotel.xhr.getResponseXML();

      var oDiv = document.getElementById("DWBookingHotelDetails");
      oDiv.className = "DWBookingHotelDetails_content";
      Dom.setStyle(oDiv, "overflow", "hidden");

      var node = document.createElement("div");
      Dom.appendChild(oDiv, node);
      Dom.setStyle(node, "width", "600px");
      Dom.setStyle(node, "opacity", "0");
      node.innerHTML = Dom.getChildText(xmlRoot, "xhtml");

      var size = Common.getSize(node);
      var pos = Common.findPos(oDiv);
      var newPos = [(wSize[0] - size[0]) / 2, wScroll[1] + (wSize[1] - size[1]) / 2];
      if (newPos[1] - wScroll[1] < 10) {
         newPos[1] = wScroll[1] + 10;
      }

      Dom.setStyle(oDiv, "position", "absolute");

      var fxDiv = new Anim({
                              element:oDiv,
                              duration:0.5,
                              attribute:{
                                 left:{ from:pos[0], to:newPos[0], unit:"px" },
                                 top:{ from:pos[1], to:newPos[1], unit:"px" },
                                 height:{ from:200, to:size[1], unit:"px" },
                                 width:{ from:200, to:600, unit:"px" }
                              }
                           });
      fxDiv.endEvent.subscribe(function () {
         Dom.setStyle(node, "overflow", "visible");
      });
      fxDiv.start();

      var fxNode = new Anim({
                               element:node,
                               duration:1,
                               attribute:{
                                  opacity:{ from:0, to:1 }
                               }
                            });
      fxNode.start();

      var loadData = Dom.getChildText(xmlRoot, "loadData");
      eval(loadData);
      DWPopupHotel.init();

      Event.addListener(document.getElementById("popupHotelBack"), "click", function (ev) {
         DWBookingHotel.hideDetails();
         Event.stopEvent(ev ? ev : event);
         return false;
      });

   },

   hideDetails:function () {
      var oDiv = document.getElementById("DWBookingHotelDetails");
      if (oDiv) {
         dome.util.Dom.removeChild(document.body, oDiv);
      }

      DWCommon.removeBackground("DWBookingHotelDetails_bg");
   },

   onRoomChange:function (idhot, hasOffer, indice, lista) {
      /* El parámetro lista no se utiliza en la función, más que para que le
       * llegue a la siguiente función (updateSelection), donde se comprueba si es de tipo lista.
       */


      var tipo = idhot.split("_");
      var tamTipo = tipo.length;
      var idLisral;
      /* Si el campo id llega con más valores los separamos */
      if (tamTipo > 1) {
         idhot = tipo[2];
         idLisral = tipo[1];
      }

      var Common = dome.util.Common;

      var form = document.forms["frmHotel" + idhot];

      /* obtener el refres para saber cuántas habitaciones hay. */
      var inpRefres = document.getElementById("refres_" + idhot);
      var tknRefres = inpRefres.value.split("#");

      /* Actualizar el refres a la nueva selección. */
      var numhab = tknRefres.length - 2;
      /* codtou#idhot#hab#hab...*/
      var newref = tknRefres[0] + '#' + tknRefres[1];

      /* Si idLisrral es null significa que no estamos en el tipo lista */

      if (idLisral == null) {
         for (var i = 1; i <= numhab; i++) {
            newref += '#' + Common.getRadioValue(form.elements["refres_" + i]);
         }
      } else {
         var selIndex = 1;
         var valores = new Array();
         var select = document.getElementById("refres_" + idhot).value
         var elemento;
         var elementoSel = document.getElementById("regimen_" + idhot + "_" + selIndex);
         while (elementoSel != null) {
            elemento = elementoSel.value.split("_");
            elemento = elemento["1"];
            valores[selIndex] = elemento;
            selIndex += 1;
            elementoSel = document.getElementById("regimen_" + idhot + "_" + selIndex);
         }
         newref = idhot;
         var tamValores = valores.length;
         for (i = 1; i < tamValores; i++) {
            newref += "#" + valores[i];
         }

         /* newref = idhot+"#"+idLisral; */
      }
      inpRefres.value = newref;

      DWBookingHotel.updateSelection(idhot, hasOffer, indice, lista);
   },

   updateSelection:function (idhot, hasOffer, indice, tipoLista) {
      var Dom = dome.util.Dom;


      var tipo = idhot.split("_");
      var tamTipo = tipo.length;
      var idLisral;

      /* comprobación si viene de DWBookingHotelList o no */

      if (tipoLista == "lista" && tamTipo > 1) {
         idhot = tipo[2];
         idLisral = tipo[1];
      }

      var refres = document.getElementById("refres_" + idhot).value;
      var tknRefres = refres.split("#");

      if (idLisral == null) {
         idLisral = tknRefres[parseFloat(indice) + 1];
      }
      var numhab = tknRefres.length - 2;
      /* codtou#idhot#hab#hab...*/
      /* Si no viene de la lista hará los pasos para el otro caso */

      if (tipoLista != "lista") {
         var spnImptot = document.getElementById("hotelPrice_" + idhot);
         var divSelection = document.getElementById("serviceSelection_" + idhot);
         oGrl = document.getElementById("sst_" + idhot);
         Dom.removeChildren(divSelection);

         if(dome.userAgent().ie != 0 && dome.userAgent().ie <= 7 ){
            var infoImgRed = document.getElementById("imgTrf_" + idhot);
            Dom.removeChild(oGrl, infoImgRed);
         }else{
            Dom.removeChildren(oGrl);
         }


         /* Actualizar datos. */
         var imptot = 0;
         for (var i = 1; i <= numhab; i++) {
            var modalidad = document.getElementById("hotelRoomType_" + i + "_" + tknRefres[i + 1] + "_" + idhot).innerHTML;
            var regimen = document.getElementById("hotelRoomBoard_" + i + "_" + tknRefres[i + 1] + "_" + idhot).innerHTML;
            var price = document.getElementById("hotelRoomPrice_" + i + "_" + tknRefres[i + 1] + "_" + idhot).innerHTML;

            price = /[0-9,.]+/.exec(price);
            price = price[0].replace(/\./, "").replace(/,/, ".");
            imptot += parseFloat(price);

            var oGrl;  //Contenedor de los detalles del servicio
            var oPrg;  //Detalles del servicio
            var oSpan; //Contenido de los detalles del servicio seleccionado
            var oTrf;  // Contenedor de la información de las tarifas
            var oImg;   //imagen de la información de las tarifas


            oPrg = document.createElement("p");
            oPrg.className = "serviceSelection";
            oSpan = document.createElement("span");
            oSpan.className = "serviceRoom";
            oSpan.innerHTML = modalidad;
            Dom.appendChild(oPrg, oSpan);


            if(dome.userAgent().ie <= 7 && dome.userAgent().ie != 0){
               oImg = Dom.getObjectsByClassName("imgTrf_" + idhot + "_" + tknRefres[2])[0];
            }else{
               oImg = document.getElementsByClassName("imgTrf_"+idhot+"_"+tknRefres[2])[0];
            }

            oImgNuevo = oImg.cloneNode(true);
            oImgNuevo.id =  "imgTrf_" + idhot;
            Dom.appendChild(oGrl, oImgNuevo);

            oSpan = document.createElement("span");
            oSpan.className = "serviceBoard";
            oSpan.innerHTML = regimen;
            Dom.appendChild(oPrg, oSpan);


            /* Añado el estado de cada opcion*/
            var cupest;
            if (document.getElementById("hotelRoomCupestPC_" + i + "_" + tknRefres[i + 1] + "_" + idhot)) {
               cupest = document.getElementById("hotelRoomCupestPC_" + i + "_" + tknRefres[i + 1] + "_" + idhot).innerHTML;
               oSpan = document.createElement("span");
               oSpan.className = "serviceCupestPC";
               oSpan.id = "peticion";
               oSpan.innerHTML = cupest;
               Dom.appendChild(oPrg, oSpan);
            } else {
               cupest = document.getElementById("hotelRoomCupestDS_" + i + "_" + tknRefres[i + 1] + "_" + idhot).innerHTML
               oSpan = document.createElement("span");
               oSpan.className = "serviceCupestDS";
               oSpan.id = "disponible";
               oSpan.innerHTML = cupest;
               Dom.appendChild(oPrg, oSpan);
            }
            if (document.getElementById("trf_" + idhot + "2")) {

            }

            Dom.appendChild(divSelection, oPrg);

            if (hasOffer) {
               oSpan = document.createElement("span");
               oSpan.className = "serviceRoomOffer";
               oSpan.innerHTML = '<img src="images/theme/dw/icono-oferta-peq.gif" alt="Habitación en oferta" heigth="20" width="20" />';
               Dom.appendChild(divSelection, oSpan);
            }

            var importe = spnImptot.innerHTML.replace(/([^0-9]*)(?:[0-9\.,]+)([^0-9]*)/, "$1" + imptot.toFixed(2).replace(/\./, ",") + "$2");
            Dom.removeChildren(spnImptot);
            Dom.appendChild(spnImptot, document.createTextNode(importe));
         }
      } else {
         var spnImptot = document.getElementById("hotelPrice_" + idhot + "_" + indice);
         var hotel = DWBookingHotel.lisHotel;
         /* Obtenemos el hotel seleccionado */
         var tamHotel = DWBookingHotel.lisHotel.length - 1;
         for (i = 1; i <= tamHotel; i++) {
            if (hotel[i].codser == tknRefres["1"]) {
               DWBookingHotel.selHotel = hotel[i];
               break;
            }
         }
         /* Obtenemos el lissmo seleccionado */
         tamHotel = DWBookingHotel.selHotel.lissmo.length;
         var selLisral;
         var tamLisral;
         var lisral;
         var codral;
         /* Recorre los hoteles hasta coincidir con el seleccionado para extraer todos sus datos */
         for (i = 0; i < tamHotel; i++) {
            lisral = DWBookingHotel.selHotel.lissmo[i].lisral;
            tamLisral = lisral.length;
            for (var j = 0; j < tamLisral; j++) {
               if (lisral[j].id == idLisral) {
                  selLisral = DWBookingHotel.selHotel.lissmo[i].lisral[j];
                  codral = selLisral.codral.split("#");
                  document.getElementById("tregimen_" + idhot + "_" + indice).innerHTML = codral['1'];
                  break;
               }
            }
            /*document.getElementById("hotelRegAb_"+idhot).innerHTML = codral['0'];*/
         }
         if (document.getElementById("hotelRegAb_" + idhot)) {
            document.getElementById("hotelRegAb_" + idhot).innerHTML = codral['0'];
         }
         importe = selLisral.imptot;
         spnImptot.innerHTML = importe;
         DWBookingHotel.evRadio(idhot);
      }

   },

   updateIdetra:function (idetra) {
      DWBookingHotel.idetra = idetra;

      var searchForm = document.forms["frmHotelSearcher"];
      if (searchForm) {
         searchForm.elements["idetra"].value = idetra;
      }
   },

   showWaitingRates:function (idhot) {
      var Dom = dome.util.Dom;
      var Anim = dome.fx.Anim;

      var container = document.getElementById("hotelRoomOptions_" + idhot);
      var oDiv = document.createElement("div");
      oDiv.className = "DWBookingHotelRates_waiting";

      Dom.appendChild(container, oDiv);
      Dom.setStyle(oDiv, "top", "0");
      Dom.setStyle(oDiv, "width", "100%");
      Dom.setStyle(oDiv, "height", "0");

      var fx = new Anim({
                           element:oDiv,
                           duration:0.5,
                           attribute:{
                              height:{ from:0, to:50, unit:"px"}
                           }
                        });
      fx.start();

   },

   showWaiting:function () {
      var Dom = dome.util.Dom;

      var container = document.getElementById("bookingHotelContent");
      var oDiv = document.createElement("div");
      oDiv.id = "DWBookingHotel_waiting";

      var oImg = document.createElement("img");
      oImg.src = "images/theme/dw/loadingBarA.gif";
      Dom.appendChild(oDiv, oImg);

      DWCommon.createBackground("DWBookingHotel_bg", container);

      Dom.appendChild(container, oDiv);
      Dom.setStyle(oDiv, "position", "absolute");
      Dom.setStyle(oDiv, "top", "0");
      Dom.setStyle(oDiv, "width", "100%");
   },

   hideWaiting:function () {
      var container = document.getElementById("bookingHotelContent");
      var oDiv = document.getElementById("DWBookingHotel_waiting");

      if (oDiv) {
         dome.util.Dom.removeChild(container, oDiv);
      }

      DWCommon.removeBackground("DWBookingHotel_bg");
   },

   /**
    * Cambia los valores de los selects y con ellos la disponibilidad y el precio
    *
    * @param id String
    * @param indice int
    * @param lista String
    */
   cambiaSelects:function (id, indice, lista, hasOffer) {
      var Dom = dome.util.Dom;
      var i;
      /* bucle */
      var sId = id.split(("#"));
      var codser = sId["1"];
      var selLissmo;
      var elemento = document.getElementById("modalidad_" + id + "_" + indice).value;
      var sElemento = elemento.split("_");
      var idLisral = sElemento["1"];
      var hotel = DWBookingHotel.lisHotel;
      /* Obtenemos el hotel seleccionado */
      var tamHotel = DWBookingHotel.lisHotel.length - 1;
      for (i = 1; i <= tamHotel; i++) {
         if (hotel[i].codser == codser) {
            DWBookingHotel.selHotel = hotel[i];
            break;
         }
      }
      /* Obtenemos el lissmo seleccionado */
      tamHotel = DWBookingHotel.selHotel.lissmo.length;
      for (i = 0; i < tamHotel; i++) {
         if (DWBookingHotel.selHotel.lissmo[i].id == idLisral) {
            selLissmo = DWBookingHotel.selHotel.lissmo[i];
            break;
         }
      }

      for (i = 0; i < DWBookingHotel.selHotel.lissmo.length; i++) {
         if (DWBookingHotel.selHotel.lissmo[i].id != selLissmo.id) {
            if(dome.userAgent().ie <= 7){
               infoTrf = Dom.getObjectsByClassName("spn_" + id + "_" + DWBookingHotel.selHotel.lissmo[i].id);
            }else{
               infoTrf = document.getElementsByClassName("spn_" + id + "_" + DWBookingHotel.selHotel.lissmo[i].id);
            }
            for (j = 0; j < infoTrf.length; j++) {
               Dom.setStyle(infoTrf[j], "display", "none");
            }

         } else {

            if(dome.userAgent().ie <= 7 && dome.userAgent().ie != 0){
               infoTrf = Dom.getObjectsByClassName("spn_" + id + "_" + selLissmo.id);
            }else{
               infoTrf = document.getElementsByClassName("spn_" + id + "_" + selLissmo.id);
            }
            Dom.setStyle(infoTrf[0], "display", "");

            oGrl = document.getElementById("ict_" + id);
            Dom.removeChildren(oGrl);
            if(dome.userAgent().ie <= 7 && dome.userAgent().ie != 0){
               oImg = Dom.getObjectsByClassName("spn_" + id + "_" + selLissmo.id)[0];
            }else{
               oImg = document.getElementsByClassName("spn_" + id + "_" + selLissmo.id)[0];
            }

            oImgNuevo = oImg.cloneNode(true);

            if (!!document.all) oImgNuevo.innerHTML = oImg.innerHTML;

            Dom.appendChild(oGrl, oImgNuevo);


         }
      }

      /* Cambia el valor de la disponibilidad */
      var dispo = selLissmo.cupest.split("#");
      if (dispo[0] == 'PC') {
         dispo[0] = 'RQ';
      }


      if (dispo[1] == "Disponible") {
         document.getElementById("dispo_" + id + "_" + indice).className = "disponible_lista";
         document.getElementById("tdispo_" + id + "_" + indice).className = "disponible_lista";
         if (document.getElementById("hotelDisAb_" + id)) {
            document.getElementById("hotelDisAb_" + id).className = "disponible_lista";
         }
      } else {
         document.getElementById("dispo_" + id + "_" + indice).className = "peticion_lista";
         document.getElementById("tdispo_" + id + "_" + indice).className = "peticion_lista";
         if (document.getElementById("hotelDisAb_" + id)) {
            document.getElementById("hotelDisAb_" + id).className = "peticion_lista";
         }
      }
      document.getElementById("dispo_" + id + "_" + indice).innerHTML = dispo[1];
      document.getElementById("tdispo_" + id + "_" + indice).innerHTML = dispo[1];
      if (document.getElementById("hotelDisAb_" + id)) {
         document.getElementById("hotelDisAb_" + id).innerHTML = dispo[0];
      }
      document.getElementById("regimen_" + id + "_" + indice).value = elemento;
      var lisral = selLissmo.lisral;
      var TamLisral = lisral.length;

      var selRegimen = document.getElementById("regimen_" + id + "_" + indice);
      selRegimen.length = TamLisral;
      /*  Cambia los valores del select del régimen */
      for (i = 0; i < TamLisral; i++) {
         var sCodral = lisral[i].codral.split("#");
         selRegimen.options[i].text = sCodral[1];
         selRegimen.options[i].value = sElemento[0] + "_" + lisral[i].id + "_" + sElemento[2];
      }
      selRegimen.options["0"].selected = true;
      var idHotel = document.getElementById("regimen_" + id + "_" + indice).value;
      document.getElementById("hotelPrice_" + id + "_" + indice).innerHTML = lisral["0"].imptot;
      /*      var oferta = lisral["0"].lisofe;
       if(oferta == null){oferta = 'sinoferta';}*/
      DWBookingHotel.updateSelection(idHotel, hasOffer, indice, lista);

   },

   addSelectsRegimen:function (idhotel, id, coddis) {
      /*  document.writeln(idhotel+"-"+id+"-"+coddis+"<br/>");*/
      var opciones;
      for (var i = 1; i < coddis; i++) {
         var obj = document.getElementById("regimen_" + idhotel + "_1");
         opciones = document.getElementById("regimen_" + idhotel).appendChild(obj).options;
         var nuevo = document.createElement('SELECT');

         document.getElementById("regimen_" + idhotel).appendChild(nuevo);
      }
   },


   /**
    * Cambia el precio del hotel seleccionado
    * @param idHotel String
    */
   evRadio:function (idHotel) {
      var indice = 1;
      var importeTot = 0;
      var preTot;
      var precio;
      var importe;
      if (indice >= 1) {
         precio = document.getElementById("hotelPrice_" + idHotel + "_" + indice);
         while (precio != null) {
            importe = precio.innerHTML.split(" ");
            importe = /[0-9,.]+/.exec(String(importe));
            importe = importe[0].replace(/\./, "").replace(/,/, ".");
            importeTot += parseFloat(importe);
            importeTot = importeTot * 100;
            importeTot = Math.floor(importeTot);
            importeTot = importeTot / 100;

            indice += 1;

            precio = document.getElementById("hotelPrice_" + idHotel + "_" + indice);
         }
      }
      preTot = document.getElementById("hotelPriceTot_" + idHotel);
      preTot.value = String(importeTot);
      preTot.innerHTML = String(importeTot).replace(".", ",") + " €";
   },
   /**
    *
    * @param idhot String
    */
   SelecRadio:function (idhot) {
      var formulario = "frmHotel_" + idhot;
      var i = 1;
      var hab = '';
      var idhab;
      var reg;
      // DWBookingHotel.onSubmit(selec1[1]);
      var inp = document.getElementById(formulario).elements["idetra"];
      if (inp) {
         inp.value = DWBookingHotel.idetra;
      }
      var refres = document.getElementById("refres_" + idhot).value
      reg = document.getElementById("regimen_" + idhot + '_' + i);
      while (reg) {
         idhab = reg.value.split('_');
         hab += "#" + idhab['1'];
         i += 1;
         reg = document.getElementById("regimen_" + idhot + '_' + i);
      }
      document.getElementById('refres_' + idhot).value = idhot + hab;
      var inp = document.forms["frmHotel_" + idhot].elements["idetra"];
      if (inp) {
         inp.value = DWBookingHotel.idetra;
      }
      document.getElementById(formulario).submit();
   },

   despliega:function (idhot) {
      var elemento = document.getElementById("tablaAux_" + idhot);
      var capa = document.getElementById("contAux_" + idhot);
      var Common = dome.util.Common;
      var Dom = dome.util.Dom;
      var Anim = dome.fx.Anim;
      var h = Common.getSize(capa)[1];
      var fx;

      if (elemento.style.display == "none") {

         DWBookingHotel.fx.muestraCapa = new Anim({
                                                     element:capa,
                                                     duration:0.6,
                                                     attribute:{
                                                        opacity:{ from:1, to:1}
                                                     }
                                                  });
         DWBookingHotel.fx.muestra = new Anim({
                                                 element:elemento,
                                                 duration:0.6,
                                                 attribute:{
                                                    opacity:{ from:0, to:1}
                                                 }
                                              });
         /* DWBookingHotel.fx.muestra.endEvent.subscribe(function () {*/
         DWBookingHotel.fx.muestraCapa.start();

         /*         });*/
         Dom.setStyle(elemento, "display", "");
         DWBookingHotel.fx.muestra.start();

         //
         // DWBookingHotel.fx.muestra.start();


      } else {

         DWBookingHotel.fx.ocultaCapa = new Anim({
                                                    element:capa,
                                                    duration:0.6,
                                                    attribute:{
                                                       /*height: {from: h, to: 0, unit:"px"},*/
                                                       opacity:{ from:1, to:0}
                                                    }
                                                 });
         DWBookingHotel.fx.oculta = new Anim({
                                                element:elemento,
                                                duration:0.6,
                                                attribute:{
                                                   opacity:{ from:1, to:0}
                                                   /*height: {from: h, to: 0, unit:"px"}*/
                                                }
                                             });
         DWBookingHotel.fx.ocultaCapa.endEvent.subscribe(function () {
            DWBookingHotel.fx.oculta.start();
            Dom.setStyle(elemento, "display", "none");
         });
         DWBookingHotel.fx.ocultaCapa.start();

      }


   },


   /** Actualiza el idetra por si se ha modificado */
   onSubmit:function (id) {
      var inp = document.forms[id].elements["idetra"];
      if (inp) {
         inp.value = DWBookingHotel.idetra;
      }
   }
};

(function () {
   /* Dependencias. */
   dome.include("dome.util.Event");

   dome.util.Event.onDomReady(DWBookingHotel.init);
})();

