/** * Site Internet Sidan. *  * @author Ludovic PECATE. */$(document).ready(function(){	//var relativeUrl = $('script:first').attr('src').substring(0, $('script:first').attr('src').indexOf('js/'));	//var baseUrl = location.href.substring(0, location.href.indexOf('/', 7))+relativeUrl;		$('a.pop_up_image').fancybox({		'titleShow'		: true,		'transitionIn'	: 'elastic',		'transitionOut'	: 'elastic'	});		// Accordéon sur newsletter	$('.newsletter-title').addClass('closed-item').css('cursor', 'pointer').toggle(		function(){			$('.zend_form_newsletter').show(500);			$(this).addClass('opened-item').removeClass('closed-item');		}, function(){			$('.zend_form_newsletter').hide(500);			$(this).addClass('closed-item').removeClass('opened-item');		}).next().find('.zend_form_newsletter').hide();		// Prise en charge de la barre d'outils JS de traduction Google	setInterval(function(){		if ($('.goog-te-banner-frame').size() > 0) {			// Déplace le fond du body en fonction de la hauteur de la barre			$('body').css({backgroundPosition: '0px '+$('.goog-te-banner-frame').outerHeight()+'px'});		}	}, 500);		// Sauvegarde d'une annonce	$.favoriteIt({		applyTo: $('.save-ads'),		cookieName: 'saved-ads',		parentContainerSelector: '#menu-bis',		url: baseUrl+'json/?format=json',		favoriteMenuLabel: 'Mes annonces',		savedLabel: 'Annonce sauvegardée',		saveLabel: 'Sauvegarder l\'annonce',		savedClass: 'heart-delete-icon',		saveClass: 'heart-icon',		deleteItemClass: 'cross-icon',		cache: true	});	$('body').css({position: 'relative'}).append('<div class="ads-tooltip"><div class="ads-tooltip-top"></div><div class="ads-tooltip-text">Les annonces sont sauvegardées dans vos cookies. Par conséquent si vous supprimez vos cookies, vous perdrez toutes les annonces que vous aurez sauvegardé.</div><div class="ads-tooltip-bottom"></div></div>')		.find('.ads-tooltip').hide();	// Message infobulle sauvegarde annonce	$('.save-ads').hover(function(){		var $a = $('.ads-tooltip');				$a.stop().css({			position: 'absolute',			top: parseInt($(this).position().top + ($(this).outerHeight() * 0.75)),			left: parseInt($(this).position().left + ($(this).outerWidth() / 2) - ($a.outerWidth() / 2)),			zIndex: 1000		});				if ($.support.opacity) {			$a.css({				opacity: 1			}).fadeIn('fast');		} else {			$a.show();		}	}, function(){		var $a = $('.ads-tooltip');				if ($.support.opacity) {			$a.stop().animate({opacity: 0}, 1000, function(){$(this).hide();});		} else {			$a.hide();		}	});		// Diaporamas de photos : annonces	$('.mini-galerie img').hover(function(){		$(this).removeClass('mini-blur').addClass('mini-hover');	}, function(){		$(this).removeClass('mini-hover').addClass('mini-blur');	});	$('.mini-galerie img').css('cursor', 'pointer').attr('title', 'Cliquez pour agrandir').click(function() {		var imgSrc = $(this).attr('src')+'&w=320';		var imgPath = $(this).attr('src').replace('getMiniImage.php?src=', '');				// Ajoute un masque sur l'image à modifier		var gallery = $(this).parent().parent();		var img = gallery.find('img:first');		$('body').find('.element-mask').remove();		$('body').prepend('<div class="element-mask loading"></div>')			.find('.element-mask')			.css({				position: 'absolute',				width: img.outerWidth()+'px',				height: img.outerHeight()+'px',				top: img.position().top,				left: img.position().left,				opacity: 0.75			});		// Préchargement de l'image		$('body').prepend('<img class="element-image-loading" src="'+imgSrc+'" />')			.find('img.element-image-loading')			.hide()			.load(function(){				img.attr('src', $(this).attr('src'));				$(this).remove();				$('body').find('.element-mask')					.css({						width: img.outerWidth()+'px',						height: img.outerHeight()+'px'					})					.animate({opacity: 0}, 'slow', 'linear', function () {						$(this).remove();					});			});				gallery.find('a:first').attr('href', imgPath);	});		// ---- ANIMATIONS BANNIERE ----	var photosGalerie = [];	var dirPhoto = 1;	if ($('#header-photo .test-galerie').size()>0){		$('body').prepend($('#header-photo .test-galerie')).find('.test-galerie:first')			.css({				position: 'absolute',				top: '201px',				background: 'red',				color: '#fff',				fontWeight: 'bold',				padding: '8px',				zIndex: '20000'			});		window.onerror = function(msg, url, line){			if (msg.indexOf('CrossSlide:') != -1) {				var posMsg = msg.indexOf('impossible animation:');				if (posMsg != -1) {					msg = msg.substring(posMsg+21);					var regExp = new RegExp("either picture ([0-9]+) .*");					var results;					if (results = regExp.exec(msg)) {						$('.test-galerie:first').append('<p>Galerie : L\'image n°'+results[1]+' de la galerie est trop petite</p>');					}				}			}		};	}	$('#header-photo img').each(function(){		photosGalerie.push({			src:$(this).attr('src'),			dir: (dirPhoto>0?'left':'right')		});		dirPhoto = -dirPhoto;	});	$('#header-photo').html('').crossSlide({			//sleep: 5, // Durée d'affichage de chaque image			speed: 20,			fade: 1 // Durée du fondu		}, photosGalerie	);	// --- TEXTE ---	// Génère le texte de l'entête	$('#header-texte span').each(function(){		texte.push($(this).text());	});	$('#header-texte').html('');	animeText();		// Désctivation du clic droit	$('img').bind('contextmenu', function(e){		alert('Les images sont soumises à la propriété intellectuelle.');		// Désactive le menu par défaut		return false;	});});var texte = [];var textIdx = 0;function animeText() {	if (texte.length > 0) {		var $ht = $('#header-texte');		$ht.append('<span>'+texte[textIdx]+'</span>');		var $htsp = $ht.find('span:last');				var posStartX = parseInt(Math.random()*$ht.width()/2);		var posStartY = parseInt(Math.random()*$ht.height()/2);				var posEndX = parseInt(Math.random()*$ht.width()/2);		var posEndY = parseInt(Math.random()*$ht.height()/2);		//		$htsp.show().css({opacity: '0', fontSize: '24px', left: posStartX+'px', top: posStartY+'px'})//			.animate({opacity: '1', /*fontSize: '36px',*/ left: posEndX+'px', top: posEndY+'px'}, //					5000, 'swing')//			.animate({opacity: '0'}, 2500, function(){$htsp.remove();});		$htsp.hide().css({fontSize: '24px', left: posStartX+'px', top: posStartY+'px'})			.fadeIn(3500);		setTimeout(function(){$htsp.fadeOut(2500);}, 3500);		setTimeout(function(){$htsp.remove();}, 7500);				textIdx++;		if (textIdx >= texte.length) textIdx = 0;		setTimeout(function(){animeText();}, 3500/*3500+Math.random()*1500*/);	}}
