var $j = jQuery.noConflict();

/* INIT SHADOWBOX */

var shadowBoxConfig 			= {};
shadowBoxConfig.troubleElements = ['select', 'canvas'];
Shadowbox.init(shadowBoxConfig);


$j(document).ready(function() {
	
	/**
	 * Init fade
	 */	
	$j('.fade')
		.live('mouseenter',function(){
			$j(this).find('div:first').stop().fadeTo(250, 1);
		})
		.live('mouseleave', function(){
			$j(this).find('div:first').stop().fadeTo(50, 0);
		});
	
	/* MENU GAUCHE */
	//  Initialize ou non le bouton 'lire la suite'
    if($j('#box_left_text').length>0){
		if($j('#box_left_text').height() >= maxHeightColumnLeftBox){
			
			$j('#box_left_text').columnize({balanced: false, height: maxHeightColumnLeftBox, minHeight: minHeightColumnLeftBox});

			$j('#box_left_text div.column').each(function(index){
				$j(this).data('num', index);
			});
			
			$j('#box_left_text').cycle({
				fx:     			'scrollVert',
				next:   			'#btn_content_next',
				prev:   			'#btn_content_prev',
				rev: 				1,
				timeout:			0,
				before: 			function(currSlideElement, nextSlideElement, options, forwardFlag){
					if($j(currSlideElement).data('num') == $j(nextSlideElement).data('num')){
						// Init
						$j('#btn_content_prev').css('display', 'none');
					}else{
						// Desactive active prev buttom
						if($j(nextSlideElement).data('num') <= 0){
							$j('#btn_content_prev').css('display', 'none');
						}else{
							$j('#btn_content_prev').css('display', 'block');
						}
						// Desactive active next buttom
						if( ($j(nextSlideElement).data('num') + 1) >=  $j('#box_left_text div.column').length ){
							$j('#btn_content_next').css('display', 'none');
						}else{
							$j('#btn_content_next').css('display', 'block');
						}
					}
				}
			});
//			if( $j('#box_left_text').length <= 1){
//				$j('#btn_content_prev').css('display', 'none');
//				$j('#btn_content_next').css('display', 'none');
//			}
		}else{
			$j('#btn_content_prev').css('display', 'none');
			$j('#btn_content_next').css('display', 'none');
		}
	};
	
	/* CYCLE PARTNERS */
	//  Initialize the slideshow when the DOM is ready
	 $j('.slide_partners').cycle({
		fx: 		'scrollHorz',
		next: 		'.next',
		prev: 		'.previous',
		timeout: 	5000,
		speed: 		800
	});
	
	/* CYCLE PRODUITS */
	//  Initialize the slideshow when the DOM is ready
	 $j('.slide').cycle({
		fx: 		'scrollHorz',
		next: 		'.next',
		prev: 		'.previous',
		timeout: 	0,
		speed: 		800
	});
	
});

