var currentIcon = 0;
var previousIcon = 0;

$(document).ready(function() {

  $("#thumb-1 .rollover").css("visibility", "visible");
  $("#thumb-1").css("opacity", "1.0");
  window.setTimeout(function() { CSBfleXcroll("flex-1");  }, 500);

  $("#slider > .thumb").click( function() {
    showSlide($("#slider > .thumb").index(this));
  });

  $("#slider > .thumb").mouseenter(function(){
    $(this).fadeTo("fast", 1);
  }).mouseleave(function() {
    if($("#slider > .thumb").index(this) != currentIcon) {
      $(this).fadeTo("fast", 0.65);
    }
  });
  
  $("#about-thumbs").mousemove(function(e) {
    var offset = $(this).offset();
    var y = e.pageY - offset.top;
    var h = $("#slider").height();
    $("#slider").css("top", (h - 450) * y / -450);
  });  
  
});

function showSlide(index) {    
  previousIcon = currentIcon;
  currentIcon = index;

  $("#thumb-" + (previousIcon + 1) + "> .rollover").css("visibility", "hidden");
  $("#thumb-" + (currentIcon + 1) + "> .rollover").css("visibility", "visible");
  $("#thumb-" + (previousIcon + 1)).fadeTo("fast", 0.65);
  $("#thumb-" + (currentIcon + 1)).fadeTo("fast", 1);
  
  if (currentIcon != previousIcon) {
     $("#slide-" + (previousIcon + 1)).fadeOut(900);
     $("#slide-" + (currentIcon + 1)).fadeIn(900);
     CSBfleXcroll("flex-" + (currentIcon + 1));
  }
}


