var current_menu=null;
var to_event=null;
var paysId = 1;
var fee;
var choices;
var x;
var target;

function hideMenu() {
if (current_menu!=='null') {
	$(current_menu).find('div').stop(true,true).hide('slide','slow');
}
current_menu=null;
}
function changeFee(input) {
$(input).children('option:selected').each(function() {
	fee=$(this).attr('fee');
	if (fee=='W') {
	choices=['postCost', 'PostMethod'];
	for (var i in choices) {
		$('#'+choices[i]).prop('checked', false);
		$('#'+choices[i]+'Label').hide();
		$('#'+choices[i]+'Label').prev().hide();
	}
	$('#postWWELabel').show();
	$('#postWWELabel').prev().show();
	$('#postWWE').prop('checked', true);
	} else {
	choices=['postCost', 'PostMethod'];
	for (var i in choices) {
		$('#'+choices[i]).prop('checked', false);
		$('#'+choices[i]+'Label').show();
		$('#'+choices[i]+'Label').prev().show();
	}
	$('#postWWELabel').hide();
	$('#postWWELabel').prev().hide();
	$('#postWWE').prop('checked', false);
	$('#PostMethod').prop('checked', true);
	}
	});
}

var jump=function(e) {
	e.preventDefault();
	target = $(this).attr("href");
	$('html,body').animate({
		scrollTop: $(target).offset().top
	},500,function() {
		location.hash = target;
	});
};

//Panier - selecteur (quantité)
function setText(a, b) {
	x = document.getElementById(a);
	if (x)
	x.innerHTML = b.options[b.selectedIndex].innerHTML;
}

function showPage(page_num) {
	if (page_num!=paysId) {
		$('#pagination > a:not(#'+page_num+')').removeClass('current');
		$('#pagination').children('#'+page_num).addClass('current');
		$('.pays:not(#'+ page_num +')').hide();
		paysId=page_num;
		$('.pays#'+ paysId).toggle('slide','slow');
	}
}

jQuery.extend(
	jQuery.expr[ ":" ],
	{ reallyvisible : function (a) { return !(jQuery(a).is(':hidden') || jQuery(a).parents(':hidden').length); }}
);

function setCookie (c_key, c_val)
{
  var c = c_key + '=' + c_val;
  var dt = new Date();
  dt.setTime(dt.getTime() + (30 * 24 * 60 * 60 * 1000));
  c = c + '; expires=' + dt.toGMTString();
  c = c + '; path=/';
  document.cookie = c;
}

function getCookie (c_key)
{
  var c_key_eq = c_key + "=";
  var cookies = document.cookie.split(';');
  var i;
  for(i = 0; i < cookies.length; i++)
  {
    var cookie = cookies[i];
    while (cookie.charAt(0)==' ')
    {
      cookie = cookie.substring(1, cookie.length);
    }
    if (cookie.indexOf(c_key_eq) == 0)
    {
      return cookie.substring(c_key_eq.length, cookie.length);
    }
  }
  return null;
}

