/* * Affichage d'un contenu suivant *  * @copyright	egzakt.com * * @version 	2007/06/05 * @package		EDU-083 * @author 		Emilie */function bloc_deroulant(objet) {	objet.next().slideToggle("normal");	objet.toggleClass("selected");	objet.parent().toggleClass("bloc_deroulant_selected");	return false;}$(function() {	$(".zone_deroulante").not(".ouvert").hide();		$("a.lien_deroulant").click(		function(){			return bloc_deroulant($(this));		}	);			if (navigator.appName == "Microsoft Internet Explorer") {		$("input").keydown(function(e){			if(e.keyCode == 13) {				$(this).parents("form").submit();				return false;			}		});	}		$("form").submit(function () {		$("input,textarea").each(function(index){			if ($(this).attr("alt") == $(this).val())			{		    	$(this).val("");			}		});	});	    $("input,textarea").focus(function(){		if ($(this).attr("alt") != "")		{	    	if ($(this).val() == $(this).attr("alt")) {	    		$(this).val("");	    	}		}    });    $("input,textarea").blur(function(){		if ($(this).attr("alt") != "")		{	    	if ($(this).val() == "") {	    		$(this).val($(this).attr("alt"));	    	}		}    });	populate_inputs();	});/* * Vérifier si une valeur alt="" est fournis au champs input et textarea * et si le input/textarea a l'attribut value vide, mettre la valeur du  * alt dans l'attribut value.  * * Était direct dans le .ready jusqu'a se que je remarque qu'il ne * s'appliquait pas au formulaire loader en ajax, maintenant on n'a qu'a * caller populate_inputs() sur le callback du load. */function populate_inputs() {	$("input,textarea").each(function(index) {		if ($(this).attr("alt") != "")		{	    	if ($(this).val() == "") {	    		$(this).val($(this).attr("alt"));	    	}		}	});}/* * Autoriser seulement des chiffres *  * @copyright	egzakt.com * @version 	2008/10/28 * @author 		Emilie */function champ_numerique(e) {	// 48 à 58 = 0 à 9	// 96 à 105 = 0 à 9 du numpad	// 8 = backspace	// 9 = tab	// 37 = fleche gauche	// 39 = fleche droite	// 46 = delete		key = e.which ? e.which : e.keyCode			if (!(((key >= 48) && (key <= 58)) || ((key >= 96) && (key <= 105)) || (key == 8) || (key == 9) || (key == 37) || (key == 39) || (key == 46))) {		return false;	}}// Obtenir le nombre d'éléments dans un objet (hash array)// http://stackoverflow.com/questions/5223/length-of-javascript-associative-arrayObject.size = function(obj) {    var size = 0, key;    for (key in obj) {        if (obj.hasOwnProperty(key)) size++;    }    return size;};// http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_in_array/function in_array(needle, haystack, strict) {	var found = false, key, strict = !!strict;	for (key in haystack) {		if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {			found = true;			break;		}	}	return found;}Object.first = function(obj) {	for (key in obj) {		if (obj.hasOwnProperty(key)) {			return obj[key];		}	}	return false;};/* * Limiter le nombre de caractères dans un textarea *  * @author		http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/ */function limitChars(textid, limit, infodiv) {	var text = $("#"+textid).val(); 	var textlength = text.length;	if (textlength > limit) {				if (langue == "fr") {			$("#" + infodiv).html("Vous ne pouvez pas écrire plus de "+limit+" caractères.");		}		else {			$("#" + infodiv).html("You can't write more than "+limit+" characters.");		}		$("#"+textid).val(text.substr(0,limit));		return false;	}	else {		if (langue == "fr") {			$("#" + infodiv).html("Vous avez "+ (limit - textlength) +" caractères restants.");		}		else {			$("#" + infodiv).html("You have "+ (limit - textlength) +" characters left.");		}		return true;	}}function sliderPagination(photo_courante,objet_diaporama,total_photos,nb_par_set) {	photo_courante == 1 ? objet_diaporama.children("a.precedent").hide() : objet_diaporama.children("a.precedent").show();	photo_courante + nb_par_set > total_photos ? objet_diaporama.children("a.suivant").hide() : objet_diaporama.children("a.suivant").show();}function sliderFlechePrecedente(photo_courante,largeur_photo,objet_slider,objet_diaporama,total_photos,nb_par_set) {	if (photo_courante != 1) {		var distance = largeur_photo * -photo_courante;		distance = distance + (largeur_photo * 2);		photo_courante = photo_courante - 1;												objet_slider.animate({			left: distance		},500);				sliderPagination(photo_courante,objet_diaporama,total_photos,nb_par_set);				return photo_courante;	}}function sliderFlecheSuivante(photo_courante,largeur_photo,objet_slider,objet_diaporama,total_photos,nb_par_set) {	if (photo_courante + nb_par_set <= total_photos) {				var distance = largeur_photo * photo_courante;		photo_courante = photo_courante + 1;												objet_slider.animate({			left: -distance		},500);				sliderPagination(photo_courante,objet_diaporama,total_photos,nb_par_set);				return photo_courante;	}}function formatTitleFancyBox(title,currentArray,currentIndex,currentOpts) {							bas_vignette = "";	credit = "";	lien_detail = "";	if (photos_infos[currentIndex]['bas_vignette'] != "") {		bas_vignette = '<div id="bas_vignette">' + photos_infos[currentIndex]['bas_vignette'] + '</div>';	}		if (photos_infos[currentIndex]['credit'] != "") {		if (photos_infos[currentIndex]['bas_vignette'] != "") {			ajout_class = ' class="credit_avec_bas_vignette"';		}		else {			ajout_class = "";		}		credit = '<div id="credit"' + ajout_class + '>' + photos_infos[currentIndex]['credit'] + '</div>';	}		if (photos_infos[currentIndex]['lien_detail']) {		if (langue == "fr") {			terme = "Plus de détails";		}		else {			terme = "More details";		}		lien_detail = '<a href="' + photos_infos[currentIndex]['lien_detail'] + '" class="plus_fleche">' + terme + '</a>';	}		return lien_detail + bas_vignette + credit;}function loadMapVille(address,ville,path_images) {	address = address.replace("\'"," ");	ville = ville.replace("\'","'");		geocoder = new google.maps.Geocoder();	var latlng = new google.maps.LatLng(47.367081, -70.039902);	var myOptions = {		zoom: 5,		center: latlng,		navigationControl: false,		mapTypeControl: false,		scaleControl: false,		mapTypeId: google.maps.MapTypeId.ROADMAP    }	map = new google.maps.Map(document.getElementById("carte"),myOptions);	if (geocoder) {		geocoder.geocode({'address':address}, function(results, status) {			if (status == google.maps.GeocoderStatus.OK) {				map.setCenter(results[0].geometry.location);								var shadow = new google.maps.MarkerImage(					(path_images + 'ul/icones/markers/ombre_marker.png'),					new google.maps.Size(21, 15),					new google.maps.Point(0, 0),					new google.maps.Point(5, 13)				);								var marker = new google.maps.Marker({					map: map,					position: results[0].geometry.location,					icon: (path_images + 'ul/icones/markers/marker.png'),					shadow: shadow				});								google.maps.event.addListener(map, 'tilesloaded', function(){					$("#carte").children().children("div:eq(2)").hide();				});								google.maps.event.addDomListener(marker, 'click', function() {					$("a#lien_carte").attr("href",$("a#lien_carte").attr("href") + "position=" + marker.position + "&ville=" + ville).click();				});								google.maps.event.addDomListener(map, 'click', function() {					$("a#lien_carte").attr("href",$("a#lien_carte").attr("href") + "position=" + marker.position + "&ville=" + ville).click();				});			} else {				alert("Geocode was not successful for the following reason: " + status);			}		});	}}/* Vieilles fonction du microsite Moto */function StringGrandeur (width, height)   {   var string = 'width=' + width + ',height=' + height + ',left=' + ((screen.width - width) / 2) + ',top=' + ((screen.height - height) / 2) + ',screenX=' + ((screen.width - width) / 2) + ',screenY=' + ((screen.height - height) / 2);   return string;   }function OuvrirFenetre(page, largeur, hauteur, scrollBars)   {   if (typeof(scrollBars) == 'undefined')      scrollBars = true;   if (scrollBars)      WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(largeur,hauteur));   else      WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=no,status=yes,menubar=no,' + StringGrandeur(largeur,hauteur));   WindowFenetre.focus();   }