function mycarousel_initCallback(carousel) {

	jQuery('#mycarousel-next').bind('click', function() {
			carousel.next();
			return false;
		});

	jQuery('#mycarousel-prev').bind('click', function() {
			carousel.prev();
			return false;
		});

};



function expand_left(id) {

	main = $('#leftcat_menu'+id);
	sub = $('#leftcat_sub'+id);

	newclass = (main.attr("class")=="expanded") ? "" : "expanded";
	newclass2 = (newclass=="expanded") ? "" : "hidden";

	main.attr("class",newclass);
	sub.attr("class",newclass2);

}

$(document).ready(function() {
	menu2 = $('#left_menu2 div');
	menu2.hover(
		function() {
			this.className = "hover";
		},
		function() {
			this.className = "";
		}
	);

	latestButtons = $('#latestProd-buttons img');
	latestButtons.hover(
		function() {
			tmp = /\/styles\/images\/box_button_(.)_/.exec($(this).attr("src"));
			$(this).attr("src","/styles/images/box_button_"+tmp[1]+"_act.gif");
		},
		function() {
			tmp = /\/styles\/images\/box_button_(.)_/.exec($(this).attr("src"));
			$(this).attr("src","/styles/images/box_button_"+tmp[1]+"_inact.gif");
		}
	);

	relatedArrows = $('#content-related img');
	relatedArrows.hover(
		function() {
			tmp = /\/styles\/images\/related_arrow_(.)_/.exec($(this).attr("src"));
			$(this).attr("src","/styles/images/related_arrow_"+tmp[1]+"_act.gif");
		},
		function() {
			tmp = /\/styles\/images\/related_arrow_(.)_/.exec($(this).attr("src"));
			$(this).attr("src","/styles/images/related_arrow_"+tmp[1]+"_inact.gif");
		}
	);

/*	pages = $('td.pages div');
	alert(pages);
	pages.hover(
		function() {			
			$(this).addClass("act");
		},
		function() {
			$(this).removeClass("act");
		}
	);
*/
	images = $('table.smallimage div');
	images.hover(
		function() {
			$(this).addClass("act");
		},
		function() {
			$(this).removeClass("act");
		}
	);


	arrow = $('table.smallimage td.arrow img');
	arrow.hover(
		function() {
			$(this).attr("src","/styles/images/icon_uarr_act.gif");
		},
		function() {
			$(this).attr("src","/styles/images/icon_uarr_inact.gif");
		}
	);
	arrow = $('table.smallimage td.arrow- img');
	arrow.hover(
		function() {
			$(this).attr("src","/styles/images/icon_darr_act.gif");
		},
		function() {
			$(this).attr("src","/styles/images/icon_darr_inact.gif");
		}
	);

	input = $('#fastSearch-input');
	input.focus(function() {
		if (this.value=="Mots cles") { this.value = ""; }
	});
	input.blur(function() {
		if (this.value=="") { this.value = "Mots cles"; }
	});

	/*-  FEATURES-RELATED MENU  -*/
	items = $('#feat-rel-menu td');
	items.hover(
		function() {
			$(this).addClass("dact");
		},
		function() {
			$(this).removeClass("dact");
		}
	);
	
	
	items.click(function() {
		tmp = /^show-(.*)$/.exec(this.id);
		if ($('#content-'+tmp[1]).attr("id")) {
			old_cont = $('.feat-rel-table');
			old_cont.css("display","none");
			display = ($.browser.name=="msie"&&parseInt($.browser.version)<=7) ? "block" : "table";
			$('#content-'+tmp[1]).css("display",display);
			tabs = $('#feat-rel-menu td');
			$(tabs).removeClass("act");
			$(this).addClass("act");			


		   
			//if($(".jcarousel-skin-tango").children("div.jcarousel-container").length ==0 ){
		  $(".jcarousel-skin-tango").jcarousel({
			scroll: 3,
					    initCallback: mycarousel_initCallback,
					  
				// This tells jCarousel NOT to autobuild prev/next buttons
				buttonNextHTML: null,
				buttonPrevHTML: null
		  });  	 
			//}
          }      

		return false;
	});
		  
		  $("#mycarousel_0").jcarousel({
			scroll: 3,
				initCallback: mycarousel_initCallback,
				// This tells jCarousel NOT to autobuild prev/next buttons
				buttonNextHTML: null,
				buttonPrevHTML: null
					  }); 
		  
		  $("#mycarousel_1").jcarousel({
			scroll: 3,
				initCallback: mycarousel_initCallback,
				// This tells jCarousel NOT to autobuild prev/next buttons
				buttonNextHTML: null,
				buttonPrevHTML: null
					  }); 
});
function changeImg(thisdiv,height){
	/*images.click(function() {
				tmp = $('table.smallimage div');
				tmp.removeClass("selected");
				$(thisdiv).addClass("selected");
		*/
				var arrBigImg=$(thisdiv).children('span');		
				var arrSmallImg=$(thisdiv).children('img');
				
				var tmpsrc=$('#big-prod-image').attr('src');
				var tmpsrc_thumb=$('#big-prod-image-thumb').attr('src');
				if(parseInt($(arrBigImg[0]).attr('value'))>height){
					$('#big-prod-image').attr('height',height);
				}
				$('#big-prod-image').attr('src',$(arrBigImg[0]).attr('src'));		
				$('#big-prod-image-thumb').attr('src',$(arrSmallImg[0]).attr('src'));
				
				
				$(arrSmallImg[0]).attr('src',tmpsrc_thumb);		
				$(arrBigImg[0]).attr('src',tmpsrc);
				//});
}