/**
 * Pfuiiit By Jonathan Cambier 2010
 * Licensed under the Creative Commons License:
 * http://creativecommons.org/licenses/by/3.0/
 *
 * Date: 2010-03-16
 */
(function($){
    $.fn.pfuit = function(h){
	h = jQuery.extend({
            width: 150,
			height: 150,
			effect: 'easeOutBounce',
			duration: 250,
			interval:15000
		}, h);
		
		
		function gogogo(g){
			
            g.each(function(i){
				$(this).css({'overflow':'hidden','width':h.width,'height':h.height,'position':'absolute'}); 
				var counter = 0;
				$(this).find('div').each(function(){
					$(this).css({left:(h.width*counter)+"px",'position':'absolute'});
					counter++;
				});	
				var temp =$(this).first();
				temp.addClass('first');
				temp.next().addClass('second');
			});
			setInterval('anim()',h.interval);	
		}
		function anim(){
			var i =0;
			$(this +' div').each(function(){
				var leftEvent = $(this).position().left-h.width;
				//alert(leftEvent);
				$(this).animate({left:leftEvent+"px"},h.duration,h.effect);
				i++;
			});
			$('.first').css({'left':(i*h.width)+"px"}).addClass('temp').removeClass('first');
			$('.second').addClass('first').removeClass('second');
			$('first').next().addClass('second');
		}
		gogogo(this);
		return this;
	}	
})(jQuery);
