var tce={
	lang:'fr'
};

function clickmap(id) {
	$('#cities #block-content-main-first-pane').hide();
	$('#cities #block-content-main-second-pane').show();
	$('#cities #block-content-main-second-pane ul li').removeClass('active');
	$('#cities #block-content-main-second-pane ul li:eq('+id+')').addClass('active');
	$('#cities .block-content-right-pane').hide();
	$('#cities #block-content-right-first-pane').show();
	$('#cities .area').hide();
	$('#cities .area:eq('+id+')').show();
	$('#cities .readmore').removeClass('active');
}

$(document).ready(function() {

/* **********************************
	 * multi tabs
	 * **********************************/

	zindextab = $('.tabs_tabs li').size()+50;

	for(var i = 0; i < $('.tabs_tabs li').length; i++) {
	if ($.browser.msie && $.browser.version.substr(0,1)<8) {
		if (i == 1) {
			$('.tabs_tabs li')[i].style.paddingLeft=130+'px';
		} else if (i == 2) {
			$('.tabs_tabs li')[i].style.paddingLeft=130+'px';
		} else if (i == 3) {
			$('.tabs_tabs li')[i].style.paddingLeft=390+'px';
		}
	} else {
		$('.tabs_tabs li')[i].style.paddingLeft=130*i+'px';
	}
	zindextab2 = zindextab-i;
	$('.tabs_tabs span')[i].style.zIndex=zindextab2;
	}


	$('.tabs_tabs span').click(function(){
		switch_tabs($(this));
	});

	switch_tabs($('.defaulttab_tabs'));


	zindextabx = $('.tabs_tabs2 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs2 li').length; i++) {
	$('.tabs_tabs2 li')[i].style.paddingLeft=220*i+'px';
	zindextabx2 = zindextabx-i;
	$('.tabs_tabs2 span')[i].style.zIndex=zindextabx2;
	}


	$('.tabs_tabs2 span').click(function(){
		switch_tabs2($(this));
	});

	switch_tabs2($('.defaulttab_tabs'));

	zindextabx = $('.tabs_tabs3 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs3 li').length; i++) {
	$('.tabs_tabs3 li')[i].style.paddingLeft=165*i+'px';
	zindextabx2 = zindextabx-i;
	$('.tabs_tabs3 span')[i].style.zIndex=zindextabx2;
	}


	$('.tabs_tabs3 span').click(function(){
		switch_tabs3($(this));
	});

	switch_tabs3($('.defaulttab_tabs'));


	zindextabx = $('.tabs_tabs5 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs5 li').length; i++) {
	$('.tabs_tabs5 li')[i].style.paddingLeft=140*i+'px';
	zindextabx2 = zindextabx-i;
	$('.tabs_tabs5 span')[i].style.zIndex=zindextabx2;
	}


	$('.tabs_tabs5 span').click(function(){
		switch_tabs5($(this));
	});

	switch_tabs5($('.defaulttab_tabs'));

	/* **********************************
	 * General
	 * **********************************/

	// read more button
	$("a.read-more").live('click', function() {
		$(this).hide().next().show();
		return false;
	});

	// delete ugly border on blur
	$("a").focus(function(e) { this.blur(); });

	// searchbox
	$('#searchbox input.form-text').click(function(e){
		if ($(this).val() == 'Search' || $(this).val()=='Recherche') {
			$(this).focus().val('');
		}
	});
	$('#searchbox input.form-text').bind('blur', function(e){
		if ($(this).val() == '') {
			$(this).val((tce.lang=='en')?"Search":"Recherche");
		}
	});

	/* **********************************
	 * homepage
	 * **********************************/
	if ($('body#page-home').length) {
		$('#header #header-picture-btn ul li.img').not('.active').bind('mouseenter mouseleave', function(){
		$(this).find('span').toggle();
		});
	}

	if($('#header-picture-btn li.img').length) {
		var currentHeaderSlide=0;
		var headerSlideInterval=5000;
		var showHeaderSlide=function(i) {
			$('#header-picture-btn li.active').removeClass('active');
			$('#header-picture-btn li:eq('+i+')').addClass('active');
			//$('.header-picture-slide:visible').hide();
			//$('.header-picture-slide:eq('+i+')').show();
			$('.header-picture-slide:visible').fadeOut(1000);
			$('.header-picture-slide:eq('+i+')').fadeIn(500);
		};
		var playHeaderSlides=function() {
			if(headerSlidePlaying) {
				currentHeaderSlide++;
				if(currentHeaderSlide>=$('#header-picture-btn li.img').length)
					currentHeaderSlide=0;
				showHeaderSlide(currentHeaderSlide);
			}
		};
		/*
		$('#header-picture-btn li.img').click(function(){
			$('#header-picture-btn .pause').click();
			var i=$('#header-picture-btn li.img').index($(this));
			if (i!=currentHeaderSlide) {
				currentHeaderSlide=i;
				showHeaderSlide(currentHeaderSlide);
			}
			return false;
		});
		*/
		var headerSlidePlaying=true;
		$('#header-picture-btn .play, #header-picture-btn .pause').click(function(){
			if($(this).hasClass('pause')) {
				$(this).hide();
				$('#header-picture-btn .play').show();
				headerSlidePlaying=false;
			}
			else {
				$(this).hide();
				$('#header-picture-btn .pause').show();
				headerSlidePlaying=true;
			}
			return false;
		});
		setInterval(playHeaderSlides, headerSlideInterval);
		$('.header-picture-slide').mouseenter(function(){
			$('#header-picture-btn .pause').click();
			$('.header-picture-link', $(this)).show();
		});
		$('.header-picture-slide').mouseleave(function(){
			//$('#header-picture-btn .play').click();
			$('.header-picture-link', $(this)).hide();
			$('#header-picture-btn .play').click();
		});
		$('#header-picture-btn li.img').mouseenter(function(){
			$('#header-picture-btn .pause').click();
			var i=$('#header-picture-btn li.img').index($(this));
			if (i!=currentHeaderSlide) {
				currentHeaderSlide = i;
				showHeaderSlide(i);
			}
			$('.header-picture-slide:eq('+i+') .header-picture-link').show();
		});
		$('#header-picture-btn li.img').mouseleave(function(){
			var i=$('#header-picture-btn li.img').index($(this));
			$('.header-picture-slide:eq('+i+') .header-picture-link').hide();
			$('#header-picture-btn .play').click();
		});

		$('#content .inner').css('padding-top', (275+$('#header-picture-btn').height())+'px');
		$('#header #header-picture-btn ul li.img').height($('#header-picture-btn').height()-12);
	}

	/* Sitemap */
	$('.sitemap-items .list').next().next().hide();
	$('.sitemap-items .list').click(function(){
		if($(this).hasClass('expanded')) {
			$(this).removeClass('expanded');
			$(this).next().next().hide();
		}
		else {
			$(this).addClass('expanded');
			$(this).next().next().show();
		}
		return false;
	});

	/* **********************************
	 * activity-list
	 * **********************************/
	$('#activity-list .toggle a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisList = 	$('#activity-list .activity-elt').index($(this).parents('.activity-elt'));
		$('#activity-list .activity-elt:eq('+thisList+') > div.list').toggle();
	});

	$('#activity-list2 .toggle a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisList = 	$('#activity-list2 .activity-elt2').index($(this).parents('.activity-elt2'));
		$('#activity-list2 .activity-elt2:eq('+thisList+') > div.list').toggle();
	});


	/* **********************************
	 * tab block
	 * **********************************/
	$('.tab-block .tab-title').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.tab-block .tab-title').index($(this));
    $(".tab-block .tab-title").removeClass("active");
    $(".tab-block .tab-title:eq("+thisTab+")").addClass("active");
    $(".tab-block .block-content").hide();
    $(".tab-block .block-content:eq("+thisTab+")").show();
	});


	/* **********************************
	 * dropdown block
	 * **********************************/
	$('.dropdown-opener').click(function(e){
		$(this).parents('ul.dropdown-list').toggleClass('open');
	});
	$('.dropdown').bind('mouseleave', function(e){
		$(this).find('ul.dropdown-list').removeClass('open');
	});
	$('.dropdown-list a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$(this).parents('ul.dropdown-list').find('.dropdown-opener').html($(this).html());
	});



	/* **********************************
	 * collapsible block
	 * **********************************/
	$('.collapsible-block > .block-title a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$(this).parents('.collapsible-block').toggleClass('collapsed');
	});

	$('.collapsible-block2 > .block-title a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$(this).parents('.collapsible-block2').toggleClass('collapsed');
	});

	$('.block-title#postComment a, .block-title#comments a').live('click',function(e){
		e.stopPropagation();
		e.preventDefault();
		$(this).parents('.collapsible-block').toggleClass('collapsed');
	});

	/* **********************************
	 * tab main content
	 * **********************************/
	$('.main-tab-title a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.main-tab-title a').index($(this));
    $(".main-tab-title a").removeClass("active");
    $(".main-tab-title a:eq("+thisTab+")").addClass("active");
    $(".main-tab-content").hide();
    $(".main-tab-content:eq("+thisTab+")").show();
    $(".main-tab-bottom").hide();
    $(".main-tab-bottom:eq("+thisTab+")").show();
    if (thisTab == 0) {
    	$(".main-tab-title-left").css({ backgroundPosition:"0px 0" });
    	$(".main-tab-title-center").css({ backgroundPosition:"-127px 0px" });
    } else if (thisTab == 1) {
    	$(".main-tab-title-left").css({ backgroundPosition:"0px -40px" });
    	$(".main-tab-title-center").css({ backgroundPosition:"-127px -40px" });
    } else if (thisTab == 2) {
    	$(".main-tab-title-left").css({ backgroundPosition:"0px -80px" });
    	$(".main-tab-title-center").css({ backgroundPosition:"-127px -80px" });
    }

	});
	$('#showMap').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = 1;
	    $(".main-tab-title a").removeClass("active");

    	$(".main-tab-title-left").css({ backgroundPosition:"0px -40px" });
    	$(".main-tab-title-center").css({ backgroundPosition:"-127px -40px" });
	    //$(".main-tab-title-center map").addClass("active");

	    $(".main-tab-title a:eq("+thisTab+")").addClass("active");
	    $(".main-tab-content").hide();
	    $(".main-tab-content:eq("+thisTab+")").show();
	    $(".main-tab-bottom").hide();
	    $(".main-tab-bottom:eq("+thisTab+")").show();
		if($.placemap) {
			$.placemap.refresh();
		}
	});

	$('#fullGallery').click(function(e){
		$("a.main-tab-title-right").click();
		return false;

	});

	/* **********************************
	 * tab main content2
	 * **********************************/
	$('.main-tab-title2 a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.main-tab-title2 a').index($(this));
    $(".main-tab-title2 a").removeClass("active");
    $(".main-tab-title2 a:eq("+thisTab+")").addClass("active");
    $(".main-tab-content").hide();
    $(".main-tab-content:eq("+thisTab+")").show();
    $(".main-tab-bottom").hide();
    $(".main-tab-bottom:eq("+thisTab+")").show();

	});

	/* **********************************
	 * tab main content3
	 * **********************************/
	$('.main-tab-title3 a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.main-tab-title3 a').index($(this));
    $(".main-tab-title3 a").removeClass("active");
    $(".main-tab-title3 a:eq("+thisTab+")").addClass("active");
    $(".main-tab-content").hide();
    $(".main-tab-content:eq("+thisTab+")").show();
    $(".main-tab-bottom").hide();
    $(".main-tab-bottom:eq("+thisTab+")").show();

	});


	/* **********************************
	 * tab main content packages
	 * **********************************/
	$('.main-tab-title-packages a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.main-tab-title-packages a').index($(this));
    $(".main-tab-title-packages a").removeClass("active");
    $(".main-tab-title-packages a:eq("+thisTab+")").addClass("active");
    $(".main-tab-content").hide();
    $(".main-tab-content:eq("+thisTab+")").show();
    $(".main-tab-bottom").hide();
    $(".main-tab-bottom:eq("+thisTab+")").show();

	});

	/* **********************************
	 * big tab content
	 * **********************************/
	$('.big-tab-title a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisTab = $('.big-tab-title').index($(this).parent());
    $(".big-tab-title").removeClass("active");
    $(".big-tab-title:eq("+thisTab+")").addClass("active");
    $(".big-tab").hide();
    $(".big-tab:eq("+thisTab+")").show();
	});

	/* **********************************
	 * google map btn (full map or info+map)
	 * **********************************/
	$('#localization-btn').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$('#localization').toggleClass('full-map');
	});

	/* **********************************
	 * Tools
	 * **********************************/
	$('.tools .tool').bind('mouseenter mouseleave', function(){
		$(this).toggleClass('hover');
	});


	/* **********************************
	 * Share page (partagez)
	 * **********************************/
	if ($('#slideshow-content').length) { /* execute function only on the "share" page */

		$('#vote-btn.nonvoted').live("click", function(e){
			e.stopPropagation();
			e.preventDefault();
			$(this).removeClass('nonvoted').addClass('voted');
			var voteResult = $(this).parent().find('#vote-result span');
			voteResult.html(parseInt(voteResult.html())+1);
		});
		$('#vote-btn.voted').live("click", function(e){
			e.stopPropagation();
			e.preventDefault();
			$(this).removeClass('voted').addClass('nonvoted');
			var voteResult = $(this).parent().find('#vote-result span');
			voteResult.html(parseInt(voteResult.html())-1);
		});

		$('#share-showcase .block-title .tab-title').click(function(){
			var tabidx = $(this).parent().find('.tab-title').index($(this));
			$('#share-showcase').removeClass('tab0-active tab1-active tab2-active').addClass('tab'+tabidx+'-active');

		});
		$('#share-showcase2 .block-title .tab-title').click(function(){
			var tabidx = $(this).parent().find('.tab-title').index($(this));
			$('#share-showcase2').removeClass('tab0-active tab1-active tab2-active').addClass('tab'+tabidx+'-active');

		});

	}

	 $('#share-showcase2 .block-title .tab-title').click(function(){
		var tabidx = $(this).parent().find('.tab-title').index($(this));
		$('#share-showcase2').removeClass('tab0-active tab1-active tab2-active').addClass('tab'+tabidx+'-active');
	});

	 $('#share-showcase_2tab .block-title .tab-title').click(function(){
		var tabidx = $(this).parent().find('.tab-title').index($(this));
		$('#share-showcase_2tab').removeClass('tab0-active tab1-active tab2-active').addClass('tab'+tabidx+'-active');
	});




	/* **********************************
	 * cities-pane
	 * **********************************/
	$('#cities #block-content-main-first-pane .readmore a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$('#cities #block-content-main-first-pane').hide();
		$('#cities #block-content-main-second-pane').show();
		$('#cities #block-content-main-second-pane ul.big-list li.active').removeClass('active');
		$('#cities #block-content-main-second-pane .readmore').addClass('active');
		$('#cities .area').hide();
		$('#cities #block-content-right-second-pane').show();
		$('#cities #all-cities-list').show();
	});
	$('#cities #block-content-main-second-pane .back a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$('#cities #block-content-main-second-pane').hide();
		$('#cities #block-content-main-first-pane').show();
		//~ $('#cities #block-content-main-first-pane .readmore').addClass('active');
	});

	//~ refresh info when clicking on the cities list on the left
	$('#cities .area').hide();
	$('#cities #all-cities-list').hide();
	$('#cities .block-content-left ul li a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$('#cities .block-content-right-pane').hide();
		$('#cities #block-content-right-first-pane').show();
		$('#cities .readmore').removeClass('active');

		$('#cities .block-content-left ul li').removeClass('active');
		var thisAreaIndex = $('#cities .block-content-left ul li').index($(this).parent());
		$('#cities .block-content-left ul li:eq('+thisAreaIndex+')').addClass('active');
		$('#cities .area').hide();
		$('#cities .area:eq('+thisAreaIndex+')').show();
		$('#cities .readmore').removeClass('active');
	});

	//~ switch to 2nd pane when clicking on "readmore link"
	$('#cities .block-content-left .readmore a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		$('#cities .block-content-right-pane').hide();
		$('#cities #block-content-right-second-pane').show();
		$('#cities ul.big-list li.active').removeClass('active');
		$('#cities .readmore').addClass('active');
		$('#cities #all-cities-list').show();
	});

	//~ all-cities-list default settings
	$('#cities #all-cities-list .all-cities-elt').hide();
	var thisCitiesList = $('#cities #all-cities-list #all-cities-index li.current');
	var thisCitiesListIndex = $('#cities #all-cities-list #all-cities-index li').index(thisCitiesList);
	$('#cities #all-cities-list .all-cities-elt:eq('+thisCitiesListIndex+')').show();

	//~ all-cities-list interactivity
	$('#cities #all-cities-list #all-cities-index li a').click(function(e){
		e.stopPropagation();
		e.preventDefault();
		var thisCitiesListIndex = $('#cities #all-cities-list #all-cities-index li').index($(this).parent());
		$('#cities #all-cities-list .all-cities-elt').hide();
		$('#cities #all-cities-list .all-cities-elt:eq('+thisCitiesListIndex+')').show();
		$('#cities #all-cities-list #all-cities-index li').removeClass('current');
		$('#cities #all-cities-list #all-cities-index li:eq('+thisCitiesListIndex+')').addClass('current');
	});

	$('#cities .area-list-elt a').click(function(){
		$('#cities #block-content-main-first-pane').hide();
		$('#cities #block-content-main-second-pane').show();
		$('#cities #block-content-main-second-pane ul li').removeClass('active');
		var id=$('#cities .area-list-elt li').index($(this).parent());
		$('#cities #block-content-main-second-pane ul li:eq('+id+')').addClass('active');
		$('#cities .block-content-right-pane').hide();
		$('#cities #block-content-right-first-pane').show();
		$('#cities .area').hide();
		$('#cities .area:eq('+id+')').show();
		$('#cities .readmore').removeClass('active');
		return false;
	});


	/* **********************************
	 * hosting
	 * **********************************/
		$('#hosting-form #hosting-other span.btn a').click(function(e){
				e.preventDefault();
				$('#hosting-form #hosting-other').toggleClass('seemore');
		});
		$('#hosting-form #hosting-keywords input').click(function(e){
			$(this).focus().val('');
		});
		$('#hosting-form #hosting-keywords input').bind('blur', function(e){
			if ($(this).val() == '') {
				$(this).val("Ex: nom de l'hôtel, ville");
			}
		});



	/* **********************************
	 * interactive map
	 * **********************************/
