var elementInDestDefault = 'Votre destination'; 
var elementInNlDefault = 'Votre adresse mail'; 
var rotateThumbsOn = true;
var elementInDestLocked = false;
var currentPanelVisio;
var nbItems = 0;

function align_pubs() {
	// aligne bons plans et dernières minutes au même niveau
	var a = $('#bloc-bons-plans');
	var b = $('#bloc-last-minutes');
	
	var ta = $('#bloc-bons-plans .bloc-top');
	var tb = $('#bloc-last-minutes .bloc-top');
	var hta = ta.height() || 0;
	var htb = tb.height() || 0;
	
	var max = Math.max(hta, htb);
	ta.height(max);
	tb.height(max);
	
	var ha = a.height();
	var hb = b.height();
	max = Math.max(ha, hb);
	a.css('height', max);
	b.css('height', max);
}

$(document).ready(function(){
	reload_link_map();
	/*$('#sitemap a').click(function(){
		window.location.href = $(this).attr('rel');
		return false;
	});*/
	
	align_pubs();
	
	$('#logo-site').click(function(){
		window.location.href = '/';
		return false;
	});

	$('#body .list-promos .promo').click(function(){
		if( $('a', this).attr('target') == '_blank')
			window.open( $('a', this).attr('href') );
		else
			window.location.href = $('a', this).attr('href');
			
		return false;
	});
	
	$('#city').after( '<div>' + maville +' <a class="fancy" id="add_city" href="/annonceurs/add-city">'+ btnAjouter +'<a/>');
	
	$('#country').change(function(){
		elem=$('#country').val();
		$('#region').empty();
		$.ajax({
			url : '/ajax/get-region/',
			data : 'term='+elem,
			type :  'get',
			cache : true,
			dataType : 'json',
			success : function(data){
					$('#region').append(data);
					$('.selectmenu').selectmenu('destroy');
					
					
					$('.selectmenu').selectmenu();
					
					//$('.region').otpions.add('toto');
			}

		});
	});
	
	$('#envoyer').click(function(){
		country=$('#country').val();
		countryname=$('#country option:selected').text();
		if($('#region').val()!=null)
		{
			region=$('#region').val();
			regionname=$('#region option:selected').text();
		}	
		else
			region='';
		cityname=$('#cityname').val();
		
		$.ajax({
			url : '/ajax/add-city/',
			data : 'country='+country+'&region='+region+'&cityname='+cityname,
			type :  'get',
			cache : true,
			dataType : 'json',
			success : function(data){
				
				$('#envoyer').after('Votre demande d\'ajout de ville a bien été envoyée.');
	
					
				setTimeout(function(){
					if(region!=''){
						parent.$('#city').val(regionname);
						parent.$('#city_id').val(region);
					
					}
					else{
						parent.$('#city').val(countryname);
						parent.$('#city_id').val(country);
	
					}
					parent.$('#country_cpt').val(country);
					parent.$('#city_new').val(data);
					parent.$.fancybox.close();
			
				},2000);
	
			}

		});
	});
	
	

	$.datepicker.setDefaults($.datepicker.regional[dateLang]);

	$('.selectmenu').selectmenu();
	$('#nombre-d-epis').selectmenu({
		'width' : '70'
	});
	
	$('li.selection:not(.annonceur)').click(function(){
		if( $('.infos a', this).attr('target') == '_blank')
			window.open( $('.infos a', this).attr('href') );
		else
			window.location.href = $('.infos a', this).attr('href');
		
		return false;
	});
	$('li.selection').hover(function(){
		$(this).css('cursor','pointer');
	});
	
	$('#ariane_sel_zone').change(function(){
		
		// var url = document.URL.split("/");
		// if( ! ( url[ url.length- 1 ].match(new RegExp('.php', 'gi')) && url[ url.length- 1 ].match(new RegExp('destination\-', 'gi')) )  ){
		// alert('ok');
			// $(this).parents('form').append('<input type="hidden" name="query" value="'+ url[ url.length- 1 ]+'"/>');
		// }
		$(this).parents('form').submit();
	});
	
	$('#filter select,#filter2 select').change(function(){
		$(this).parents('form').submit();
	});
	
	$('#m_france area').each(function(){
	
		$(this).attr('alt', $(this).attr('title'));
		$(this).attr('title','');
	});
		

	$('#m_france .mapHilight').click(function(){
		window.location.href = $(this).attr('alt');
	});
	 
	 // Redirection pour stats de clics pour les annonces dont l'annonceur affiche un lien direct vers son site
	 $('.lien').click(function(){
		// var link =  $(this).attr('href');
		alert( $(this).attr("rel"));
		if( $(this).attr("rel") != '' ){
			window.open( $(this).attr("rel") );
		}else
			window.open("/url-tracking/?object="+$('#an_id').val()+"&classe=ANNONCE&lang="+$('#an_lang').val());
		 return false;
	});
	 
	//Champ de recherche

	elementInNl = $('#in-email');
	elementInNl.focus(function() {
		if(elementInNl.val()== elementInNlDefault) {
			elementInNl.val('');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			elementInNl.val(elementInNlDefault);
		}
	}); 
	
	$('.email').each(function(){
		$(this).focus(function() {
			if($(this).val()== $(this).attr('title')) {
				$(this).val('');
			}
		}).blur(function() {
			if ($(this).val() == '') {
				$(this).val($(this).attr('title'));
			}
		}); 
	});
	
	// Gestion visionneuse
	$('.visu-lnk').click(function(){
	// alert($(this).parents('#home-carousel').find('.hcd-lnk').attr('href'));
		if( $(this).parents('#home-carousel').find('.hcd-lnk').attr('target') == '_blank')
			window.open($(this).parents('#home-carousel').find('.hcd-lnk').attr('href'));
		else
			window.location.href = $(this).parents('#home-carousel').find('.hcd-lnk').attr('href');
		
		return false;
	});
	$("#hc-visus .visu:first .hc-thumbs").show();
	
	
	
	$("#hc-thumbs ul li").each(function(i){
		$(this).attr('id','hc-thumb-'+i);
		$(this).click(function(){
			$("#hc-but-go-"+i).click();	
		});
	});
	$("#hc-visus ul li").each(function(i){
		$(this).attr('id','hc-visu-'+i);
	});
	buttons = new Array();
	$("#hc-buttons-go-wrapper span").each(function(i){
		$(this).attr('id',"hc-but-go-"+i);
		buttons.push("#hc-but-go-"+i);
	});
		

	carTab = $('#hc-buttons-go-wrapper span');
	
	nbItems = $("#hc-visus ul li").length;
	currentPanelVisio = $('#hc-visus .visu:first');
	if( nbItems > 1 ){
		hcDescriptions = $('#hc-descriptions .hc-description');
		$("#hc-visus").jCarouselLite({
			auto: 1000,
			speed: 500,
			visible: 1,
			//vertical:true,
			circular:true,
			pauseOnHover:"#home-carousel",
			btnGo:buttons,
			beforeStart:function(a,b) {
				idNext = b.attr('id').replace(/.*(\d+)/,"$1");
				idCurr = a.attr('id').replace(/.*(\d+)/,"$1");
				if(idNext!=idCurr) {
					if($('.hc-thumbs').length) {
						href = $('.hc-thumbs a:first',b).attr('href');
						$('.visu-img',b).attr('src',href);
					}
					$('.hc-thumbs',a).fadeOut('fast');
					$('#hc-descriptions .hc-description:hidden').remove();
					itemCurr = $('#hc-descriptions .hc-description').eq(0);
					$('#hc-descriptions').append('<div class="hc-description" style="display:none"></div>');
					itemNext = $('#hc-descriptions .hc-description').eq(1);
					itemNext.html($('.hc-thumbs-desc:first',b).html());
					itemCurr.fadeOut('fast',function(){$(this).remove();});
					itemNext.fadeIn('normal');
					// itemCurr = $('#hc-descriptions .hc-description.current')
					// itemCurr.fadeOut('normal',function(){$(this).removeClass('current');});
					// $(hcDescriptions[idNext]).fadeIn('normal',function(){$(this).addClass('current');});
				}
			
			},
			afterEnd: function(a) {
				$('.hc-thumbs',a).fadeIn('fast');
				idNext = a.attr('id').replace(/.*(\d+)/,"$1");
				$('#hc-thumbs .current').removeClass('current');
				$('#hc-thumb-'+idNext).addClass('current');
				$('#hc-buttons-go-wrapper span').removeClass('selected');
				$('#hc-buttons-go-wrapper #hc-but-go-'+idNext).addClass('selected');
				currentPanelVisio = a;
				idCurrentPanelVisio = a.attr('id');
				$('#home-carousel').addClass('paused');
				window.setTimeout("rotateThumbs('"+idCurrentPanelVisio+"')",5000);
				
			}
		});

		defaultH = $('#hc-buttons-go-wrapper span:first').height();
		$('#hc-buttons-go-wrapper span:last').css('padding-top','16px').height(defaultH+10);
	}
	
	$('#home-carousel').hover(
		function(){rotateThumbsOn = false;},
		function(){rotateThumbsOn = true;}
	);
	
	$('#hc-col1,#hc-buttons').hide().show();
	$('#home-carousel').addClass('paused');
	
	idCurrentPanelVisio = currentPanelVisio.attr('id');
	window.setTimeout("rotateThumbs('"+idCurrentPanelVisio+"')",5000);
	
	
	$("#hc-visus .hc-thumbs .hc-thumbs-w .hc-thumbs-lnk").live('click',function(){
		href = $('.hc-thumbs-lnk',$(this).parent()).attr('href');
		$('.visu-img',$(this).parents('.visu').get(0)).attr('src',href);
		
		$('#hc-descriptions .hc-description:hidden').remove();
		itemCurr = $('#hc-descriptions .hc-description').eq(0);
		$('#hc-descriptions').append('<div class="hc-description" style="display:none"></div>');
		itemNext = $('#hc-descriptions .hc-description').eq(1);
		itemNext.html($('.hc-thumbs-desc',$(this).parent()).html());
		itemCurr.fadeOut('fast',function(){$(this).remove();});
		itemNext.fadeIn('normal');
		
		$("#hc-visus .hc-thumbs .hc-thumbs-w .hc-thumbs-lnk.current").removeClass('current');
		$(this).addClass('current');
		return false;
	});
	
	
	
	// Skin des select/option
	$('#sel-country').selectmenu();
	$('#sel-country').change(function(){
	// alert($(this).val());
		window.location.href = $(this).val();
	});
	

/* -------------------------- Zone Recherche --------------------------*/
	
	//Mappage de la france
	$('#map_france').maphilight({stroke:false});
	
	//Permet de hilighter les zones sur les liens en dessous
	$('.zoneHilight').mouseover(function(){
		var id =  $(this).attr('id').split('_');
		$('#map_'+id[1]).mouseover();
	}).mouseout(function(){
		var id =  $(this).attr('id').split('_');
		$('#map_'+id[1]).mouseout();
	});
	
	//Permet de souligner une zone hilighter
	$('.mapHilight').mouseover(function(){
		var id =  $(this).attr('id').split('_'); 
		$('#zone_'+id[1]+' a').css({
			'text-decoration':'underline'
		});
	}).mouseout(function(){
		var id =  $(this).attr('id').split('_'); 
		$('#zone_'+id[1]+' a').css({
			'text-decoration':'none'
		});
	});
	
	//Change les liens lorsque l'utilisateurs change le type de logment
	$('.type-search').change(function(){
		var title = $(this).attr('title');
		
		// $('.zoneHilight').each(function(){
			// var path = $(this).find('a').attr('href').split('/');
			// var url = '/'+title;
			// for(i=2;i<path.length;i++){
				// url = url+'/'+path[i];
			// }
			// $(this).find('a').attr('href',url);
		// });
		$('.mapHilight').each(function(){
			if( $(this).attr('alt') ){
				var path = $(this).attr('alt').split('/');
				var url = '/'+title;
				for(i=2;i<path.length;i++){
					url = url+'/'+path[i];
				}
				$(this).attr('alt',url);
			}
		});
		
		$('.others-country a').each(function(){
			if( $(this).attr('href') ){
				var path = $(this).attr('href').split('/');
				var url = '/'+title;
				for(i=2;i<path.length;i++){
					url = url+'/'+path[i];
				}
				$(this).attr('href',url);
			}
		});
		
		$('#more-crt').each(function(){
			var path = $(this).attr('href').split('/');
			var url = '';
			for(i=1;i<path.length-2;i++){
				url = url+'/'+path[i];
			}
			url=url+'/'+title+'/';
			$(this).attr('href',url);
		});
		$('#link-more-crt').each(function(){
			var path = $(this).attr('href').split('/');
			var url = '';
			for(i=1;i<path.length-2;i++){
				url = url+'/'+path[i];
			}
			url=url+'/'+title+'/';
			$(this).attr('href',url);
		});
		
		$('#sel-country option').each(function(){
			var path = $(this).attr('value').split('/');
			var url = '/'+title;
			for(i=2;i<path.length;i++){
				url = url+'/'+path[i];
			}
			$(this).attr('value',url);
		});
		$('#type-search').val($(this).attr('id').substr(4));
		
		var tmp_destination = $('#destination').val();
		var tmp_destination_id = $('#destination_id').val();
		showsearchform($('#type-search').val());
		$('#destination').val(tmp_destination);
		$('#destination_id').val(tmp_destination_id);
	});
	showsearchform($('#type-search').val());
	

	
	$('.selectmenu').selectmenu('destroy');
	$('.selectmenu').selectmenu();

	
	$("#destination").change(function(){
		$("#destination_id").val(0);
	});
					
	function showsearchform_destination_focus(){
	
		elementInDest = $('#destination');
		elementInDest.focus(function() {
			if(!elementInDestLocked) {
				elementInDestDefault =  $('#destination').val();
				// if(elementInDest.val()== elementInDestDefault) {
					$('#destination').val('');
				// }
			}
		}).blur(function() {
			if ($(this).val() == '') {
				elementInDest.val(elementInDestDefault);
			}
		});
			
	}
	

	
	$('.search-comp.issearch').hide();
	$('#more-crt.accord').live('click',function(){
		$('.search-comp').slideToggle('slow',function(){
			$('#more-crt').html() == 'Plus de critères' ? $('#more-crt').html('Moins de critères') : $('#more-crt').html('Plus de critères');
			$('.selectmenu').selectmenu('destroy');
			$('.selectmenu').selectmenu();
		});
		return false;
	});
	function showsearchform(elem){
		if ( typeof(elem) != 'undefined' &&  !$('#search-form').hasClass('noajax') ){

			$('.search-gen,.search-comp').html('');
			$('.search-comp').hide();
			/*$('#more-crt').html('Plus de critères');*/
			$.ajax({
				url : '/ajax/get-search-engine/',
				beforeSubmit : $('.search-gen').html('<img src="/images/jquery/loader.gif" alt="loading" style="margin : 20px 0 20px 100px"/>'),
				data : 'term='+elem,
				type :  'get',
				cache : true,
				dataType : 'json',
				success : function(data){
					$('.search-gen').html(data.gen);
					$('.search-comp').html(data.comp);
					$('#search-form .selectmenu').selectmenu();
					
					$('#destination').autocomplete({
						selectFirst: true,
					    source: '/ajax/search-zones/',
					    minLength: 3,
						// focus : function(event, ui){
						// alert('ok');
							
							// elementInDestDefault =  $(this).val();
							// $(this).val('');
							
						// },
					    select: function(event, ui) {
					    	$("#destination_id").val(ui.item.id);
							
					    },
						search : function (event, ui){
							$("#destination_id").val('0'); // permet de remettre a zero la zone recherché afin que si l'utilisateur ne clique sur aucune item on lui propose des résultats de recherche
						},
						open: function(event, ui) { elementInDestLocked = true;},
						close: function(event, ui) { window.setTimeout('unlockInDest()',400);}
				    });
					// $( "#destination" ).bind( "autocompletefocus", function(event, ui) {
						// if ($(this).val() == '') {
							// $(this).val(elementInDestDefault);
						// }
					// });
					showsearchform_destination_focus();
					reload_link_map();
				}
			});		
		}
		else{
			$('#search-form .selectmenu').selectmenu();
					
			$('#destination').autocomplete({
				selectFirst: true,
				source: '/ajax/search-zones/',
				minLength: 3,
				select: function(event, ui) {
					$("#destination_id").val(ui.item.id);
				},
				search : function (event, ui){
					$("#destination_id").val('0'); // permet de remettre a zero la zone recherché afin que si l'utilisateur ne clique sur aucune item on lui propose des résultats de recherche
				}
			});			
			showsearchform_destination_focus();			
		}
		
			var handlers = {};
			var getDatePickerParams = function(element) {
				var id = element.attr('id');
				// parametres par défaut
				var r = {
					yearRange : '2000:2099',
					showButtonPanel: true,
					showOn: "both",
					buttonImage: "/css/screen/jquery/images/calendar.png",
					autoSize : true,
					buttonImageOnly: true,
					prevText : '',
					nextText : '',
					dateFormat:'dd/mm/yy',
					changeMonth: true,
					changeYear: true
				};
				
				// si begin existe, affecte la date de begin si date vaut null
				if (handlers[id] !== undefined) {
					r.beforeShow = function() {
						var widget = $('#'+id);
						if (widget.datepicker('getDate') === null) widget.datepicker('setDate', $('#'+handlers[id]).datepicker('getDate'));
					};
				}
				
				// si begin/end existe, handler end
				var t = (new RegExp('(.*)begin(.*)')).exec(id);
				if (t && t.length >= 2) {
					var before = t[1];
					var after = (t[2] !== undefined) ? t[2] : '';
					handlers[before+'end'+after] = id;
				}
				
				return r;
			};
			
			$('.text-form-date').each(function() { $(this).datepicker(getDatePickerParams($(this))); });
			show_type_logement( $('input[name=type-logement]:checked').val() );
	}
	
	$('#search-form').submit(function() {
		if (setup) {
			var yourDestination = setup.yourDestination;
			var destination = setup.destination;
		}
		else {
			var yourDestination = 'Votre destination';
			var destination = 'france';
		}
		
		if( $('#destination').val() == yourDestination) {
			$('#destination').val(destination);
			$('#destination_id').val('28');
		}
	});
	
	// handlers more critere
	$('#link-more-crt').each(function() {
		$(this).click(function() {
			location.href = $(this).attr('href') + '?' + $('#search-form').serialize();
			return false;
		});
	});
	$('#more-critere').click(function(){
		location.href = $(this).attr('alt') + '?' + $('#search-form').serialize();
	});
	
	$('.type-logement').live('click',function(){
		show_type_logement( $(this).val() );
	});
	
	function show_type_logement( val ){
	
		if ( val == 'Gîte' || val == 'Maison' || val =='Appartement' || val =='Chalet'  || val =='Chambre d\'hôtes' )
			$('.search-epis').show();
		else{
		
			
			$('.search-epis').hide();
		}
		
		if ( val == 'all' || val == 'Hébergement insolite' || val =='Villages et clubs de vacances' || val =='Mobil-home' )
			$('.search-animation').show();
		else
			$('.search-animation').hide();
		
		
		if ( val=='Villages et clubs de vacances' || val=='Hébergement insolite' )
			$('.search-formule').show();
		else
			$('.search-formule').hide();
			
			

		$('.selectmenu').selectmenu('destroy');
		$('.selectmenu').selectmenu();
	}
	
/* ------------------------------------------------------------------ */	
	
	// Scrooling doux
	$('#list-tabs a,.scroll,#detail-contactez-nous').click(function(){
		$.scrollTo(this.hash, 500);
		return false;
	});
	
	var galleries = $('.ad-gallery').adGallery({
		loader_image: '/images/jquery/loader.gif',
		width:310,
		height:230,
		description_wrapper: false,
		display_next_and_prev: false,
		effect: 'fade',
		callbacks: {
		// This gets fired right after the new_image is fully visible
			afterImageVisible: function() {
				$('#medias .ad-image a').click(function() {
					imgs = $('#medias .ad-thumb-list li a img');
					imgs_high = new Array();
					for(i = 0; i < imgs.length; i++) {
						imgs_high.push($(imgs[i]).attr('longdesc'));
					}
					if( $('.ad-thumb-list').height() > 52 ) {
						while( $('.ad-thumb-list').height() > 52 ) {
							$('.ad-thumb-list').width($('.ad-thumb-list').width()+1);
						}
					}
					$.fancybox(imgs_high, {
					'padding' : 0,
					'type' : 'image',
					'centerOnScroll' : true,
					'index':$('#medias .ad-thumb-list li a.ad-active').index('#medias .ad-thumb-list li a')
					});
					return false;
				});
			}
		}
	}); 
	
	$('.ad-gallery').width(318);
	$('.ad-image-wrapper').width(318);
	$('.ad-image-wrapper').height(238); 
	
	// Accordeon
	// $('.accordion-dm').accordion({ 
		// active: false,
		// collapsible: false 
	// });
	
	// $('.accordion-dm').bind('accordionchange', function(event, ui) {
			// $.scrollTo(ui.newHeader, 500); // jQuery object, activated header
		// });
	
	
	$('a.fancy,a.fancymini').click(function(){
		return false;
	});
	$('a.fancy').fancybox({
			'width' 		: 	600,
			'height' 		: 	500,
			'type'			:	'iframe',
			'padding' 		: 	5
		});
	$('a.fancymini').fancybox({
			'width' 		: 	600,
			'height' 		: 	170,
			'type'			:	'iframe',
			'padding' 		: 	5
		});
	$('a.fancyimg').fancybox({
				'padding' : 0,
				'type' : 'image',
				'centerOnScroll' : true
				});
	$('.datepicker').datepicker({
						yearRange : '2000:2099',
						showButtonPanel: true,
						showOn: "both",
						buttonImage: "/css/screen/jquery/images/calendar.png",
						autoSize : true,
						buttonImageOnly: true,
						prevText : '',
						nextText : '',
						dateFormat:'dd/mm/yy',
						changeMonth: true,
						changeYear: true
					});
					
/******************** Planning ***********************************/
	// title=G%26icirc%3Bte+Gras+%28Ard%26egrave%3Bche%29+pour+20+personnes&an=32701&month=10&year=2011&type=1#box-planning
	$('#selectweek').change(function(){
		var el = this;
		$('#ulPlan2 li').each(function(){
			if ($(this).hasClass('selected')){
				var url = window.location.href;
				var url_parts = url.split('?');
				var main_url = url_parts[0]; 
				// var url = $(this).find('a').attr('title');
				window.location = main_url.concat("?type="+$(el).val()).concat('#box-planning');
			}
		});
	});
	
/**************************************************/
	//cpt vacancier et ajout a ma selection
	var zip = '';
	$('#zipcode').autocomplete({
	    source: '/ajax/get-zones/',
	    minLength: 3,
	    select: function(event, ui) {
				zip = ui.item.zz;	
				city = ui.item.city;	
				id=ui.item.id;
				country=ui.item.country;
				$('#city').val(ui.item.city);
	        },
        close : function (event,ui){
			$('#zipcode').val(zip);
					$('#city').val(city);
				$('#city_id').val(id);
				$('#country_cpt').val(country);
			
        }
    });
	var city = '';
	$('#city').autocomplete({
		source : '/ajax/get-zones-by-city/',
		minLength : 3,
	    select: function(event, ui) {
		    	$('#zipcode').val(ui.item.zipcode);
				
				city = ui.item.zz;	
				id=ui.item.id;
				country=ui.item.country;
						$('#city').val(city);
				$('.opengmap').show();
						
	        },
        close : function (event,ui){
				$('#city').val(city);
				$('#city_id').val(id);
				$('#country_cpt').val(country);
				
        }
	});
	$('#dir_city').autocomplete({
		source : '/ajax/get-zones-by-city/',
		minLength : 3,
	    select: function(event, ui) {
				city = ui.item.zz;	
				id = ui.item.id;
				
				$('#dir_city').val(city);
				$('#id_dir_city').val(id);
	        }
	});
	
	$('.form_search_them').each(function() {
		this.onsubmit = function() {
			var zones = $('.form_search_them .text.ui-autocomplete-input');
			var t = true;
			var zone;
			zones.each(function() { zone = this; t = t && (this.value != ''); });
			if (! t) {
				alert('Vous devez renseigner la destination !');
				zone.focus();
				return false;
			}
			return true;
		};
	});
	
	try{ announceDetailsonloadHandler(); }catch(e){};
	
});
function unlockInDest() {
	elementInDestLocked = false;
}
// function prevCarousel(){
	// $("#ulPlan").trigger("prev",2);
