$(document).ready(function(){
	
	$("#inner_video_container").paginate({button_class:"browse_video",display_width:"448"});
	
	$(".featured_video_thumb").hover(function(){
		$(this).children(".featured_video_hover").show();	
	},function(){
		$(this).children(".featured_video_hover").hide();	
	});
	
	$(".featured_video_hover").live("click",function(){
		window.location = $(this).parent().children("a").attr("href");	
	});
	
});

(function($) {  
   $.fn.paginate = function(options) {  
	var defaults = { width : "" , button_class : ""};  
	    defaults = $.extend(defaults, options);  
	var id = $(this).attr("id");
	var display_width = defaults.display_width;
		   $("."+defaults.button_class).each(function(){
				if($(this).attr("move")=="left"){
					$(this).hide();
				}
			});
			
			
			
			
			$(this).children().first().addClass("current");
			$this = $(this);
			$("."+defaults.button_class).click(function(){
			 if($this.children().length>1){

				var move = $(this).attr("move");
				var target =   (move == "right") ? $(".current").next() : $(".current").prev();
				var ttarget_type =  ( move == "right") ? typeof(target.next().attr("id")) : typeof(target.prev().attr("id"));
				if( ttarget_type == 'undefined' ) $(this).hide(); //remove && move == "left"
				if(move == "right"){  $('#'+id).animate({ left : '-='+display_width}); }else{  $('#'+id ).animate({ left : '+='+display_width}); }
				if( $(this).attr("move") == "right") $(this).prev().show(); else $(this).next().show();
				$(".current").removeClass("current");
				target.addClass("current");
			  }else{
				if($(this).attr("move")=="right"){
					$(this).effect("shake", { times:2},100);
				}
			  }
			});
			
	 return this;  
   };  
 })(jQuery);  