$(document).ready(function() {

	var textTooLong;
	var roundSize;
	var prevSlideTag;
	var nextSlideTag;
	var jump;
	var h;
	var c;
	var hs;
	var me;
	var myZindex;
	var slideId;
	var itemID;
	var theLanguage;
	var index;
	var inputaddWidth;
	var inputWidth;
	var contentStart;
	var startUi;
	var dateName;
	var nombreList;
	var hitarea;
	var paysList;
	var slideOneTimeLeft;
	var slideOneTimeRight;
	var startSlide = 1;
	var hover = false;
	var sldr_id = 0;
	var right_pos = 200;
	var selectThemeVal;
	var m = 0;
	var slidesHeight = $('#slides').outerHeight();
	var slidesWidth = $('#slides').outerWidth();
	var viewport = $('#viewport');
	var wrapper = $('#viewport > ul');
	var objects = wrapper.children();
	var winHeight;
	var pageHeight;

	function slideAdjust() {

		// slide unique
		$('#slides .slides_container .one a').css({
			height: slidesHeight,
			width: slidesWidth,
			position: 'relative'
		});


		//slide double
		$('#slides .slides_container .two a').css({
			height: (slidesHeight),
			width: (slidesWidth/2),
			position: 'absolute'
		});
		$('#slides .slides_container .two a:nth-child(1)').css({
			top: 0,
			left: 0
		});
		$('#slides .slides_container .two a:nth-child(2)').css({
			top: 0,
			left: (slidesWidth/2)
		});


		//slide triple
		$('#slides .slides_container .three a:nth-child(1)').css({
			height: (slidesHeight/2),
			width: (slidesWidth),
			position: 'absolute',
			top: 0,
			left: 0
		});

		$('#slides .slides_container .three a:nth-child(2)').css({
			height: (slidesHeight/2),
			width: (slidesWidth/2),
			position: 'absolute',
			top: slidesHeight/2,
			left: 0
		});

		$('#slides .slides_container .three a:nth-child(3)').css({
			height: slidesHeight/2,
			width: (slidesWidth/2)-1,
			position: 'absolute',
			top: (slidesHeight/2),
			left: (slidesWidth/2)
		});

		//slide Quadruple
		$('#slides .slides_container .four a').css({
			height: (slidesHeight/2),
			width: (slidesWidth/2),
			position: 'absolute'
		});

		$('#slides .slides_container .four a:nth-child(1)').css({
			top: 0,
			left: 0
		});

		$('#slides .slides_container .four a:nth-child(2)').css({
			top: 0,
			left: (slidesWidth/2)
		});

		$('#slides .slides_container .four a:nth-child(3)').css({
			top: (slidesHeight/2),
			left: 0
		});

		$('#slides .slides_container .four a:nth-child(4)').css({
			top: (slidesHeight/2),
			left: (slidesWidth/2)
		});

	}

	// pour la page d'accueil uniquement : centrage vertical et slider
	function homepage(){
		if( $('body > section').hasClass('homepage') || $('body > section').hasClass('histoire') ){

			slideAdjust();

			$('.mainNav').removeClass('open');

			$('.homepage #slides').mouseenter(function() {
				$('.homepage #slides .next, .homepage #slides .prev').stop().animate({
					opacity: '1'
				},1200);
			}).mouseleave(function(){
				$('.homepage #slides .next, .homepage #slides .prev').stop().animate({
					opacity: '0'
				},1200);
			});

			$('.sitemapBouton').delay(1200).animate({
				bottom: '-30px',
				paddingTop: '0',
				height: '24px'
			},800);

		} else {
			$('body').css({
				paddingBottom: '150px',
				height: 'auto'
			});
		}
	}

	function siteMapColumn() {
		$('#sitemapList').columnize({
			width: 154,
			height: 75
		});
		
		if (getCookie('sitemap') != 'open') {
			$('.sitemap').hide();
		} else {
			$('.homepage, .histoire').css('margin-top','-310px');
		}
		$('.sitemap').css('height','140px');
	}

	//Full size BG
	function backgroundSwitch() {
		//empecher la selection
		$('#backgrounds').disableTextSelect();

		if( $('body > section').hasClass('homepage') ){
			slideId = $('#slides .slide:reallyvisible').attr('id');
			$('#backgrounds img').fadeOut('slow', function(){ $(this).hide().removeClass('visible'); });
			$('#backgrounds .'+slideId).fadeIn('slow', function(){ $(this).show().addClass('visible'); });
		}
	}
	
	//In Big Screens content is centered
	function bigScreen() {
		winHeight = $(window).height();
		pageHeight = $('body > section').outerHeight();
		
		if( winHeight <= (pageHeight +260) ){
			$('body > section').removeClass('bigScreen').css('margin-top','0');
			$('body').css({
				paddingBottom: '150px',
				height: 'auto'
			});
		} else {
			$('body > section').addClass('bigScreen').css('margin-top', (-(pageHeight/2) + -50) );
			$('body').css({
				paddingBottom: '0px',
				height: '100%'
			});
		}
	}
	$(window).resize(function() {
		bigScreen();
	});
	
	//APPLICATE FUNCTIONS
	homepage();
	backgroundSwitch();
	siteMapColumn();
	bigScreen();


	// Afficher ou non le bouton options -> et l'animer
	if ( !($('.options').is(':hidden'))) {
		$('.optionsBouton').delay(1200).css({
			top: (getCookie('options') == 'open') ? '-64px' : '-30px',
			height: '24px'
		},800);
	} else {
		$('.optionsBouton').delay(1200).animate({
			top: (getCookie('options') == 'open') ? '-64px' : '-30px',
			height: '24px'
		},800);
	}

	// SLIDERS
	if (window.location.hash) {
		startSlide = window.location.hash.replace('#','');
	}

	$('.homepage #slides').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		generatePagination: true,
		generateNextPrev: true,
		play: 7000,
		pause: 2500,
		slideSpeed: 1600,
		hoverPause: true,
		animationComplete: function(current){
			backgroundSwitch();
		}
	});

	$('#slides .texte span').prepend('<span class="icon">&gt;</span>');

	$('.sos-noukies #slides, .gamme-detail #slides, .dvd #slides, .livres #slides, .mobilier #slides').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		generatePagination: true,
		generateNextPrev: true,
		play: 0,
		slideSpeed: 1600,
		hoverPause: true,
		animationComplete: function(current){
			$('.sosList li, .articlesList li').removeClass('current');
			$('.sosList li:nth-child('+ current +'), .articlesList li:nth-child('+ (current - 1) +')').addClass('current');
		}
	});

	$('.vetements #slides, .maillots #slides').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		generatePagination: true,
		generateNextPrev: true,
		play: 1600,
		slideSpeed: 1600,
		hoverPause: true,
		animationComplete: function(current){
			$('.sosList li, .articlesList li').removeClass('current');
			$('.sosList li:nth-child('+ current +'), .articlesList li:nth-child('+ (current - 1) +')').addClass('current');
		}
	});

	$('.peintureBox #slides').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		generatePagination: true,
		generateNextPrev: true,
		play: 0,
		slideSpeed: 800,
		hoverPause: true,
		animationComplete: function(current){
		}
	});


	// slide hover
	$('.homepage #slides .slides_container a').hover(function() {
		$(this).find('img').hide();
		$(this).find('.texte').show();
	}, function(){
		$(this).find('.texte').hide();
		$(this).find('img').show();
	});

	// Préviuous & Next dans la langue
	theLanguage = $('html').attr('lang');
	prevSlideTag = 'Previous'; nextSlideTag = 'Next';
	if(theLanguage == 'nl'){ prevSlideTag = 'Vorige'; nextSlideTag = 'Volgende'; }
	if(theLanguage == 'fr'){ prevSlideTag = 'Précédent'; nextSlideTag = 'Suivant'; }
	if(theLanguage == 'de'){ prevSlideTag = 'zurück'; nextSlideTag = 'vor'; }
	if(theLanguage == 'it'){ prevSlideTag = 'Precedente'; nextSlideTag = 'Seguente'; }

	$('#slides .prev').html(prevSlideTag).prepend('<span>&lt;</span>');
	$('#slides .next').html(nextSlideTag).append('<span>&gt;</span>');







	// Options
	$('.optionsBouton').click(function() {

        if ($('.options').is(':hidden')) {
            $('.options').show().animate({
                top: '-40px',
                height: '32px'
            }, {
                duration: 'slow',
                step: function(now, fx){
                    if (fx.prop == 'top')
                    {
                      $('.optionsBouton').css('top', (parseInt(now) - 24) + 'px');
                    }
                }
            });
            setCookie('options', 'open');
        } else {
            $('.options').animate({
                top: '-6px',
                height: '0px'
            }, {
                duration: 'slow',
                step: function(now, fx){
                    if (fx.prop == 'top')
                    {
                      $('.optionsBouton').css('top', (parseInt(now) - 24) + 'px');
                    }
                },
                complete: function(){ $(this).hide(); }
            });
            $('.basket ul').hide();
            setCookie('options', 'close');
        }
		return false;
	});
	// options hover
	$('.optionsBouton').hover(function() {
		$(this).animate({
			marginTop: '-5px',
			paddingBottom: '5px'
		}, 200);
	}, function() {
		$(this).animate({
			marginTop: '0',
			paddingBottom: '0'
		}, 200);
	});






	// Sitemap
	$('.sitemapBouton').click(function() {
		if ($('.sitemap').is(':hidden')) {
			$('.sitemap').slideDown('slow', function(){
				m = 0;
				c = $('#sitemapList .column');
				for (var i = 0; i < c.length; i++)
				{
					m = Math.max(m, c.eq(i).height());
				}
				for (var i = 0; i < c.length; i++)
				{
					c.eq(i).css('height', m + 'px');
				}
			});
			
			$('.bigScreen.homepage, .bigScreen.histoire').animate({
				marginTop: '-310px'
			}, 500);
			
            setCookie('sitemap', 'open');
            
		} else {
			$('.sitemap').slideUp('slow');
            
            $('.bigScreen.homepage, .bigScreen.histoire').animate({
				marginTop: '-242px'
			}, 500);
			
			setCookie('sitemap', 'close');
		}

		return false;
	});
	// sitempa hover
	$('.sitemapBouton').hover(function() {
		$(this).animate({
			marginBottom: '-5px',
			paddingTop: '5px'
		}, 200);
	}, function() {
		$(this).animate({
			marginBottom: '0',
			paddingTop: '0'
		}, 200);
	});






	// Basket
	$('.basket>a').click(function() {
		if($('.basket ul').is(':hidden')) {
			$('.basket ul').slideDown('fast');
			$('.basket').toggleClass('open');
		} else {
			$('.basket ul').slideUp('fast');
			$('.basket').toggleClass('open');
		}
		return false;
	});






	//Mini Menu
	function menuClose() {
		$('.mainNav .navContainer').slideDown('slow');
		$('.mainNav').addClass('open');
	}
	function menuOpen() {
		$('.mainNav .navContainer').slideUp('slow');
		$('.mainNav').removeClass('open');
	}



	//Menu - sous niveaux
	$('.mainNav .menuTitle').click(function() {
		if($('.mainNav .navContainer').is(':hidden')) {
			menuClose();
		} else {
			menuOpen();
		}
		return false;
	});
	// imiter le click au survole
	$('.mainNav .menuTitle').mouseenter(function() {
		if(!($('.mainNav').hasClass('open'))){
			if(!($('MainNav').is(':animated'))){
				menuClose();
			}
		}
	});


	// hover anywhere else
	if( $('.mainNav').hasClass('open') ){
		$('#slides, .content, #backgrounds, .sitemap, .options').mouseenter(function(){
			hideMenu();
		});
	}

    // set width for submenu (by #columns)
	$('.mainNav .navContainer > ul > li > div').each(function(){
		var n = $(this).find(".column");
		$(this).css("width", n.length * (n.eq(0).width() + 2) + "px");
	});

	// Navigation sub level
	$('.mainNav .navContainer > ul > li').mouseenter(function() {
		if (this==current_menu) {
		return;
		} else {
			if (current_menu!==null) {
				clearTimeout(to_event);
				me=this;
				$(this).parent().children('li').each(function() {
					if (this!==me) {
						$(this).find('div').each(function() {
							if (!$(this).is(':hidden') && !$(this).data("animated")) {
								$(this).data("animated", true);
								$(this).stop(true,true).hide('slide','slow',function(){ $(this).data("animated",false); });
							}
						});
					}
				});
			}
		current_menu=this;
		$(this).find('div').stop(true,true).show('slide','slow');
		}
	});

	$('.mainNav > ul > li').mouseleave(function() {
		to_event=setTimeout(hideMenu(), 3000);
	});




	// possibilité de cacher le menu pour certaines pages
	$('.histoire .container').prepend('<a href="#" class="menuOpen">Menu</a>');

	$('.histoire .header .logo').click(function() {
		if( $('.header').is(':visible') ){
			$('.header').toggle('slide','slow');
			$('.header').queue(function() {
				$('.histoire_slide, .personnages_slide').css('marginLeft','0px');
				$(this).dequeue();
			});
		} else {
			$('.header').queue(function() {
				$('.histoire_slide, .personnages_slide').css('marginLeft','-170px');
				$('.header').toggle('slide','slow');
				$(this).dequeue();
			});
		}
		return false;
	});

	// rotation sur le bouton du menu masqué
	if( $('body > section').hasClass('histoire') ){
		if ( !($.browser.msie) ) {
			$('.menuOpen').rotate(-90);
		}

		$('.menuOpen').click(function() {
			$('.header .logo').trigger('click');
			if( !$('.mainNav ul').is(':visible') ){
				$('.menuTitle').trigger('click');
			}
			return false;
		});
	} else {
		$('.menuOpen').hide();
	}




	// Gamme - Articles list > new (FR)
	$('.articlesList .new').children().append('<span class="newTag">Nouveau</span>');
	$('.gammeList .new').append('<span class="newTag">Nouveau</span>');
	$('.newTag').rotate(45);
	$('.lightbox').lightBox({
		overlayBgColor: '#FFF',
		overlayOpacity: 0.8,
		imageLoading: 'images/loading.gif',
		imageBtnClose: 'images/lightbox-btn-close.png',
		imageBtnPrev: 'images/lightbox-btn-prev.png',
		imageBtnNext: 'images/lightbox-btn-next.png'
	});
	// liens retour en haut
	$('.gototop em').rotate(-90);

	//interaction entre le slide de la gamme et les thumbs de la liste
	$('.articlesList li a').click(function(){
		itemID = $(this).parent().index();
		$('.articles_slides .pagination li:nth-child('+ (itemID+2) +') a').trigger('click');
		$('html, body').animate({scrollTop:'0'}, 'slow');
		return false;
	});
	$('.articlesList li a').bind("click", jump);
	//idem (-1) page SOS noukies
	$('.sosList li a').click(function(){
		itemID = $(this).parent().index();
		$('.sos_slides .pagination li:nth-child('+ (itemID+1) +') a').trigger('click');
		$('html, body').animate({scrollTop:'0'}, 'slow');
		return false;
	});

	// HISTOIRE
	if($('.histoire_slide').size()) {
		right_pos = 0;
	}

	$('.histoire .content').click(function(){
		if( $('.header').is(':visible')){
			$('.header .logo').trigger('click');
		}
	});

	//aller a un élément precis
	function slideTo(index) {
		if (index > objects.length || index < 0) return;
		viewport.stop().animate(
		{
			scrollLeft: viewport.scrollLeft() + $(objects[index]).position().left
		},
		'slow',
		'swing',
		function(e) {
			viewport.stop();
		}
	);
	}

	//aller a l'id
	function goToId(id){
		h=id;
		hs=$('.slider').slider();
		hs.slider('option', 'value',h);
		hs.slider('option','slide').call(hs,null,{ handle: $('.ui-slider-handle', hs), value: h });
		return false;
	}

	//direction : true = droite
	//false = gauche
	function histoireSlide(direction) {
		if (
			(direction === false && viewport.scrollLeft() <= 0) || (direction === true && $(objects[objects.length - 1]).position().left <= right_pos )
		) return;

		viewport.animate(
			{
				scrollLeft: viewport.scrollLeft() + ((direction) ? 1 : -1) * 100
			},
			{'duration':'fast',
			'easing':'linear',
			'complete':function() {
				histoireSlide(direction);
			},
			'step':function(){
				for(var i=0; i<objects.length; i++) {
					if($(objects[i]).position().left > -50 && $(objects[i]).position().left < 50 && $('.histoire_slide').size() ) {
						if(sldr_id != i) {
							sldr_id = i;
							goToId(i);
						}
					}
				}
			}}
		);
	}

	$('.hover_prev, .clonePrev, .content .timeline_arows .prev').hover(
		function(e) {
			hover = true;
			histoireSlide(false);
		},
		function(e) {
			hover = false;
			viewport.stop();
		}
	);

	$('.clonePrev, .cloneNext').click(function(e){
		e.preventDefault();
	});

	$('.hover_next, .cloneNext, .content .timeline_arows .next').hover(
		function(e) {
			hover = true;
			histoireSlide(true);
		},
		function(e) {
			hover = false;
			viewport.stop();
		}
	);

	$('.content .timeline_arows .prev, .content .timeline_arows .next').click(
		function(e){
			return false;
		}
	);

	slideOneTimeLeft = function () {
		histoireSlide(true);
		setTimeout(function(){
			viewport.stop();
		},800);
	}
	slideOneTimeRight = function () {
		histoireSlide(false);
		setTimeout(function(){
			viewport.stop();
		},800);
	}


	$('.dateList a').click(function(e) {
		index = $('.dateList a').index(e.target);
		slideTo(index);
		return false;
	});

	startUi = $('.dateList li a').html();

	$('.slider').append('<span class="sliderLeft"></span><span class="sliderRight"></span>').slider({
		min: 0,
		max: objects.length-1,
		slide: function( event, ui ) {
			function slideCallBack(){
				dateName = $('.dateList li:nth-child('+ (ui.value+1) +') a').html();
				$('.ui-slider-handle').html(dateName);
				$('.dateList li a').css('opacity','1');
				if(hover) {
					$('.dateList li:nth-child('+ (ui.value+1) +') a').css('opacity','0');
				} else {
					$('.dateList li:nth-child('+ (ui.value+1) +') a').css('opacity','0').trigger('click');
				}
			}
			slideCallBack();
		}
	});

	$('.ui-slider-handle').html(startUi);
	$('.dateList li:first-child a').css('opacity','0');

	//largeur de liste
	nombreList = $('.dateList ol').children().length;
	$('.dateList li').width( Math.round(100/nombreList)+'%');

	//mini bulle histoire
	$('#viewport li .perso').append('<span class="minibulle">…</span>');
	$('#viewport li .description').append('<span class="coinbulle"></span>');
	$('<div class="perso_hitarea"></div>').insertBefore($('#viewport li .perso'));

	objects.each(function(index) {
		hitarea = $('#viewport li')[index];
		hitarea = $(hitarea).find($('.perso_hitarea'));
		hitarea.css({"width": hitarea.next().css("width"),
					"height": hitarea.next().css("height"),
					"top": hitarea.next().css("top"),
					"left": hitarea.next().css("left")});
	});

	//Personnages hover - infobulle show
	$('#viewport .perso_hitarea').hover(function(){
		$('.minibulle').stop(true, true);
		if($(this).next().children().is(':visible')){
			$('.description').fadeOut('fast');
			$('.minibulle').fadeIn('slow');
			$(this).next().children().fadeOut('fast');
			$(this).next().next().next().fadeIn('slow');

		} else {
			$('.minibulle').stop(true, true).fadeIn('slow');
			$(this).next().next().next().stop(true, true).fadeOut('fast');
		}
	});

	$('.personnages_slide #viewport .perso_hitarea').hover(function() {
		$(this).parent().animate({
			marginRight: "0"
		},500);
		$(this).stop();
	}, function() {
		$(this).parent().animate({
			marginRight: "-200"
		},500);
		$(this).stop();
	});

	//inverser l'order z-index des lists (histoire et personnages)
	myZindex = 80;

	$('#viewport li').each(function(){
		$(this).css('z-index',myZindex);
		myZindex = myZindex - 1;
	});

	//retour au debut
	$('.storyContinue a').click(function(){
		goToId(0);
		return false;
	});


	//Panier ajouter l'icon dropdown
	$('.selectQuantity, .countrySelect, .childrenSelect').append('<span class="icon"></span>');

	$('.itemDelete').rotate({
		bind: {
			mouseover : function() {$(this).rotate({animateTo:180});},
			mouseout : function() {$(this).rotate({animateTo:0});}
		}
	});


	//contact input margin
	$('.coordonnees input').each(function(){
		if( !($(this).parent().hasClass('phone')) && !($(this).parent().parent().hasClass('childrens')) ){

			inputWidth = $(this).outerWidth();
			inputaddWidth = $(this).prev().outerWidth();

			//$(this).css('padding-left',inputaddWidth);
			$(this).css('width', (inputWidth - inputaddWidth - 15) );
		}
	});





	//Champs contact - input radio
	$('.newsSubscribe, .confirmForm, .expedition, .persontitle').find('label').append('<span></span>');
	$('.downloadlink').append('<span>&gt;</span>');
	$('.validationForm').append('<span class="icon">&gt;</span>');
	$('.newsSubscribe input, .confirmForm input, .expedition input, .persontitle input').click(function(){
		$(this,"input:radio:checked").parent().find('span').removeClass('selected');
		$(this,"input:radio:checked").next().find('span').addClass('selected');
	});

	$('.validationForm span').click(function(){
		$('#sendForm').trigger('click');
		return false;
	});

	// *new* STORE LOCATOR Input Radio
	$('.storeInfos .storetype input').click(function(){
		$(this,"input:radio:checked").parent().find('.radioBtn').removeClass('selected');
		$(this,"input:radio:checked").next().find('.radioBtn').addClass('selected');
	get_sorted_stores($(this,"input:radio:checked").val());
		return false;
	});

	$('.pays:not(#1)').hide();


	$('.control a.next').click(function(e){
		e.preventDefault();
		paysList = $('.storelocator .pays').length;

		if( paysId < paysList ){
			showPage(paysId+1);
		} else {
			showPage(1);
		}
		return false;
	});

	$('.control a.prev').click(function(e){
		e.preventDefault();
		paysList = $('.storelocator .pays').length;

		if( paysId == 1 ){
			showPage(paysList);
		} else {
			showPage(paysId-1);
		}
		return false;
	});


	// ESPACE CONSEILS
	function conseilsStart(){
		// start Status
		$('.themeContent img').rotate(7);
		contentStart = $('.selectTheme select').val();
		$('.theme:not(#'+ contentStart +')').hide();
	}
	conseilsStart();


	// selecteur
	$('.selectTheme select').change(function(){
		selectThemeVal = $(this).val();
		$('.theme:not(#'+ selectThemeVal +') .themeContent').slideUp('slow');
		$('.theme:not(#'+ selectThemeVal +')').slideUp('slow');
		$('.theme#'+ selectThemeVal).slideDown('slow');
	});

	// open - close content
	$('.theme li h4').click(function(){
		if( $(this).parent().hasClass('open') ){
			$(this).parent().find('.themeContent').slideUp('slow');
		} else {
			$('.theme .open .themeContent').slideUp('slow');
			$(this).parent().find('.themeContent').slideDown('slow');
		}
		return false;
	});

	$('.theme h4').rotate({
		bind: {
			mouseover : function() {$(this).prev().rotate({animateTo:90});},
			mouseout : function() {$(this).prev().rotate({animateTo:0});}
		}
	});

	// Champs enfant (newsletter) - clonage de champs
	$('.childrens:not(#1)').slideUp();
	$('.childrens input').click(function(){
		$(this).parent().parent().next().slideDown('slow');
	});

	//too long item name
	$('.gammeList li p').each(function(){
		textTooLong = $(this).text().length;
		if( textTooLong >= 50){
			$(this).css('font-size','1.5em');
		}
	});

	//IPAD
	$(document).ready(startUp);

	function startUp(){
		if( String(navigator.userAgent).search(/(iPad)|(iPhone)/i) > 0 ){

			$('.histoire .cloneArrow, .histoire .hover_next, .histoire .hover_prev').hide();

			$("#viewport").touchwipe({
				wipeLeft: function() { slideOneTimeLeft() },
				wipeRight: function() { slideOneTimeRight() },
				min_move_x: 40,
				min_move_y: 40,
				preventDefaultEvents: true
			});
		}
	}

});

