
(function($) {
var opts;
var id = 0;
$.fn.scroller = function(options)
{
	var defaults = { 
		switchtime: 1000,
		center: 1,
		axis: 'x',
		effect: 'linear'
		};
	
	opts = $.extend(defaults, options);
	
	$.scrollTo.defaults.axis = opts.axis;
	return $(this).each(function()
	{
	if(opts.center == 1) $.centerIt(this);
	});
};
$.fn.nextScrollSlide = function()
{
	return $(this).each(function()
	{
	var $self = this;
	$.nextScrollSlide($self);
	});
};
$.fn.prevScrollSlide = function()
{
	return $(this).each(function()
	{
	var $self = this;
	$.prevScrollSlide($self);
	});
};
$.extend({
	nextScrollSlide: function(o)
	{
	var $self = $(o);
	id++;
	if($self.find('div.video_item').length == 0) return;
	if($self.find('div.video_item:eq('+(id+2)+')').length == 0)
	{
		id = 0;
	}
	$self.stop().scrollTo( $self.find('div.video_item:eq('+id+')'), opts.switchtime, {easing: opts.effect});
	},
	prevScrollSlide: function(o)
	{
	var $self = $(o);
	id--;
	
	if($self.find('div.video_item').length == 0) return;
	if($self.find('div.video_item:eq('+id+')').length == 0)
	{
		id = $self.find('div.video_item').length-3;
	}
	$self.stop().scrollTo( $self.find('div.video_item:eq('+id+')'), opts.switchtime, {easing: opts.effect});
	},
	
	centerIt: function(o)
	{
	var $self = $(o);
	var top = ( $self.height() - $self.find('div.image').height() ) / 2;
		$self.find('div.image').css('margin-top', top);
	var top = ( $self.height() - $self.find('div.overlay').height() ) / 2;
		$self.find('div.overlay').css('margin-top', top);
	var top = ( $self.height() - $self.find('div.text').height() ) / 2;
		$self.find('div.text').css('margin-top', top);
	}
});
})(jQuery);