$(document).ready(function(){

  $("#menu").superfish({'autoArrows':false});

  if($.browser.mozilla){
    $("body").addClass("loading");
    $(window).load(function() {
      $("body").removeClass("loading");
    });
  }; 

  //$("#slideshow li").not(':first').find('img').css('opacity', 0.5);

  var elWidth = parseInt($("#slideshow li:first").width());
  
  var elLeft = 0;
  var elZindex = 50;
  $("#slideshow li").each(function(){
    $(this).css({
      position:'absolute',
      left:elLeft,
      zIndex:elZindex
    });
    elZindex--;
    elLeft += elWidth;
  });

  $("#slideshow li").not(':first').find('img').css({'opacity':0.4});
  $("#slideshow a").click(function(){
    //$("#slideshow .slideshow-mask").scrollTo((cur * elWidth), 500);
    var count=0;
    $("#slideshow li").each(function(){
      var left = parseInt($(this).css('left')) - elWidth;
      $(this).animate({'left': left}, 500);
    });

    $("#slideshow ul").append($("#slideshow li:first"));
    $("#slideshow li:first img").animate({'opacity': 1}, 500);
    $("#slideshow li").not(':first').find('img').animate({'opacity':0.4}, 500, function(){
      elLeft = 0;
      elZindex = 50;
      $("#slideshow li").each(function(){
        $(this).css({
          position:'absolute',
          left:elLeft,
          zIndex:elZindex
        });
        elZindex--;
        elLeft += elWidth;
      });    
    });
    return false;
  });
});

