jQuery.fn.videos = function (options) {                      
		var options = jQuery.extend({
		swf: "/resources/swf/videoplayer1.1.swf",
		width: 640,
		height: 360
	}, options);
	
	$('.vscrollable').width($('.vscrollable .preview_').length*132);
	
	function view(ns) {								
		$(ns).find('.videotitle_').html($(ns).find(".current").find(".videotitle").html());
		$(ns).find('.videocontent_').css('width', options.width).html($(ns).find(".current").find(".videocontent").html());
		$(ns).find('.videoflash_').css({'height': options.height, 'width': options.width}).flash({
			swf: options.swf,
			width: options.width,
			height: options.height,
			flashvars: {
				videoid: $(ns).find(".current").data('video')
			}
		});
	}							
	return this.each( function () {
		var ns = $(this);
		view(ns);								
		$(ns).find(".preview_").bind('click', function () {
			$(ns).find(".preview_").removeClass("current");
			$(this).addClass("current");
			view(ns);
		});
		$(ns).find('.videonext').click( function () {
			$(ns).find('.videoscroll').scrollTo('+=660px', 1000);				
		});
		$(ns).find('.videoprev').click( function () {				
			$(ns).find('.videoscroll').scrollTo('-=660px', 1000);				
		});
	});
}				
$(document).ready( function () {						
	$('.videos').videos();
});
