
$(document).ready(function() {

  if($("#columns .portfolio").length > 0) {

    $(".example img").load(function() {
    
      $(".example a").click(function() {
        ExamplePlayer.start();
        return false;
      });
        
      ExamplePlayer.start();
    });
  }

});

var ExamplePlayer = {
  start: function() {
    // contentWidth = $("#columns").width();
    // navigationWidth = $("#navigation").width();
    // containerWidth = $("#content_container").width();
    // 
    // moveTo = "-" + (contentWidth ) + "px"
    //    
    // console.log("Move to: "+ moveTo);
    // $("#columns").animate({
    //   left: moveTo}, 6000, function() {
    //     
    //   });
    
    $("#content_slider").slider({
      animate: true,
      change: function(e, ui) {
        var maxScroll = $("#column_container").attr("scrollWidth") - 
                          $("#column_container").width();

          $("#column_container").animate({scrollLeft: ui.value * 
             (maxScroll / 100) }, 1000);
      },
      slide: function(e, ui) {
        var maxScroll = $("#column_container").attr("scrollWidth") - 
                          $("#column_container").width();

          $("#column_container").attr({scrollLeft: ui.value * (maxScroll / 100) });
        
      }
    });
    // parentWidth = $(".example").width();
    // imageWidth = $(".example img").width();
    // 
    // moveTo = "-" + (imageWidth - parentWidth) + "px"
    //   
    // $(".example a").fadeOut();
    // 
    // $(".example img").animate({
    //   left: moveTo
    //   }, 6000, function() {
    //   // go back?
    //   }
    // );
    // 
    // $(".example img").click(function() {
    //   $(this).stop();
    //   $(".example a").fadeIn();
    // });
    // 
    // parentLeft = $(".example").position().left;
    // parentRight = parentLeft + parentWidth;
    //  
    // $(".example img").draggable({
    //   axis: "x",
    //   containment: [parentLeft - (imageWidth - parentWidth), 0, parentRight + (imageWidth - parentWidth), 0]
    // });
  }
}