(function($) {
	$.fn.videoCarousel = function(options){

		// default configuration properties
		var defaults = {
		};

		var options = $.extend(defaults, options);

		return this.each(function() {
			var mainObj = $(this);
			var wrapperObj = $('div.videoCarouselWrapper', mainObj);
			var videoItems = $('div.item', mainObj);
			var rotateItems = $('div.videoRotate a', mainObj);
			var currentObj = $(rotateItems[0]);

			for(var i=0; i<videoItems.length; i++){
				$(rotateItems[i]).attr('pos', i);
				if(i!=0){
					$(rotateItems[i]).bind('click', function(){
						toggle($(this));
					});
				}
			}
			
			function toggle(obj){
				obj.addClass('selected');
				obj.unbind('click');
				wrapperObj.css('marginLeft', (-306)*obj.attr('pos'));
				
				currentObj.removeClass('selected');
				currentObj.bind('click', function(){
					toggle($(this));
				});
				currentObj = obj;
			}
		});

	};

})(jQuery);

