var global_chemin_url = "http://www.abbaye-vauclair.fr/";
var global_chemin_url_images = "http://www.abbaye-vauclair.fr/";



// ******************************** Pour la gestion des infos bulles ******************************** //
if ((navigator.appName == "Netscape")&&(navigator.appVersion.substring(0,4)>=4)) 
	{isNav="net";} 
if (navigator.appName == "Microsoft Internet Explorer")
	{isNav="ie";} 
function popLayer(a,b)
{ 
	var desc = "";
	couleur_fond = "";
	
	desc += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\""+couleur_fond+"\"><tr><td align=\"center\"><a id=\"texte\">";
	desc += a;
	desc += "</a></td></tr></table>"; 
	if (isNav=="net")
	{
		var NS6_tmp = (!document.all && document.getElementById) ? 1 : 0;
		if (NS6_tmp)
		{
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = handlerMM;
			document.getElementById('alt_txt').innerHTML = desc;
			var taille_layer = document.getElementById('alt').offsetWidth;
			document.getElementById('alt').style.top=y+20;
			document.getElementById('alt').style.left=x+25;
			if ((document.body.clientWidth+document.body.scrollLeft)<(document.getElementById('alt').offsetLeft+taille_layer))
			{
				document.getElementById('alt').style.left=document.body.clientWidth+document.body.scrollLeft-taille_layer;
			}
			document.getElementById('alt').style.visibility = "visible";
		}
		else
		{
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = handlerMM; 
			document.alt_txt.document.write(desc); 
			document.alt.document.close(); 
			document.alt.left=x-5; 
			document.alt.top=y-25;
			document.alt.visibility = "show";
		}
	}
	else if (isNav=="ie")
	{
		handlerMM();
		alt_txt.innerHTML=desc;
		var taille_layer = alt.offsetWidth;
		alt.style.pixelLeft=x-5;
		alt.style.pixelTop=y-20;
		if ((document.body.clientWidth+document.body.scrollLeft)<(alt.offsetLeft+taille_layer))
		{
			alt.style.pixelLeft=document.body.clientWidth+document.body.scrollLeft-taille_layer;
		}
		
		
		alt.style.visibility = "visible";
	}
}
function hideLayer(a)
{ 
	var NS6_tmp = (!document.all && document.getElementById) ? 1 : 0;
	if (isNav=="net")
	{
		if (NS6_tmp)
		{
			document.getElementById('alt').style.visibility = "hidden";document.getElementById('alt').style.left=0;document.getElementById('alt').style.top=0;
		}
		else
		{
			document.layers['alt'].visibility = "hide";document.alt.left=0;document.alt.top=0;
		}
	}
	if (isNav=="ie")
	{
		alt.style.visibility = "hidden";alt.style.pixelLeft=0;alt.style.pixelTop=0;
	}	
}
function handlerMM(e)
{
	if (isNav=="net") 
	{
		x = e.pageX+25;
		y = e.pageY+25;
	} 
	if (isNav=="ie")
	{
		x = event.x+document.documentElement.scrollLeft+25;
		y = event.y+document.documentElement.scrollTop+25;
	}
}
if (isNav=="net") 
{
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = handlerMM; 
}

// ****************************** Fin pour la gestion des infos bulles ****************************** //



	function dcd_m(val)
	{
		var l_val = val.length;
		var code = "";
		var result = "";
		
		for(i=0; i<l_val; i+=3)
		{
			code = val.substr(i, 3)-3;
			result += String.fromCharCode(code);
		}
		
		return result;
	}




// ******************************** Pour la gestion des flash ******************************** //


// Variables globales
// Version majeure de Flash requise
var requiredMajorVersion = 9;
// Version mineure de Flash requise
var requiredMinorVersion = 0;
// Rï¿½vision de Flash requise
var requiredRevision = 0;
// Version de javascript prise en charge
var jsVersion = 1.0;

var msg_deja_affiche = false;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function EvalJs(html){
	$(".script",html).each(function(ind,obj){
		eval($(this).text());
	});
}
				
function aff_bal(ch)
{
	document.write(ch);
}

