sfHover = function() {

	var sfEls = document.getElementById("menu").getElementsByTagName("LI");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover = function() {
			this.className+=" sfhover";
		}

		sfEls[i].onmouseout = function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}

	}

}

if (window.attachEvent) { window.attachEvent("onload", sfHover); }



$( function() {
	$("#menu ul").hover(
		function() {
			$(this).prev().addClass('active');
		},

		function() {
			$(this).prev().removeClass('active');
		}
	);
});


	$(function() {
		if( $(".datepicker").length == 0 ) {
			return;
		}

		$(".datepicker").datepicker({
			dateFormat: 'dd-mm-yy',
			minDate: new Date(),
			beforeShow: function (i, e) {
				e.dpDiv.zIndex("10000");
			}
		});
	});


$(function() {

	if( $("#diaporama").length == 0 ) {
		return;
	}

	$("#diaporama").showcase({
		linksOn: "titles",
		animation: {
			type: "fade"
		},
		navigator: {
			showNumber: false,
			item: {
				css: { display: "none" }
			}
		},
		titleBar: {
			enabled: false
		},
		images: [
			{url: "/images/diaporama/01-mobil-home-foret.jpg",description:""},
			{url: "/images/diaporama/02-tente-riviere.jpg",description:""},
			{url: "/images/diaporama/03-chalet-entre-deux-lacs.jpg",description:""},
			{url: "/images/diaporama/04-caravane-camping.jpg",description:""},
			{url: "/images/diaporama/05-chalet-detente.jpg",description:""}
		]
	});
});

$( function() {
	if( $(".fancy").length == 0 ) {
		return;
	}

	$(".fancy").fancybox();
});


$(function(){
	if( $("#accordion").length == 0 ) {
		return;
	}


	var stop = false;
	$("#accordion h2").click(function(event) {
		if (stop) {
			event.stopImmediatePropagation();
			event.preventDefault();
			stop = false;
		}
	});

	if( jQuery.browser.msie && /^[6|7]/.test(jQuery.browser.version) ) {
		$("#accordion").accordion();
	} else {
		$("#accordion").accordion({autoHeight:false});
	}

});


$(function(){
	if( $("#SearchForm").length == 0 ) {
		return;
	}

	$("#SearchForm input[name^=service]:checked").each(function(){
		var index = $(this).val();
		$("#Distance_Service_"+index ).show();
	});

	$("#SearchForm input[name^=service]").click(function() {
		var index = $(this).val();

		if( $(this).attr("checked") ) {
			$("#Distance_Service_"+index ).show("fast");
		} else {
			$("#Distance_Service_"+index ).hide();
		}
	});

});



function checkContactForm () {
	if( $("#lastname").val().empty() ) {
		alert( lang["Veuillez saisir votre nom"] );
		return false;
	}

	if( ! $("#adresse_mail").val().isEmail() ) {
		alert("Veuillez saisir votre adresse email");
		return false;
	}

	if( $("#texte").val().empty() ) {
		alert("Veuillez saisir un message");
		return false;
	}

	return true;
}



$(function(){
	if( $(".accordion_theme").length == 0 ) {
		return;
	}


	var stop = false;
	$(".accordion_theme h2").click(function(event) {
		if (stop) {
			event.stopImmediatePropagation();
			event.preventDefault();
			stop = false;
		}
	});

	aActive = /\?([0-9])$/.exec(document.location.href);

	if( aActive == null ){
		iActive = 0;
	} else {
		iActive = aActive[1];
	}

	iActive = parseInt(iActive);

	if( jQuery.browser.msie && /^[6|7]/.test(jQuery.browser.version) ) {
		$(".accordion_theme").accordion({active:iActive});
	} else {
		$(".accordion_theme").accordion({autoHeight:false,active:iActive});
	}

	if( iActive > 0 ) {
		iActive++;
		$('.title'+iActive).scrollTo();
	}
});


function viewActu() {
	$(".savoirplus").hide();
	$("#Actu_Complete").slideDown(400, function(){
		$("#Actu_Complete").css("display" , "inline")
	});


	$(".snippet").html( $(".snippet").text().trim().replace(/\.\.\.$/m, '')  );
}