$('#localization-legend div.block-title a').bind('click', function(e){
	e.preventDefault();
	$('#localization-legend').toggleClass('collapsed');;
});

/* **********************************
	 * interactive map
	 * **********************************/
	var legends = [];

	function autoCollapse() {
		if ( $('#localization-legend ul li').length == 0 ) {
			$('#localization-legend').addClass('collapsed');
		}
		return true;
	}

	function hideLegend(id) {
		var li = $('#interactive-map #localization-info-content li[id='+id+']');

		if (li.hasClass('selected')) {
			li.removeClass('selected');
			var places=li.parents('.block-content').data('places')[id];
			$.interactivemap.hidePlaces(places);
		}
		$('#interactive-map #localization-legend li[id='+id+'-legend]').remove();
		autoCollapse();
	}

	// legend close-links (using live instead of bind to attach behavior to new legend element)
	$('#interactive-map #localization-legend li a.close').live('click', function(e){
			$(this).blur();
			e.stopPropagation();
			e.preventDefault();
			hideLegend($(this).attr('rel'));
	});

	$('#interactive-map #localization-info-content li:not(.all) a').live('click',function(e){
			e.stopPropagation();
			e.preventDefault();
			$(this).parent().toggleClass('selected');

			var legendId = $(this).parent().attr('id');
			var places=$(this).parents('.block-content').data('places')[legendId];
			var i;

			if ($(this).parent().hasClass('selected')) {
				var $legends = $('#interactive-map #localization-legend li');
				if ($legends.length>=7) {
					hideLegend($legends.attr('id').replace(/\-legend$/,''));
					$legends = $('#interactive-map #localization-legend li');
				}
				var colors=[1,2,3,4,5,6,7];
				$legends.each(function(){
					colors[$(this).attr('rel')-1]=undefined;
				});
				var color=1;
				for (i in colors) {
					if(colors[i]!=undefined) {
						color = colors[i];
						break;
					}
				}

				$.interactivemap.showPlaces(places, color);
				//~ var legendCloseLink = $.new('a').attr('href','#').attr('class','close').append('x');
				var legendCloseLink = '<a rel="'+legendId+'" href="#" class="close">x</a>';

				var legendText = $(this).text();
				if(legendText.indexOf('(') != -1) {
					legendText = $(this).text().substr(0, $(this).text().indexOf('('));
				}
				//~ var legendElt = $.new('li').attr('rel', legendId).append(legendCloseLink).append(legendText).appendTo('#interactive-map #localization-legend ul');
				var legendElt = '<li id="'+legendId+'-legend" rel="'+color+'">'+legendCloseLink+'<span>'+legendText+'</span></li>';
				$('#interactive-map #localization-legend ul').append(legendElt);
				$('#interactive-map #localization-legend li[id='+legendId+'-legend]').css('background','url(img/map/m'+color+'_16x16.png) 0px 0px no-repeat');
				$('#interactive-map #localization-legend').removeClass('collapsed');
			}	else {
				$.interactivemap.hidePlaces(places);
				$('#interactive-map #localization-legend li a[rel='+legendId+']').parent().remove();
				autoCollapse();
			}
	});
	$('#interactive-map #localization-info-content li.all a').click(function(e){
			e.stopPropagation();
			e.preventDefault();
			$(this).parent().toggleClass('selected');

			if ($(this).parent().hasClass('selected')) { // add all
				//~ $(this).parent().siblings('li.selected').find('a').trigger('click');
				//~ $(this).parent().siblings('li').find('a').trigger('click');
			} else { // remove all
				//~ $(this).parent().siblings('li:not(.selected)').find('a').trigger('click');
				//~ $(this).parent().siblings('li').find('a').trigger('click');
				autoCollapse();
			}
	});

	places={};

	$('#interactive-map #localization-info-content .collapsible-block .block-title a').click(function(e){
			e.stopPropagation();
			e.preventDefault();
			if($(this).parent().next().children('ul').length==0) {
				$.ajax({
					url:this.href,
					dataType:'json',
					container:$(this).parent().next(),
					success:function(data,status) {
						this.container.append(data.categories);
						this.container.data('places',data.places);
					}
				});
			}
	});

	 //~ never un-collapse legend if empty
	$('#interactive-map #localization-legend .block-title a').click(function(e){
			e.stopPropagation();
			e.preventDefault();
			autoCollapse();
	});

	$('.map-directions a').live('click',function(){
		var $link=$(this);
		if(!$link.hasClass('active')) {
			$('.map-directions a').removeClass('active');
			$('.map-directions .form').hide();
			$('.map-directions .form.'+$link.attr('class')).show();
			$link.addClass('active');
		}
		return false;
	});

	$('#localization-info .directions a').live('click',function(){
		var $link=$(this);
		if(!$link.hasClass('active')) {
			$('#localization-info .directions a').removeClass('active');
			$('#localization-info .directions .form').hide();
			$('#localization-info .directions .form.'+$link.attr('class')).show();
			$link.addClass('active');
		}
		return false;
	});

	$('a.main-tab-title-right.map').click(function(){
		if($.placemap) {
			$.placemap.refresh();
		}
	});
	$('a.main-tab-title-center.map').click(function(){
		if($.placemap) {
			$.placemap.refresh();
		}
	});

	/* **********************************
	 * favorites
	 * **********************************/
	$('#favorites-notes textarea.empty').click(function(e){
		$(this).removeClass('empty').focus().val('');
	});

	$('#favorites-notes textarea').bind('blur', function(e){
		if ($(this).val() == '') {
			$(this).val('Click to edit the text');
			$(this).addClass('empty');
		}
	});

	$('#favorites-page .favorites-elt a').live('click', function(e){
		if($(this).attr('rel')!='') {
			$.placemap.showPlace($(this).attr('rel'));
			return false;
		}
	});

	$('#sitemap3 .social a').hover(function(){
		var url=$('img',$(this)).attr('src').replace(/16x16_mono/,'16x16');
		$('img',$(this)).attr('src',url);
	}, function(){
		var url=$('img',$(this)).attr('src').replace(/16x16\//,'16x16_mono/');
		$('img',$(this)).attr('src',url);
	});
});