function insert_flash(p_src,p_name,p_width,p_height,p_id,p_class,wmode,param) {
	
	if (!wmode) wmode = '';
	if (!param) param = {};
	
	var inject = false;
	var injectDiv = null;
	
	if (param['inject'] && param['injectDiv']) {
		var inject =  (param['inject']) ? param['inject'] : false;
		var injectDiv = (param['injectDiv']) ? param['injectDiv'] : null;
	}
	
	if (p_src.indexOf(".flv")>=0){
		var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(hasRightVersion) {  // if we've detected an acceptable version
			// embed the flash movie
	
			AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
				'width', p_width,
				'height', p_height,
				'src', 'PlayerVideo',
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'false',
				'loop', 'false',
				'scale', 'showall',
				'wmode', 'window',
				'devicefont', 'false',
				'id', 'PlayerVideo',
				'bgcolor', '#ffffff',
				'name', 'PlayerVideo',
				'menu', 'true',
				'allowScriptAccess','sameDomain',
				'allowFullScreen','true',
				'movie', 'PlayerVideo',
				'salign', '',
				'flashvars', 'nomflv='+p_src
				); //end AC code
		}	
		else{
			// flash is too old or we can't detect the plugin
			var alternateContent = 'Alternate HTML content should be placed here.'
				+ 'This content requires the Adobe Flash Player.'
				+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
			document.write(alternateContent);  // insert non-flash content
		}
	}
	else{
		var hasRightVersion = DetectFlashVer2(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(!hasRightVersion) {  // si nous avons dï¿½tectï¿½ une version acceptable
			if (!msg_deja_affiche)
			{
				msg_deja_affiche = true;
				
				var alternateContent = 'Pour visualiser correctement cette page vous avez besoin du Flash&nbsp;Player&nbsp;'+requiredMajorVersion+'.'
				+ '<br /><a href="http://www.macromedia.com/go/getflash/" class="text-normal-lien" target="_blank">Obtenir le lecteur Flash</a><br />';
				document.write(alternateContent);  // Insï¿½rer contenu non-Flash
			}
		}
		var flashvars = '';
		//document.write('<embed src="' + p_src + '" name="' + p_name + '" id="' + p_id + '" width="' + p_width + '" height="' + p_height + '" wmode="transparent" quality="high"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		if ($.browser.msie) {
			var class_ie = 'id="'+p_id+'" class="'+p_class+'"';
			
			var ch = '<object '+class_ie+' name="'+p_name+'" width="'+p_width+'" height="'+p_height+'" align="middle" type="application/x-shockwave-flash" data="'+p_src+'">'+
	   	 		 ' 		<param name="movie" value="'+p_src+'" />'+
				 '		<param name="quality" value="high" />'+
	         	 '		<param name="bgcolor" value="#ffffff" />'+
	         	 '		<param name="allowscriptaccess" value="sameDomain" />'+
	         	 '		<param name="allowfullscreen" value="true" />'+
	         	 '		<param name="wmode" value="'+wmode+'" />'+
	         	 '		<param name="flashvars" value="'+flashvars+'" />'+
	         	 '		<param name="autostart" value="true" />'+
	         	 '		<param name="loop" value="true" />'+
	         	 '		<param name="volume" value="0" />'+
	         	 '		<param name="controls" value="smallconsole" />'+
         		 '</object>'+
				 '';
		}
		else {
			var class_ie = 'class="'+p_class+'"';
			
			var ch = '<embed src="'+p_src+'" name="'+p_name+'" width="'+p_width+'" height="'+p_height+'" flashvars="'+flashvars+'" allowscriptaccess="sameDomain" allowfullscreen="true" wmode="'+wmode+'" autostart="true" loop="true" volume="0" controls="smallconsole" />';
		}
		if (!inject) {
			document.write(ch);
		}
		else {
			$(injectDiv).html(ch);
		}
	}	
}


