$(function() {
  /* PRODUCT SCROLLER */
  $(".carousel").jCarouselLite({
    btnNext:  "#product_scroller .prev",
    btnPrev:  "#product_scroller .next",
    circular: true,
    visible:  6
  });
  $(".carousel img").mouseenter(function() {
    $("#product_scroller .enlarged").remove();

    var src = $(this).attr("src");
    src = src.replace(/_th_/i, "_pr_");

    var details   = $(this).parents("a").attr("href");
    var specsheet = details.replace('display', 'specsheet');
    if ($(this).parents("a").attr("class")) {
        specsheet = 'specsheet_'+ $(this).parents("a").attr("class") +'.pdf';
    }
    specsheet = "pdfs/"+ specsheet.replace('.html', '.pdf');
    $("#product_scroller").append("<div class=\"enlarged\"><a href=\""+ details +"\"><img src=\""+ src +"\" width=\"150\" height=\"200\" border=\"0\" alt=\"\"><\/a><div class=\"options\"><div class=\"page\"><a href=\""+ details +"\">See more details<\/a><\/div><div class=\"specsheet\"><a href=\""+ specsheet +"\">Download spec sheet<\/a><\/div><\/div><\/div>");

    var offset          = $(this).offset();
    var scroller_offset = $("#product_scroller .enlarged").offset();
    $("#product_scroller .enlarged")
      .css("left", offset.left - scroller_offset.left - 50)
      .hide()
      .fadeIn()
      .mouseleave(function() {
        $(this).remove();
      });
  });

  /* BANNER STAND TOOLTIPS */
  $("#banner-stands a").each(function() {
    if ($("img", this).length) {
      $(this).qtip({
        content: {
          text: "<a href=\""+ $(this).attr("href") +"\">"+ $("span", this).html() +"<\/a>"
        },
        show: "mouseover",
        hide: {
          delay: 250,
          fixed: true,
          when:  "mouseout"
        },
        position: {
          adjust: {
            screen: true
          },
          corner: {
            target:  "rightMiddle",
            tooltip: "leftMiddle"
          }
        },
        style: {
          width: 155,
          padding: 0,
          background: "#000",
          color: '#FFF',
          textAlign: 'left',
          border: {
            width:  2,
            radius: 0,
            color:  "#000"
          },
          tip: {
            corner: "leftMiddle",
            color:  "#000"
          }
        }
      });
    }
  });

  /* FABULOK FADER */
  $(".fader img:gt(0)").hide();
  $("a.style-straight").click(function() {
    $(".fader img:not(.style-straight)").hide();
    $(".fader img.style-straight").show();
  });
  $("a.style-curve").click(function() {
    $(".fader img:not(.style-curve)").hide();
    $(".fader img.style-curve").show();
  });

});
