$.enableConsole = false;
$.fn.console = $.console = function(method){
	if (window.console && console[method] && $.enableConsole)
		console[method].apply(this, [].splice.call(arguments,1))
	return this;
}
$.enableConsole = true;

// easing methods
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}
});


$.fn.sponsorRotator = function(settings){
	var config = {
		ms: 5000	
	};
	if(settings) $.extend(config, settings);
	return this.each( function(){
		var pic = $(this).find('.SponsorWrapperCnt');
		var timer;
		function animatePic() {
			timer = setInterval(function() {				 
					pic.animate({opacity:0},400,'easeInOutSine', function(){
					pic.scrollTop(0);
					pic.append(pic.children().filter(":first-child"));
					pic.animate({opacity:1},400,'easeInOutSine');
				});
			},config.ms);
		}	
		animatePic();
	})
}


$(window).load( function(){

	$('.TeaserHome .SponsorWrapper').sponsorRotator();

})