$(document).ready(function() { 
	
	$('#container').before('<div class="opacite"></div><div id="ajoutpanier"></div>');
	
	$('.bloc_panier p').click(function(){
		location = $('#lienPanier a').attr('href');
	});	
	
	rolloverImage();
	showTotalHorsTaxe();
	zoomListe();
	
	// ACCEPT CGV PANIER
	if( $('.cgv #cgv').size != 0 ) {
		$('.cgv #cgv').change(function(){
			$('.cgv a').css("color", "green")
		});
	}
	
	// ACTU HOMEPAGE 
	if ( $('#content').has('.actu_box') ) {
		$('.actualites').click(function(){
			$('#hp_flash').css('visibility','hidden');
			$('.actu_box').fadeIn();
			return false;
		});
		$('.actu_box .fermer').click(function(){
			$('.actu_box').fadeOut(500, function(){$('#hp_flash').css('visibility','visible');});
			
			return false;
		});
	}
	
	// USE ADRESSE FACTURATION POUR LIVRAISON
	if( $('.choix_livraison').size() > 0 ) {
		$('.choix_livraison .sous_titre_encart input').change(function(){	
						
				if( $(this).parent().next().is(':animated') ) {
					if ( $(this).attr("checked") == true ) {
						$(this).attr("checked", false);
					} else {
						$(this).attr("checked", true); 
					}
					return false;
				}
				
				if( $(this).is(':checked') ) {
					$(this).parent().next().slideDown(500);
					$('.adresse_facturation:first span').hide();
				}	else {
					$(this).parent().next().slideUp(500);
					$('.adresse_facturation:first span').show();
					
				}
		});	
		if ( $('.choix_livraison .sous_titre_encart input').attr("checked") == true ) {
			$('.form_autre_adresse').slideDown(); 
			$('.adresse_facturation:first span').hide();
		}
		
		$('.form_autre_adresse ul').append('<li class="erreur validation"></li>');
		$('.form_autre_adresse ul li.validation img').click(function(){
			var formIsOk = true;
			
			if( $('.form_autre_adresse input[type=radio]:checked').size() == 0 ) {	
				formIsOk = false;	
			}
			$('.form_autre_adresse li:contains("*") input[type=text]').each(function(){
				if ($(this).val() == "") {	formIsOk = false;	}
			});
			
			if ( formIsOk == true ) {
				$('.form_autre_adresse ul li:last').html('Votre adresse a &eacute;t&eacute; valid&eacute;e')
			} else {
				$('.form_autre_adresse ul li:last').html('Veuillez remplir tous les champs obligatoires')
			}
			
		});
	}
	
	$('.newsletter input[type=text]').form_exemple('Recevez nos offres par email');
	$('.recherche input[type=text]').form_exemple('Saisissez ici un mot-clef ou un produit');
	
	// FORMULAIRE : ajout de class afin de pouvoir cibler les différents <input type="">
	$(":text, :password").addClass("input-text");
	$(":radio").addClass("input-radio");
	$(":checkbox").addClass("input-checkbox");
	$(":image").addClass("input-image");
	

	
	
});


