$(document).ready(function() {
  Cufon.replace('ul#nav > li a', {
    hover: true
  });

  Cufon.replace('ul#offer-tabs li span, ul#inside-tabs li span, .sliding-inside h1, #tabs2content .tabs2box h1, #content-right h1');
  Cufon.replace('.offer-box h1, #floating-promotion h1, #floating-promotion h2', {textShadow: '1px 1px rgba(51, 51, 51, 0.6)'});

  var content = $("#carousel-content #special-offers").html();
  $("#tabs ul li:first").addClass("selected");
  $('#carousel-holder').addClass('special-offers');
  $("#carousel-holder").html(content).jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		visible: 4
    });

  if ($("#carousel_inner .gallery li").size() != 0) {
    $("#carousel_inner").show();
    $("#carousel_inner .gallery").jCarouselLite({
      btnNext: ".next",
      btnPrev: ".prev",
      visible: 5
    });
    Cufon.refresh();
    $("#carousel_inner").hide();
    $("#carousel_inner").fadeIn('normal');
  }


  $("#tabs2content").show();

  $('#events2').show();
  $("#events2 .carousel-inner-footer .image-list-wrapper").jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev",
    visible: 4
  });
  $('#events2').hide();

  $('#special-offers2').show();
  $("#special-offers2 .carousel-inner-footer .image-list-wrapper").jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev",
    visible: 4
  });
  $('#special-offers2').hide();

  $('#latest-highlights2').show();
  $("#latest-highlights2 .carousel-inner-footer .image-list-wrapper").jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev",
    visible: 4
  });
  $('#latest-highlights2').hide();

  $("#tabs2content").hide();

  $("ul#offer-tabs li a").click(function() {
    $("ul#offer-tabs li").removeClass("selected");
    $(this).parent().addClass("selected");
    var el = $(this).attr("href");
    $("#carousel-holder").fadeOut("fast", function() {
      $("#carousel-holder").html($(el).html()).fadeIn("fast");

      if ($('#carousel-holder .no-carousel').length == 0) {
        $('.prev').show();
        $('.next').show();

        $("#carousel-holder").jCarouselLite({
          btnNext: ".next",
          btnPrev: ".prev"
        });
      }
      else {
        $('.prev').hide();
        $('.next').hide();
      }
    });

    $('#carousel-holder').addClass(el.substr(1));

    return false;
  });

  var lastObj = $(".expanded");
  var initWidth = 150;
  var maxWidth = 780;

/*  $("#sliding-content").bind("mouseleave",function() {
    $(".sliding-box").removeClass("expanded").animate({width: "360px"}, { queue:false, duration:400 });
  });*/
  $(".sliding-box").click(function() {
    $(".sliding-box").removeClass("expanded").animate({width: initWidth+"px"}, { queue:false, duration:400 });
    $(this).addClass("expanded").animate({width: maxWidth+"px"}, { queue:false, duration:400 });
    lastObj = this;

    return false;
  });

  $("ul#inside-tabs li a").click(function() {
    if($(this).attr("class") == "active") {
      if($("#tabs2content").attr("class") != "down") {
        $("#tabs2content").addClass("down").slideUp();
      } else {
        $("#tabs2content").removeClass("down").slideDown();
      }
    } else {
      $("#tabs2content").removeClass("down").slideDown();
      $("ul#inside-tabs li a").removeClass("active");
      $(this).addClass("active");
      var obj = $(this).attr("href");
      $("#tabs2content > div").hide();
      $("#tabs2content "+obj).show();
    }

    return false;
  });

  $('ul#inside-tabs li:first a').trigger('click');

  $(".exp-btn").hover(function() {
    $(this).css("background-position", "bottom right");
    $("ul", this).slideDown("fast");
  }, function() {
    $(this).css("background-position", "top right");
    $("ul", this).slideUp("fast");
  });

  $(function() {
    $(".gallery a").lightBox();
  });

  $('#weather_feed').weatherfeed(['EIXX0055']);

  /**
   * HOME PAGE FLOATING PROMOTION ROTATOR
   */

  var promotions_qty = $('#floating-promotion ul li').size();
  var next_promotion = 0;

  var rotate_promotions = function() {
    if (next_promotion == promotions_qty) { next_promotion = 0 }

    $('#floating-promotion ul li').hide();
    $('#floating-promotion ul li').eq(next_promotion).fadeIn(500);

    next_promotion++;
  };

  //rotate_promotions();
  $('#floating-promotion ul li').hide();

  setInterval(rotate_promotions, 6000);


  /**
   * IMAGE ROTATOR FOR INNER PAGES
   */

  $('#imageleft').cycle({fx: 'fade', speed: 2000, timeout: 8000});

});

