// JavaScript Document

// Ne pas utiliser l'alias $ déjà utilisé par mootools.
// Prière donc de lancer la fonction jQuery directement

jQuery.noConflict();
jQuery(document).ready(function() { 

	jQuery('body').prepend('<div id="bg_popup"></div>');

	rolloverImage();
	showMenuNavigation();
	
	
	// MODULE FAQ
		jQuery('.foire_aux_questions ul li div').hide();
		jQuery('.foire_aux_questions ul li').css('cursor', 'pointer');
		jQuery('.foire_aux_questions ul li').not('.foire_aux_questions ul li li').click( function() {
			
		jQuery(this).find('div').toggle();
	});
	
	
	// MAJ prix et ref des input hidden EAN pour fiche produit
	if ( jQuery('.taille_produit').size() > 0 && jQuery('.detail_silouhette').size() == 0) {
		jQuery('.taille_produit div').not('.taille-off').click(function(){
			optVal = jQuery(this).next().val();
			p_val = jQuery('#p_val').val();
			
		//	jQuery('.taille_produit div').removeClass('taille-selected');
			jQuery(this).parent().find('div').removeClass('taille-selected');
			jQuery(this).addClass('taille-selected');
			jQuery('#EAN').val(optVal);
			jQuery('#qty').val('1');
			
			maj_prix(p_val);
			
			if (!jQuery('.personalisation_panier option:first').is(':selected') ) {
				jQuery('#infos_ajoutEnfant').show();
			}
			jQuery('.perso_panier').slideDown();
			
		});
	}
	
	// MAJ prix et ref des input hidden EAN pour fiche silhouette
	if ( jQuery('.detail_silouhette').size() > 0) {
		jQuery('.taille_produit div').not('.taille-off').click(function(){
			optVal = jQuery(this).next().val();
			p_val = jQuery(jQuery(this).next()).next().val();

		//	jQuery('.taille_produit div').removeClass('taille-selected');
			jQuery(this).parent().find('div').removeClass('taille-selected');
			jQuery(this).addClass('taille-selected');
			jQuery('#ean_'+p_val).val(optVal);
			jQuery('#qty_'+p_val).val('1');
			changePrice(p_val, optVal);
		});
	}

	jQuery('.encart_hp IMG:not(:first)').css('opacity',0.5);
	
	if( jQuery('.caroussel_hp').size() > 0 ) {
		
		
		function turn_homepage() {
			
			jQuery('.caroussel_hp div:eq(2) img:eq(0)').delay(2500).animate({opacity:0},1000);
			jQuery('.caroussel_hp div:eq(2) img:eq(1)').delay(3000).animate({opacity:0},1000);
			jQuery('.caroussel_hp div:eq(2) img:eq(2)').delay(3500).animate({opacity:0},1000, 
				function(){
					jQuery('.caroussel_hp div:eq(2)').detach().insertBefore('.caroussel_hp div:eq(0)'); 
					jQuery('.caroussel_hp div:eq(0) img').css({'opacity':1});
					turn_homepage();
				}
			);
			
		}
		turn_homepage();
	
	
	}
	
});

