jQuery.fn.prepare_slider = function(){	
		var x_pos = 0;
		var li_items_n = 0;	
		var right_clicks = 0;		
		var left_clicks = 0;					
		var li_col = jQuery("#slider_list > li");		
		var li_width = li_col.outerWidth(true);		
		var viewWindow = Math.round(jQuery('.box-top').width()/li_width);
		
		li_col.each(function(index){			
			x_pos += jQuery(this).outerWidth(true);
			li_items_n++;								
		})	
		
		right_clicks = li_items_n - viewWindow;
		total_clicks = li_items_n - viewWindow;		
		
		jQuery('#slider_list').css('position','relative');
		jQuery('#slider_list').css('left','0px');
		jQuery('#slider_list').css('width', x_pos+'px');
		
		var is_playing = false;
		var completed = function() { is_playing = false; }

		jQuery('#left_but').click( function(){													
			cur_offset = jQuery('#slider_list').position().left;
			if (!is_playing){						
				if (left_clicks > 0) {
						is_playing = true; jQuery('#slider_list').animate({'left': cur_offset + li_width + 'px'}, "slow", "swing", completed); 
						right_clicks++; 
						left_clicks--;
					} 
					else {
						is_playing = true;
						jQuery('#slider_list').animate({'left':    -li_width*total_clicks	+ 'px'}, "slow", "swing", completed); 
						right_clicks = 0;
						left_clicks = total_clicks;
					}
			}
		});		

		jQuery('#right_but').click( function(){
			if (!is_playing){			
				cur_offset = jQuery('#slider_list').position().left;			
			 	if (right_clicks > 0) {
						is_playing = true; 
						jQuery('#slider_list').animate({'left': cur_offset - li_width + 'px'}, "slow", "swing", completed );
						right_clicks--; left_clicks++; 
				} 
				else { 
						is_playing = true; jQuery('#slider_list').animate({'left':    0	+ 'px'}, "slow", "swing", completed ); 
						left_clicks = 0;
						right_clicks = total_clicks;
					}			 
			}
		});	
		
	}

jQuery.fn.over = function(){						
	jQuery(this).hover(
	   function () {
	 	 jQuery(this).addClass("over");
	   },
	   function () {
	 	 jQuery(this).removeClass("over");
	   }
	 );		
   }

function removeAll()
{
	jQuery('#lbOverlay').remove();
	jQuery('#lbCenter').remove();
	jQuery('#lbBottomContainer').remove();
	return false;
}

jQuery(document).ready(function(){ 
	jQuery('#mb').click(function() {
		var lbOverlay = '<div id="lbOverlay" style="visibility: visible; opacity: 0;filter: alpha(opacity=0);ZOOM:1; top: 0px; height: 864px;"></div>';
		var lbCenter = '<div id="lbCenter" style="width: 425px; height: 350px; margin-left: -212px; top: 47.4667px; background: none repeat scroll 0% 0% rgb(255, 255, 255);"><embed height="350" width="425" quality="high" name="flvvideo" id="flvvideo" style="" src="http://vimeo.com/moogaloop.swf?clip_id=10605651&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash"></div>';
		var lbBottomContainer = '<div id="lbBottomContainer" style="top:207px; margin-left: -212px; width: 425px;"><div id="lbBottom" style="margin-top: 0px;"><a id="lbCloseLink" href="#"></a><div id="lbCaption">Vidéo de démonstration</div><div id="lbNumber"></div><div style="clear: both;"></div></div></div>';
		var url = jQuery(this).attr("href");
	
		jQuery('body').append(lbOverlay);
		jQuery('#lbOverlay').animate({
			opacity: 0.8
		});
		jQuery('body').append(lbBottomContainer);
		jQuery('body').append(lbCenter);
		var video = jQuery('#video_block').html();
		jQuery('#lbCenter').html(video);
		jQuery('#lbBottomContainer').animate({
			top: '407px'
		},1000);
		jQuery('#lbCloseLink').click(function(){
			removeAll();	
			return false;
		});
		jQuery('#lbOverlay').click(function(){
		    removeAll();
		    
		});
		return false;
	});

	jQuery('body').click(function(){
	//	removeAll();
	});
	
	
});



