DWHome = {

   /** array de ofertas */
   offer: new Array(),
   offerAbajo: new Array(),

   /* Los contadores empiezan por 2, porque por defecto se empieza mostrando la imagen 1. */
   contador: 1, /* Contador del bannerA */
   contador2: 1, /* Contador del bannerB_01 */
   fx: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("dome.fx.Anim");
      dome.include("dome.util.Dom");

      var loadOk = DWHome.loadData();
      if (loadOk) {
         /*DWHome.fx = {};
         DWHome.temporizador();*/
      }
   },

   rotate: function(rotator){
         //Get the first image
         var current = ($('div.'+rotator+' ul li.show')?
                        $('div.'+rotator+' ul li.show') : $('div.'+rotator+' ul li:first'));

          if ( current.length == 0 ) current = $('div.'+rotator+' ul li:first');

         //Get next image, when it reaches the end, rotate it back to the first image
         var next = ((current.next().length) ?
                     ((current.next().hasClass('show')) ?
                      $('div.'+rotator+' ul li:first') : current.next()) : $('div.'+rotator+' ul li:first'));

         //Un-comment the 3 lines below to get the images in random order

         //var sibs = current.siblings();
          //var rndNum = Math.floor(Math.random() * sibs.length );
          //var next = $( sibs[ rndNum ] );


         //Set the fade in effect for the next image, the show class has higher z-index
         next.css({opacity: 0.0, zIndex: 100})
         .addClass('show')
         .animate({opacity: 1.0}, 1000);

         //Hide the current image
         current.css({zIndex:0});
         current.animate({opacity: 0.0}, 1000).removeClass('show');

      }

};

/* Inicilización. */
(function() {
   /* Dependencias */
   dome.include("dome.util.Event");
   /* Alias */
   var Event = dome.util.Event;
   dome.util.Event.onDomReady(DWHome.init);

})();
