$(document).ready(function(){

	/* cufon */
	Cufon.replace('.dax', { fontFamily: 'dax' });
	Cufon.replace('#menu ul li', { fontFamily: 'dax' });
	Cufon.replace('#menuS', { fontFamily: 'dax' });


	/* Comportement Rollover avec class="rollover" */
	$("img.rollover").each(function(){
		attachRollOverEvent(this);
	});

	/* Remplacement image actif avec class="actif" */
	$("img.actif").each( function(){
		attachActif(this);
	});

	/* Fancybox Propriétés */
	$("a.varianteFancy").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true, 'padding': 15, 'frameWidth': 495, 'frameHeight': 500 });

	$(".panierFancy").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true,'frameHeight': 230 });
  $("a.fancy").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true });
	$("a.fancyPasse").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true,'frameWidth': 470,'frameHeight': 220 });

  $("a.fancyCGV").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true, 'frameWidth': 600, 'frameHeight': 500  });
  $("a.fancyVideo").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true, 'padding': 25, 'frameWidth': 320, 'frameHeight': 243 });
  $("a.fancyColoris").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true, 'padding': 0, 'frameWidth': 400, 'frameHeight': 310 });
  $("a#fenetre").fancybox({ 'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': true });

  /* PNG Fix */
  $(document).pngFix();

  $('#menu ul li a.titre').next().hide();

  $('#menu ul li a.titre').bind("click",function(e) {
	  $(this).next().toggle('slow').prev().parent().toggleClass("actif");
	  e.preventDefault();
  });

  $('#inputLettre').bind("click",function(e) {
	  if(this.value == "Saisissez votre email")this.value="";
  }).bind("blur",function(e) {
	  if(this.value == "")this.value="Saisissez votre email";
  });

  $('#inputLogin').bind("click",function(e) {
	  if(this.value == "identifiant")this.value="";
  }).bind("blur",function(e) {
	  if(this.value == "")this.value="identifiant";
  });

  $('#inputPass').bind("click",function(e) {
	  if(this.value == "mot de passe")this.value="";
  }).bind("blur",function(e) {
	  if(this.value == "")this.value="mot de passe";
  });

  $('.inlog :input#id').bind("click",function(e) {
	  if(this.value == "identifiant")this.value="";
  }).bind("blur",function(e) {
	  if(this.value == "")this.value="identifiant";
  });

  $('.inlog :input#mdp').bind("click",function(e) {
	  if(this.value == "mot de passe")this.value="";
  }).bind("blur",function(e) {
	  if(this.value == "")this.value="mot de passe";
  });

  DD_roundies.addRule('#body div.img img','6px', true);
  DD_roundies.addRule('.rond2', '12px' , true);
  DD_roundies.addRule('.trois', '12px 12px 12px 0px' , true);
  DD_roundies.addRule('.rond', '3px', true);
  DD_roundies.addRule('.rondeco', '3px', true);
  DD_roundies.addRule('.rond3', '6px', true);
  DD_roundies.addRule('.archives', '0px 0px 12px 12px', true);
  DD_roundies.addRule('.bas12', '0px 0px 12px 12px', true);
  DD_roundies.addRule('.bas6', '0px 0px 6px 6px', true);
  DD_roundies.addRule('#produit', '0px 6px 0px 6px', true);
  DD_roundies.addRule('.notes', '4px 0px 0px 0px', true);
  DD_roundies.addRule('.ui-slider-handle', '3px', true);
  DD_roundies.addRule('.ui-slider', '3px', true);
  DD_roundies.addRule('.rondshg','6px 0px 6px 6px', true);
  DD_roundies.addRule('#guide2','4px 4px 0 0', true);

	$("#printPage").bind("click",function(e){
 		window.print();
 		e.preventDefault();
 	});

 	$("#ad2fav").bind("click",function(e){
 		favoris();
 		e.preventDefault();
 	});



	$("#bandeau").cycle({
    fx:    'fade',
    speed:  2500,
    timeout:  6500
	});

	$("#visuTemoins").cycle({
    fx:    'fade',
    speed:  2500,
    timeout:  6500
	});

	$(".haide").hide();
	//$(".achatAccess").hide();

	$("a.carac").bind('click',function (e) {
	  e.preventDefault();
      $(this).next().slideToggle(500);
    });

	$("a.accessoires").bind('click',function (e) {
	  e.preventDefault();
      $(this).next().slideToggle(500);
    });

	$('.achatAccess ul li a').hover(function(){
		$(this).find('img').attr("src", $(this).find('img').attr("src").replace('.','_roll.'));
	},function(){
		$(this).find('img').attr("src", $(this).find('img').attr("src").replace('_roll',''));
	});

	$("div.faq h4").bind('click',function (e) {
	  e.preventDefault();
      $(this).next().slideToggle(500);
    });

	$("a#oubliMDP").fancybox({'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': false, frameHeight:230,frameWidth:450, padding:0});

	/* Tableau 1 sur 2 */
	$("#body table tr:even").addClass("even");
	$("#body table tr:odd").addClass("odd");



	/* Actions panier */
	$(".cartAdd").bind('submit',function(e){

		e.preventDefault();

		id=$(this).find(":input[name=id]").val();

		$.ajax({
			url: 'ajaxCart.php',
			type: 'POST',
			data: '&id='+id,
			success: function(){
				$("#espaceco").load("loadEspaceco.php");
			}
		});

		$(this).find('a:hidden').trigger('click');

	});

	$("#f_d").bind("click",function(){
		$("#aDomicile").show();
	});
	$("#f_m").bind("click",function(){
		$("#aDomicile").hide("slow");
	});


}); /* fin doc ready */


/* ======== Fonctions ========================================================================== */

/* Comportement Rollover avec class="rollover" */
attachRollOverEvent = function(imageId){
	$(imageId).hover(function(){ $(this).attr("src", $(this).attr("src").replace('.','_roll.')) },function(){ $(this).attr("src", $(this).attr("src").replace('_roll','')) } );
}

/* Change image pour les "actif" */
attachActif = function(imageId){
	$(imageId).attr("src", $(imageId).attr("src").replace('.','_roll.'));
}

/* Impression des documents */
function imprimer(){
	if(window.print) window.print();
	else alert("Désolé mais votre navigateur ne supporte pas cette fonctionnalité. Pour la plupart des navigateurs, vous pouvez imprimer cette page  en allant dans le menu 'Fichier' > 'Imprimer'");
}

/* Ajouter aux favoris */

function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("le nom du site","http://www.tonsite.com",""); }
else { window.external.AddFavorite("http://www.tonsite.com","le nom du site"); } }