// Programme d'assistance JavaScript requis pour dï¿½tecter les informations de version du plug-in Flash Player
function JSGetSwfVer2(i){
	// Version NS/Opera >= 3 rechercher le plug-in Flash dans le tableau des plug-ins
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 prend en charge Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 prend en charge Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// La version antï¿½rieure de WebTV prend Flash 2 en charge
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Dï¿½tection impossible dans tous les autres cas
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// Si elle est appelï¿½e sans paramï¿½tres,
// cette fonction renvoie une valeur en virgule flottante indiquant la version Flash Player ou 0.0 
// ex : Flash Player 7r14 renvoie 7.14
// Si appelï¿½ avec reqMajorVer, reqMinorVer, reqRevision renvoie true si cette version ou une version ultï¿½rieure est disponible
function DetectFlashVer2(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// Examiner les versions pour dï¿½tecter la plus rï¿½cente	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer2(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// est la rï¿½vision.principale >= rï¿½vision.principale demandï¿½e ET la version mineure >= mineure demandï¿½e
        	if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}



// ****************************** Fin pour la gestion des flash ****************************** //

jQuery(function(){
	
	if($.browser.msie==true && $.browser.version<7) {
		DD_belatedPNG.fix('.pngfix');
	}
	
	$('img.imgzoom').fancyzoom({Speed:400,showoverlay:false});
	
	if(typeof jQuery.fn.superfish == 'function') {
		jQuery('ul#main-menu').superfish();
	}
	
	if(typeof jQuery.fn.anythingSlider == 'function') {
		$('.anythingSlider').anythingSlider({
	        easing: "easeInOutExpo",
	        autoPlay: true,
	        delay: 5000,
	        startStopped: false,
	        animationTime: 600,
	        hashTags: true,
	        buildNavigation: true,
	        pauseOnHover: true,
	        startText: "",
	        stopText: "",
	        navigationFormatter: formatText
	    });
	
	    $("#slide-jump").click(function(){
	        $('.anythingSlider').anythingSlider(6);
	    });
	}
	
	
	if(typeof jQuery.fn.anythingSlider == 'function') {
		$('.anythingSliderZonePromo').anythingSlider({
	        easing: "easeInOutExpo",
	        autoPlay: true,
	        delay: 5000,
	        startStopped: false,
	        animationTime: 600,
	        hashTags: true,
	        buildNavigation: true,
	        pauseOnHover: true,
	        startText: "",
	        stopText: "",
	        navigationFormatter: formatText
	    });
	
	    $("#slide-jump").click(function(){
	        $('.anythingSlider').anythingSlider(6);
	    });
	}
	if(typeof jQuery.fn.accordion == 'function') {
		jQuery('#main-menu').accordion({
				autoheight: false,
	            collapsible: true,
				active: 'span.selected',
				alwaysOpen: false,
				header: 'span.head'
			});
			jQuery('.xtraMenu').accordion({
				autoheight: false,
	            collapsible: true,
				active: 'span.selected',
				alwaysOpen: false,
				header: 'span.sshead'
			});
	}
	
	if(typeof jQuery.fn.tooltip == 'function') {
		$('.zone_tooltip').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			showBody: " - ", 
			fade: 150,
			fixPNG: true
		});
	}
	
	$('.action_clic_map_fr').css('cursor', 'pointer').attr('title', 'Ouvrir la carte').click(function() {
		display_carte_aisne();
		
		$('#carte_aisne_home').mouseenter(function() {
			stop_tempo_carte_aisne();
		}).mouseleave(function() {
			hide_with_tempo_carte_aisne();
		});
	});
	
	$('.link_anim_abbaye_3d').click(function() {
		display_carto_3d();
		return false;
	});
	
	if ($('#diapos').length){
		$('#diapos').mouseenter(function(){
			stopDiapoInterval();
		}).mouseleave(function(){
			setTimeout('setDiapoInterval()', 5000);
		});
		setDiapoInterval();
	}
	
	if(typeof jQuery.fn.jcarousel == 'function') { 
		$('.carousel').addClass('jcarousel-skin-tango').jcarousel();
	}
	
	$('.action_click_diaporama').css('cursor', 'pointer').click(function(){
		var id = $(this).attr('id').replace(new RegExp('([^0-9]+)', 'gi'), '');
		if (id>0 && !isNaN(id)) {
			load_diaporama(id);
		}
	});
	
	// validate signup form on keyup and submit
	if (typeof jQuery.fn.validate == 'function') {
		$("#form_ressource").validate({
			rules: {
				titre: "required",
				nom: "required",
				prenom: "required",
				qui_dispose: "required",
				email: {required: true, email: true}
			},
			messages: {
				titre: "Merci de remplir un titre", 
				nom: "Merci de remplir votre nom", 
				prenom: "Merci de remplir votre prénom", 
				qui_dispose: "Merci de remplir ce champ",
				email: {
					required: "Merci de remplir votre mail",
					email: "Merci de saisir un mail correct (Ex: votrenom@domain.com)"
				}
			}
		});
	}
});

