$(window).load(function(){
	
	
	 carrousel('carrousel-1',128,1,500);
	 carrousel('carrousel-2',128,1,500);
	 carrousel('carrousel-3',128,1,500);
	 
	 padding();
	 
	 if(isIE6())
	 {
	 	remplacePng('illu_produit');
	 	remplacePng('attachment-univers');
	 }
      $('p.deroulant').click(function() {
			if($(this).is('.open')){
			$('.masque').slideUp();	
			$(this).removeClass('open');
			}
			else{
			$(this).next('.masque').slideDown();
			$('.open').next('.masque').slideUp();	
			$('.open').removeClass('open');
			$(this).addClass('open');
			}			
	 });
	
	lightbox();
});



function lightbox(){
	$('.lightbox').click(function(){
		
		id=this.id;
		
		var  top, left;
		top=($(window).height() - 455) / 2 + $(window).scrollTop();
		left=($(window).width() - 900) / 2 + $(window).scrollLeft();
		
		$('body').append('<div id="zoom" style="position:absolute;top:0;left:0;background:#967151;opacity:0.8;height:'+$(document).height()+'px;width:'+$(window).width()+'px"></div>');
		$('body').append('<div id="fermer" style="position:absolute;top:'+(top-20)+'px;left:'+(left+800)+'px;background:#f3efeb;color:#967151;height:16px;width:100px;text-align:right"><a href="#" style="color:#967151;font-size:11px;line-height:16px;padding-right:5px;">retour à la page &gt; </a></div>');
		$('body').append('<img class="lightbox_big" src="/wp-content/themes/biodeal/images/'+id+'.png" alt="" style="position:absolute;top:'+top+'px;left:'+left+'px;" />');
			
		return false;
	});
}


$('#fermer').live('click',function(){
	$('.lightbox_big').remove();
	$('#zoom').remove();
	$('#fermer').remove();
});

function padding(){
	var padding;
	$('.item img').each(
		function(){
			if($(this).height()<130)
			{
				padding=(130-$(this).height())/2;
				$(this).css({'padding-top':padding+'px'});
				$(this).css({'padding-bottom':padding+'px'});
			}
		}
	);
}


function isIE6()
{
	var IE6 = false

	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf('(',0);
	var intSplitEnd = strChUserAgent.indexOf(')',0);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	if(strChMid.indexOf('MSIE 6') != -1) IE6 = true;
	return IE6;
}

function remplacePng(classe){
	
	$('.'+classe).each(function(){
		$(this).attr('src',$(this).attr('src').replace('.png','.gif'));
	});
}