function switch_tabs(obj)
{

	zindextabx = $('.tabs_tabs li').size()+50;

	for(var i = 0; i < $('.tabs_tabs li').length; i++) {
	zindextab2x = zindextabx-i;
	$('.tabs_tabs span')[i].style.zIndex=zindextab2x;
	}

	$('.tab-content_tabs').hide();
	$('.tabs_tabs span').removeClass("selected");
	var id = obj.attr("rel");

	if (obj.attr("id")) {
	document.getElementById(obj.attr("id")).style.zIndex=100;
	}

	$('#'+id).show();
	obj.addClass("selected");
	//obj.style.zIndex=100;
	obj.trigger('afterShow');
}

function switch_tabs2(obj)
{

	zindextabx = $('.tabs_tabs2 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs2 li').length; i++) {
	zindextab2x = zindextabx-i;
	$('.tabs_tabs2 span')[i].style.zIndex=zindextab2x;
	}

	$('.tab-content_tabs').hide();
	$('.tabs_tabs2 span').removeClass("selected");
	var id = obj.attr("rel");

	if (obj.attr("id")) {
	document.getElementById(obj.attr("id")).style.zIndex=100;
	}

	$('#'+id).show();
	obj.addClass("selected");
	//obj.style.zIndex=100;
}

function initSuperBox(closeText)
{
	$.superbox.settings = {
		overlayOpacity: .6,
		closeTxt: closeText
	};
	$.superbox();
}

function switch_tabs3(obj)
{

	zindextabx = $('.tabs_tabs3 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs3 li').length; i++) {
	zindextab2x = zindextabx-i;
	$('.tabs_tabs3 span')[i].style.zIndex=zindextab2x;
	}

	$('.tab-content_tabs').hide();
	$('.tabs_tabs3 span').removeClass("selected");
	var id = obj.attr("rel");

	if (obj.attr("id")) {
	document.getElementById(obj.attr("id")).style.zIndex=100;
	}

	$('#'+id).show();
	obj.addClass("selected");
	//obj.style.zIndex=100;
}



function switch_tabs5(obj)
{

	zindextabx = $('.tabs_tabs5 li').size()+50;

	for(var i = 0; i < $('.tabs_tabs5 li').length; i++) {
	zindextab2x = zindextabx-i;
	$('.tabs_tabs5 span')[i].style.zIndex=zindextab2x;
	}

	$('.tab-content_tabs').hide();
	$('.tabs_tabs5 span').removeClass("selected");
	var id = obj.attr("rel");

	if (obj.attr("id")) {
	document.getElementById(obj.attr("id")).style.zIndex=100;
	}

	$('#'+id).show();
	obj.addClass("selected");
	//obj.style.zIndex=100;
}