tempo_carte_aisne = -1;
function display_carte_aisne() {
	$('#carte_aisne_home').css('display', 'block');
	$('#carte_aisne_home_close').css('display', 'block').mouseover(function() {
		stop_tempo_carte_aisne();
		$(this).css('cursor', 'pointer');
	}).click(function(){
		hide_carte_aisne();
	});
}
function hide_carte_aisne() {
	$('#carte_aisne_home').css('display', 'none');
	$('#carte_aisne_home_close').css('display', 'none');
}
function stop_tempo_carte_aisne() {
	clearTimeout(tempo_carte_aisne);
}
function hide_with_tempo_carte_aisne() {
	tempo_carte_aisne = setTimeout(function() {
		hide_carte_aisne();
	}, 2500);
}


var interval_diapo, timer_interval_diapo = -1, diapo_nb = 3, diapo_index = 0, diapo_nb_pas = 1;
function setDiapoInterval() {
	interval_diapo = setInterval(function() {
		if (diapo_nb_pas > 0) {
			diapo_index++;
			if (diapo_index >= diapo_nb) {
				diapo_index = diapo_nb-2;
				diapo_nb_pas = -diapo_nb_pas;
			}
		}
		else {
			diapo_index--;
			if (diapo_index < 0) {
				diapo_index = 1;
				diapo_nb_pas = -diapo_nb_pas;
			}
		}
		if (diapo_nb_pas > 0) {
			var obj_selector = '#diapos_next';
		}
		else {
			var obj_selector = '#diapos_previous';
		}
		$(obj_selector).trigger('click');
	}, 5000);
}
function stopDiapoInterval() {
	if (interval_diapo) {
		clearInterval(interval_diapo);
	}
}

function formatText(index, panel) {
  return index + "";
}


// ****************************** Fin pour la gestion des flash ****************************** //



// ******************************* Pour la gestion des formulaires ****************************//

function show_modal() {
	$('#modal').css('height',getDocHeight()).css('opacity', '0.5').fadeIn(500);
}
function hide_modal() {
	$('#modal').fadeOut(500);
}

function valider_moteur_recherche(){
	var f = document.form_moteur_recherche;
	var mot_recherche = f.query.value;
	wysistat_tag_mot_cle_moteur(mot_recherche);
	return true;
}

function valider_moteur_recherche_2(){
	var f = document.form_moteur_recherche_2;
	var mot_recherche = f.query.value;
	wysistat_tag_mot_cle_moteur(mot_recherche);
	return true;
}

function wysistat_tag_mot_cle_moteur(mot_recherche) {
	if (valeur==1){stat('abbaye_vauclair','','','recherche;'+mot_recherche);}
}
// ***************************** Fin pour la gestion des formulaires **************************//


function redirection_flash(url) {
	if (url) {
    	window.open(url, '_blank', '');
    }
    else{
    	display_carto_3d();
    }
}

/**
 * Generic function to launch video on a popup
 * @param <string> path
 * @param <string> width
 * @param <string> height
 */
