OtherTodd = function() {}


$(function() {
  $('.snipe').css('display', 'normal');

  placeholder = new OtherTodd.ImagePlaceholder('img.photo');
  OtherTodd.animateScrolling();

  $('.slideshow').cycle({
		fx: 'fade', 
    timeout: 8000
	});

  $('a.external').click(function(){
      window.open(this.href);
      return false;
  });


});


OtherTodd.animateScrolling = function() {
  scrollSize = 104;
  scrollDuration = 250
  $('#strip').css('overflow', 'hidden');

  $('#down, #up').show();

  $('#down').click(function() {
    currentScroll = $('#strip').scrollTop();
    $('#strip').animate({scrollTop: (currentScroll + scrollSize)}, scrollDuration);
  });
  
  $('#up').click(function() {
    currentScroll = $('#strip').scrollTop();
    $('#strip').animate({scrollTop: (currentScroll - scrollSize)}, scrollDuration);
  });
  

  $("div.scrollable").scrollable({ 
       vertical:true,  
       size: 3 
   });
  
}


OtherTodd.ImagePlaceholder = function(image_selector) {

  function preloadImage(imgSrc, callback) {
    var objImagePreloader = new Image();

    objImagePreloader.src = imgSrc;
    if(objImagePreloader.complete){
      callback();
      objImagePreloader.onload=function(){};
    } else {
      objImagePreloader.onload = function() {
        callback();
        //    clear onLoad, IE behaves irratically with animated gifs otherwise
        objImagePreloader.onload=function(){};
      }
    }
  }

  $(image_selector).each(function() {
    var image_element = $(this);
    image_element.wrap('<span class="image-placeholder"></span>');
    preloadImage(image_element.attr('src'), function(){
      image_element.parent().removeClass('image-placeholder');
    });
  });
}


