/*
 * jQuery doTimeout: Like setTimeout, but better! - v1.0 - 3/3/2010
 * http://benalman.com/projects/jquery-dotimeout-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);


/*!
 * jQuery imagesLoaded plugin v1.0.4
 * http://github.com/desandro/imagesloaded
 *
 * MIT License. by Paul Irish et al.
 */

(function($, undefined) {

/*
  // $('#my-container').imagesLoaded(myFunction)
  // or
  // $('img').imagesLoaded(myFunction)

  // execute a callback when all images have loaded.
  // needed because .load() doesn't work on cached images

  // callback function gets image collection as argument
  //  `this` is the container
*/
  $.fn.imagesLoaded = function( callback ) {
    var $this = this,
        $images = $this.find('img').add( $this.filter('img') ),
        len = $images.length,
        blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';

    function triggerCallback() {
      callback.call( $this, $images );
    }

    function imgLoaded( event ) {
      if ( --len <= 0 && event.target.src !== blank ){
        setTimeout( triggerCallback );
        $images.unbind( 'load error', imgLoaded );
      }
    }

    if ( !len ) {
      triggerCallback();
    }

    $images.each( function() {
	/* cached images don't fire load sometimes, so we reset src. */
      if (this.complete || this.complete === undefined){
        var src = this.src;
          /* webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
          data uri bypasses webkit log warning (thx doug jones) */
        this.src = blank;
        var t = this;
        $.doTimeout( 1, function() {t.src = src;});
        //this.src = src;
      }
    }).bind( 'load error',  imgLoaded );

    return $this;
  };
})(jQuery);

$(document).ready( function() {
	$('#front .content').imagesLoaded( function( $images) {
		// 20 seconds per 154 pix = (h / 154) * 20 * 1000 =  h * (20K / 154)
	 var t = 0;
	 var m = ($('#front .content > div > div').height() - $('#front .content > div').height());
	 
	 var animate = function() {
	 	if ( t >= m) return;
	 	t = t + 154;
	 	if ( t > m) t = m;
		$('#front .content > div > div').animate(
			{top: -t},
			{duration: 1000, complete: function() {$.doTimeout( 2000, animate); }}
		);	 	
	 };
	 
/* 
		$('#front .content > div > div').animate(
			{top: -($('#front .content > div > div').height() - $('#front .content > div').height())},
			{duration: $('#front .content > div > div').height() * (20000.0 / 154.0) }
			);

 */
 		$.doTimeout( 7000, animate);
		
		$('#front .content > div > div .activity').click( function() {
			window.location.href = $(this).find('a.more').attr('href');
		});
	});
	
});