function lancer_video(path, width, height, title) {
	show_modal();
	if (!title) {
		title = 'Visite virtuelle de l\'abbaye en 3D';
	}
	var text = '';
	if (path.match(new RegExp('visite_virtuelle_de_l_abbaye|vauclair-xiie-siecle', 'gi'))) {
		text = '<a href="http://www.heritage-virtuel.com/" target="_blank">Réalisation Héritage Virtuel</a>';
	}
	if ($.browser.msie) {
		var ch_flash = '<object width="'+width+'" height="'+height+'" align="middle" data="'+path+'" type="application/x-shockwave-flash">'+
			 '		<param value="'+path+'" name="movie" />'+
			 '		<param value="high" name="quality" />'+
			 '		<param value="#ffffff" name="bgcolor" />'+
			 '		<param value="sameDomain" name="allowscriptaccess" />'+
			 '		<param value="true" name="allowfullscreen" />'+
			 '		<param value="true" name="play" />'+
			 '		<param value="true" name="autostart" />'+
			 //'		<param value="transparent" name="wmode" />'+
			 //'		<param value="'+flashvars+'" name="flashvars" />'+
			 '</object>';
	}
	else {
		var ch_flash = '<embed height="'+height+'" width="'+width+'" controls="smallconsole" loop="true" volume="0" autostart="true" play="true" '+
			 //'wmode="transparent" '+
			 //'allowfullscreen="true" allowscriptaccess="sameDomain" src="'+path+'" '+
			 'allowfullscreen="true" allowscriptaccess="sameDomain" src="'+path+'" />';
	}

	if ($.browser.msie==true && $.browser.version<7) {
		var img = '/download/abbaye-de-vauclair/image/charte/layer_visite/closebox.gif';
	}
	else {
		var img = '/download/abbaye-de-vauclair/image/charte/layer_visite/closebox.png';
	}

	if (!$('#suvoler_animation_accueil').length > 0) {
		$('body').append('<div id="suvoler_animation_accueil"></div>');
	}
	var width_tmp = parseInt(width)+40;
	var width_tmp2 = parseInt(width)+20;
	$('#suvoler_animation_accueil').html('<div class="header" style="width:'+width_tmp+'px"><img style="left:'+width_tmp2+'px" class="close pngfix" src="'+img+'" alt="Fermer" /></div>'+
	 '<div class="center" style="width:'+width_tmp+'px">'+
	 '	<h1>'+title+'</h1>'+
	 '	<div class="content">'+
	 ch_flash+
	 text+
	 '	</div>'+
	 '</div>'+
	 '<div class="footer" style="width:'+width_tmp+'px"></div>');
	
	var w = CalculWidthEcran();
	var pos_layer = (w-width) / 2;
	$('#suvoler_animation_accueil').css('left', pos_layer+'px');
	$('#suvoler_animation_accueil .close').click(function(){
		$('#suvoler_animation_accueil').remove();
		hide_modal();
	}).mouseover(function(){
		$(this).css('cursor','pointer');
	});
	$('#suvoler_animation_accueil').show();

	if (path.match(new RegExp('visite_virtuelle_de_l_abbaye', 'gi'))) {
		if (valeur==1){stat('abbaye_vauclair','','','video3D;visiteVirtuelleAbbaye');}
	}
	else if (path.match(new RegExp('vauclair-xiie-siecle', 'gi'))) {
		if (valeur==1){stat('abbaye_vauclair','','','video3D;vauclairXIIeSiecle');}
	}
	else {
		if (valeur==1){stat('abbaye_vauclair','','','video3D;Ouverture');}
	}
}