// };

// function nextCarousel(){
	// $("#ulPlan").trigger("next",2);
// };

/* Fonction pour faire défiler les vignettes quand il n'y a qu'un seul panneau dans le carousel : location, camping ... */
function rotateThumbs(panel) {
	if(rotateThumbsOn && panel == currentPanelVisio.attr("id")) {
		if(nbItems > 1) {
			$("#home-carousel").addClass('paused');
		}
		if($(".hc-thumbs .hc-thumbs-w .hc-thumbs-lnk.current",currentPanelVisio).length == 0) {
			$(".hc-thumbs .hc-thumbs-w .hc-thumbs-lnk:first",currentPanelVisio).addClass('current');
		}
		//indexCurrentHcThumbsLnk = $('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk.current',currentPanelVisio).index(currentPanelVisio.find('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk'));
		indexCurrentHcThumbsLnk = $('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk',currentPanelVisio).index($('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk.current',currentPanelVisio));
		indexCurrentHcThumbsLnkNext = 0;
		if(indexCurrentHcThumbsLnk+1 < $('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk',currentPanelVisio).length) {
			indexCurrentHcThumbsLnkNext = indexCurrentHcThumbsLnk+1;
		} else {
			if(nbItems > 1) {
				$("#home-carousel").removeClass('paused');
				$('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk',currentPanelVisio).removeClass('current');
				return false;
			}
		}
		$('.hc-thumbs .hc-thumbs-w .hc-thumbs-lnk:eq('+indexCurrentHcThumbsLnkNext+')',currentPanelVisio).click();
	}
	window.setTimeout("rotateThumbs('"+panel+"')",5000);
}
/* permet l'affichage des liens sous la carte sur la page accueil */
function reload_link_map(){
	var them = $('#type-search').val();
	
	var reg = new RegExp('^/(.*)/(.*)');
	$('.zoneLinks .link').hide();
	$('.zoneLinks .link.them_'+them+', .zoneLinks .link.them_').each(function() {
		var themName = setup.uriThem[them];
		$(this).show();
		var href = $(this).attr('href');
		var t = reg.exec(href);
		if (! (t && t.length >= 3)) return;
		
		$(this).attr('href', '/'+themName+'/'+t[2]);
	});
}
/*********************************************************************/

