function cre_cook(nom,contenu) {
	document.cookie = nom + "=" + escape(contenu)
      }
      


   function lit_cook(nom) {
      var deb,fin
      deb = document.cookie.indexOf(nom + "=")
      if (deb >= 0) {
         deb += nom.length + 1
         fin = document.cookie.indexOf(";",deb)
         if (fin < 0) fin = document.cookie.length
         return unescape(document.cookie.substring(deb,fin))
         }
      return ""
      }


$(document).ready(function(){ 
	
	
		
	//ipad and iphone fix
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		

		//menu pour ie6
		$("#menu a img + img, #menu_sec a img + img, #col_menu_categorie a img + img, #menu_sec_eng a img + img").css({
		display:"none",
		position:"absolute",
		top:"0px",
		left:"0px"
		})
		//menu
		$("#menu a:not('.current'), #menu_sec a:not('.current'), #col_menu_categorie a:not('.current'), #menu_sec_eng a:not('.current')")
			.css({position:"relative"})
			.bind('touchstart', function(){
				$(this).find("img").next()
				.stop(true,true)
				.fadeIn(200);
			})
			
			.bind('touchend', function(){
				$(this).find("img").next().fadeOut(200)
			});
		
		
		//overfade pour ie6
		$("a.overFade img + img").css({
		display:"none",	
		position:"absolute",
		top:"0px",
		left:"0px"
		})
		//overfade
		$("a.overFade")
		.css({position:"relative"})
		
		.bind('touchstart', function(){
				$(this).find("img").next()
				.stop(true,true)
				.fadeIn(200);
			})
			
			.bind('touchend', function(){
				$(this).find("img").next().fadeOut(200)
			});
		
		
	}else{
	//hover normal
	
	
		//menu pour ie6
		$("#menu a img + img, #menu_sec a img + img, #col_menu_categorie a img + img, #menu_sec_eng a img + img").css({
		display:"none",
		position:"absolute",
		top:"0px",
		left:"0px"
		})
		//menu
		$("#menu a:not('.current'), #menu_sec a:not('.current'), #col_menu_categorie a:not('.current'), #menu_sec_eng a:not('.current')")
		.css({position:"relative"})
		.hover(
			function(){
	
				$(this).find("img").next()
				.stop(true,true)
				.fadeIn(200);
				
			}, function(){
				
				$(this).find("img").next().fadeOut(200);
				
			}
		);
		
		//overfade pour ie6
		$("a.overFade img + img").css({
		display:"none",							  
		position:"absolute",
		top:"0px",
		left:"0px"
		})
		//overfade
		$("a.overFade")
		.css({position:"relative"})
		.hover(
			function(){
	
				$(this).find("img").next()
				.stop(true,true)
				.fadeIn(200);
				
			}, function(){
				
				$(this).find("img").next().fadeOut(200);
				
			}
		);
	
	}
	
	
	
	
	//slideshow
	$('#anim').cycle({
	fx: 'fade',
	speed:800,
	delay:2000,
	//	easing: 'bounceout',
	//next:   '#fleche_droite a', 
    //prev:   '#fleche_gauche a', 
	pager:  '#bouton_pub',
	
	// callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
		return '<a href="#"></a>'
    } 
	
	});


initMenu();

$.smoothAnchors(700, "swing", false);
  
});




//menuvertical
function initMenu() {
var cetteSection = lit_cook('id');
  
  $("#menu2 li ul").attr("rel", function (arr) {
		return arr;
   })
  
  $('#menu2 ul').hide();
  $('ul[rel='+cetteSection+']').show();
  
  $('#menu2 li a').click(
	function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
		  window.location = $(this).attr('href'); 
	   return false
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu2 ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
		
       	var cetteSection = $(this).next("ul").attr('rel');
		cre_cook('id',cetteSection);
		window.location = $(this).attr('href'); 
		return false
	  }
	 
	 	if(!$(this).parent().parent('ul').attr('rel')){
		cre_cook('id','');
		window.location = $(this).attr('href'); 
		return false
	 }

      });
  
  
  }

//slideboutique
function initPointVente() {
  $('#pointvente .detail_boutique').hide();
  $('#pointvente .titre_boutique').show();
  
  	$('#pointvente .top_pointvente').click(function(){
		
		var checkElement = $(this).next();
      if((checkElement.is('.detail_boutique')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('.detail_boutique')) && (!checkElement.is(':visible'))) {
        $('#pointvente .detail_boutique:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
		
	});
	
}