function CalculWidthEcran(){
	var width_ecran;
	
	if(self.innerWidth!=undefined){
		width_ecran = self.innerWidth;
		width_ecran = width_ecran-20;
	}
	else{
		if(document.documentElement) {
			width_ecran = document.documentElement.clientWidth;
		}
	}
	if (width_ecran>1254){
		width_ecran = 1254;
	}
	if (width_ecran<980){
		width_ecran = 980;
	}
	return width_ecran;
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function load_diaporama(id) {
	
	$.ajax({
		type: "GET",
		url: "/module/diaporama/data.php",
		dataType: "json",
		data: {'id' : id, 'site' : '1', 'langue' : '1'},
		contentType: 'application/json; charset=iso-8859-1', 
		success: function(json){
			display_diaporama(json);
		}
	});
}

global_preload_img = new Array();
function preload_image(callback, param, compt) {
	if (!compt) compt = 0;
	
	var len_img = global_preload_img.length;
	var img_ok = 0;
	for (var i = 0; i < len_img; i++) {
		img = global_preload_img[i];
		if (img.width > 0) {
			img_ok++;
		}
	}
	if (img_ok >= len_img) {
		callback(param);
	}
	else {
		if (compt<40) {
			setTimeout(function(){
				preload_image(callback, param, compt+1);
			}, 1000);
		}
	}
}



function display_diaporama(json) {
	
	if (typeof jQuery.fn.galleria == 'function') {
		show_modal();
		
		if($.browser.msie==true && $.browser.version<7) {
			var img_next = '/lib/js/galleria/next.gif';
			var img_previous = '/lib/js/galleria/previous.gif';
		}
		else {
			var img_next = '/lib/js/galleria/next.png';
			var img_previous = '/lib/js/galleria/previous.png';
		}
		
		if (!$('#diaporama_modal').length > 0) {
			
			var ch_galleria = '<div class="galleria_container">'+
								'<ul class="galleria">';
			
			var active_class = ' class="active"';
			for (var i in json) {
				
				var image = json[i]['image'];
				var titre = json[i]['titre'];
				var description = json[i]['description'];
				var legende = json[i]['legende'];
				
				var ch_titre = (titre.length) ? '<h1>'+titre+'</h1>' : '';
				var ch_description = (description.length) ? '<h2>'+description+'</h2>' : '';
				var ch_legende = (legende.length) ? '<h3>'+legende+'</h3>' : '';
				
				var ch_text = ch_titre + ch_description + ch_legende;
				ch_galleria+= '<li'+active_class+'><img src="'+image+'" alt="" title="' + ch_text + '" /></li>';
				
				active_class = '';
				
				var img = new Image();
				img.src = image;
				global_preload_img[global_preload_img.length] = img;
			}
			ch_galleria+= '</ul>'+
						  '<p class="diapo_nav">'+
								'<a href="#" class="previous" onclick="$.galleria.prev(); return false;"><img src="'+img_previous+'" alt="Pr&eacute;c&eacute;dent" /></a>'+
								'<a href="#" class="next" onclick="$.galleria.next(); return false;"><img src="'+img_next+'" alt="Suivant" /></a>'+
						  '&nbsp;</p>'+
		                  '</div>';		
			
			
			preload_image(display_diaporama_callback, {ch_galleria : ch_galleria});
			
			if (valeur==1){stat('abbaye_vauclair','','','diaporama;Ouverture');}
		}
	}
}

function display_diaporama_callback(param) {
	
	ch_galleria = param['ch_galleria'];
	
	var galleria_w = 835;
	var galleria_h = 650;
	
	if($.browser.msie==true && $.browser.version<7) {
		var img = '/download/abbaye-de-vauclair/image/charte/layer_visite/closebox.gif';
	}
	else {
		var img = '/download/abbaye-de-vauclair/image/charte/layer_visite/closebox.png';
	}
	
	$('body').append('<div id="diaporama_modal">'+
	     '	<div class="header"><img class="close pngfix" src="'+img+'" alt="Fermer" /></div>'+
	     '	<div class="center">'+
		 '		<div class="content">'+
		 ch_galleria+
		 '		</div>'+
		 '	</div>'+
	     '	<div class="footer"></div>'+
		 '</div>');	
	
	// anim diaporama
	$('.galleria').galleria({
		history   : true, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
			
			// fade in the image & caption
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
				image.css('display','none').fadeIn(1000);
			}
			caption.css('display','none').fadeIn(1000);
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// fade out inactive thumbnail
			_li.siblings().children('img.selected').fadeTo(500,0.3);
			
			// fade in active thumbnail
			thumb.fadeTo('fast',1).addClass('selected');
			
			// add a title for the clickable image
			image.attr('title','Next image >>');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// if thumbnail is active, fade all the way.
			var _fadeTo = _li.is('.active') ? '1' : '0.3';
			
			// fade in the thumbnail when finnished loading
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});
	
	var w = CalculWidthEcran();
	var pos_layer = (w-galleria_w) / 2;
	$('#diaporama_modal').css('left', pos_layer+'px');
	$('#diaporama_modal .close').click(function(){
		$('#diaporama_modal').remove();
		hide_modal();
	}).mouseover(function(){
		$(this).css('cursor','pointer');
	});
	$('#diaporama_modal').show();
}

$(window).load(function() {
	var timestamp = ((new Date()).getTime());
	p_src = "/download/abbaye-de-vauclair/multimedia/anim_accueil.swf?t="+timestamp;
	p_name = "";
	p_width = "994";
	p_height = "350";
	insert_flash(p_src,p_name,p_width,p_height, 'animation-accueil', 'animation-accueil', 'transparent', {'inject' : true, 'injectDiv' : '#accueil'});
	
	var timestamp = ((new Date()).getTime());
	p_src = "/download/abbaye-de-vauclair/multimedia/visite-virtuelle.swf?t="+timestamp;
	p_name = "";
	p_width = "230";
	p_height = "220";
	insert_flash(p_src,p_name,p_width,p_height, 'visite', 'visite', 'transparent', {'inject' : true, 'injectDiv' : '#visite'});
});

