$(document).ready(function(){

	jQuery.fn.reverse = [].reverse;


	/* Gestione foto pagina prodotto */
	imgh = $('#image_container').find('img').height();
	$('#image_container').css('height',imgh+'px');
	$('.product_image').reverse().each(function(){
		$(this).clone().css({width:'100px',height:'auto'}).prependTo('#thumb_container');
	});
	$('#thumb_container img').each(function(){
		$(this).bind('click',function(){
			thisindex = $(this).index();
			$('.product_image').css({zIndex:1,position:'relative'});
			$('.product_image').eq(thisindex).css({zIndex:2,position:'absolute',top:0,left:0});
		});
	});
	
	
	


	/* Animazione nuvole */
	$('#clouds').animate({
		left: -1500
	},100000,'linear', function(){
		$('#clouds').css('left',1920).animate({
		left: -1500
	},100000);
		
	});

	/* Menu categorie */
	$('#menu_categories li').hover(
		function(){
			$(this).find('.content_box').stop().animate({
				height:315,
				opacity:1
			},400,'swing');
		}, 
		function(){
			$(this).find('.content_box').stop().animate({
				height:0,
				opacity:0
			},400,'swing');
		}
	);
	
	/* Menu lingue */
	$('#menu_languages').hover(
		function(){ $('#menu_languages li').slideDown(200,'swing');},
		function(){ $('#menu_languages li').not('.active').slideUp(100,'swing');}
	);

	/* Menu laterale */
	$('.menu_side h3').toggle(
		function(){ 
			$(this).animate({height:"65px"},200,function(){$(this).parent().addClass('active');});
			$(this).next().slideDown(200,'swing');
			$(this).children($('.menu_side h3 span')).fadeIn(200,'swing');
		},
		function(){ 
			$(this).animate({height:"20px"},200,function(){$(this).parent().removeClass('active');});
			$(this).children($('.menu_side h3 span')).fadeOut(200,'swing');
			$(this).next().slideUp(100,'swing');
		}
	);
});
