
	
// Agrandit la fenetre du navigateur au max de l'ecran
function fenetre_max(){
	var fenetre = window.parent;
	fenetre.moveTo(0,0);
	if (document.all) {
	top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
	if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
	top.window.outerHeight = screen.availHeight;
	top.window.outerWidth = screen.availWidth;
	}
	}
}

// Nom du repertoire en fonction de la taille
var l_tailleImg = [50,100,150,200,250,295,300,400,500,600,678,700,720,800,900,1000,1024,1200,1500,1524,2000,2048,2500,3000,3072];
var nb_ltailleImg = l_tailleImg.length;

function recup_repmax(larg){
	if(typeof(larg)=="undefined"){
		if (document.body)
		{
			var larg = (document.body.clientWidth);
			var haut = (document.body.clientHeight);
		}
		else
		{
			var larg = (window.innerWidth);
			var haut = (window.innerHeight);
		}
	}else{
		
	}
	
	var largeur = larg;	
	//alert(largeur);
	for(var n=0;n<nb_ltailleImg;n++){
		if (largeur<=l_tailleImg[0]){rep=l_tailleImg[0];}
		else if (n<nb_ltailleImg-1 && largeur>l_tailleImg[n] && largeur<=l_tailleImg[n+1]){rep=l_tailleImg[n];}
		else if (largeur>l_tailleImg[nb_ltailleImg-2]){rep=l_tailleImg[nb_ltailleImg-1];}
	}
	if(largeur<rep)rep = largeur;
	return rep;
	//alert(rep);
}


// Fonction pour afficher une image dans pop up qui se redimensionne automatiquement
//liste_image, dossier, zoom_ratio
function gallerie(liste_images, dossier, zoom_ratio)   {
	//alert(liste_images);

	//fenetre_max();
	
	//largeur = recup_repmax();
	if(dossier=="undefined" || dossier=="null" ||dossier==undefined || dossier==null || dossier==""){dossier = "site";}
	if(zoom_ratio==undefined || zoom_ratio==null || zoom_ratio=="" || zoom_ratio=="undefined" || zoom_ratio=="null" || zoom_ratio=="auto"){zoom_ratio = 10/15;}
	else{zoom_ratio = parseFloat(zoom_ratio);}
	var largeur = recup_repmax();//1500
	var hauteur = Math.round(largeur*zoom_ratio);
	
	jQuery("#zoom_conteneur").width(largeur);	
	
	var fichier_swf = "";
	
	fichier_swf += '<div class="diaporama" ><script type="text/javascript">var flashvars = {};flashvars.nom_effet = "alpha00";flashvars.effet = "alpha";flashvars.swf_action = "false";flashvars.coin = "00";flashvars.contour = "";flashvars.largeur = "'+largeur+'";flashvars.hauteur = "'+hauteur+'";flashvars.affiche_vignette = "false";flashvars.rep_vignette = "../medias/photos/'+dossier+'/100/";flashvars.largeur_vignette = "100";flashvars.hauteur_vignette = "65";flashvars.reflet_vignette = "false";flashvars.affiche_boutons="true";flashvars.aff_alpha = "non";flashvars.rep = "../medias/photos/'+dossier+'/'+largeur+'/";flashvars.rep2 = "../medias/photos/'+dossier+'/'+largeur+'/";';
	
	var l_images = liste_images.split(",");
	l_images.shift();
	var nb_images = l_images.length;
	fichier_swf += 'flashvars.nb = "'+nb_images+'";';
	for(var i=0;i<=nb_images;i++){
		fichier_swf += 'flashvars.image'+i+'="'+l_images[i]+'";';
		}
		
	fichier_swf += 'var params = {};params.menu = "false";params.quality = "high";params.wmode = "transparent";params.scale = "exactfit";params.allowfullscreen = "true";var attributes = {};swfobject.embedSWF("../moteurajax/medias/diaporamas/vignettes_01.swf", "diaporama_gallerie", "'+largeur+'","'+hauteur+'", "9.0.0",  "moteurajax/affichage/librairie/swfobject/expressInstall.swf", flashvars, params, attributes);</'+'script><div id="diaporama_gallerie" class="diaporama_article"></div></div>';
	
	
	jQuery("#zoom_divimage").html(fichier_swf);
	
	jQuery("#zoom_conteneur").overlay({expose: '#fff', api:true, top: 0}).load();
	
	
	/*
	<img style="border: 1px solid black" src="../medias/photos/site/300/activite_araghju.jpg" width="150" alt="">
	*/
}

// Fonction pour afficher une image dans pop up qui se redimensionne automatiquement
//popImage('"+rep_img+"','"+rep_taille+"','"+nom_elmt+"');
//function popImage(chemin,largeur0){
function popImage(rep_img,rep_taille,nom_elmt){	

	if(typeof(g_zoom_action_enable)!="undefined"){
		if(g_zoom_action_enable==false)return;
	}
	
	if(rep_taille=="auto" || rep_taille==""){
		rep_taille = recup_repmax();
	}else if(rep_taille.substr(0,1)=="x"){
		rep_taille = rep_taille.substr(1);
		var document_height = document.documentElement.clientHeight;
		rep_taille = document_height/(parseFloat(rep_taille));
		rep_taille = recup_repmax(rep_taille);
		
	}
	
	//alert('pop up:'+rep_img+','+rep_taille+','+nom_elmt);

	largeur = parseInt(rep_taille);
	//chemin = "../../../medias/photos/"+rep_img+"/"+rep_taille+"/"+nom_elmt;
	chemin = "/"+rep_img+"/"+rep_taille+"/"+nom_elmt;
	
	jQuery("#zoom_conteneur").width(largeur);
	
	jQuery("#zoom_conteneur").overlay({expose: '#fff', api:true, top: 0}).load();
	
	var charg = new Image();

	  // wrap our new image in jQuery, then:
	  jQuery(charg)
		// once the image has loaded, execute this code
		.load(function () {
		  // set the image hidden by default    
		  jQuery(this).hide();
		
		  // with the holding div #loader, apply:
		  
		  jQuery('#zoom_divimage')
			// remove the loading class (so no background spinner), 
			//.removeClass('loading')
			// then insert our image
			.html(this);
		
		  // fade our image in to create a nice effect
		  jQuery(this).fadeIn();
		})
		
		// if there was an error loading the image, react accordingly
		.error(function () {
		  // notify the user that the image could not be loaded
		})
		.attr('id', 'img_charge')
		// *finally*, set the src attribute of the new image to our image
		.attr('src', '../moteurajax/medias/images/animes/loader/gris.gif');

	
	
	
	
	var img = new Image();
	  // wrap our new image in jQuery, then:
	  jQuery(img)
		// once the image has loaded, execute this code
		.load(function () {
		  // set the image hidden by default    
		  jQuery(this).hide();
		  // with the holding div #loader, apply:
		  //alert(document.documentElement.clientHeight);
		
		/*jQuery("#zoom_divimage").height(document.documentElement.clientHeight-50);
		jQuery("#zoom_divimage").css({'overflow':'auto',
			'text-align':'center','padding-top':'10px'});
		*/
		
		jQuery('#zoom_divimage')
			// remove the loading class (so no background spinner), 
			//.removeClass('loading')
			// then insert our image
			.html(this);
			
		  // fade our image in to create a nice effect
		  jQuery(this).height(jQuery("#zoom_divimage").height()-20);
		  jQuery(this).css({'margin-left':'auto','margin-right':'auto'});
		  jQuery(this).fadeIn();
		})
		
		// if there was an error loading the image, react accordingly
		.error(function () {
		  // notify the user that the image could not be loaded
		})
		
		// *finally*, set the src attribute of the new image to our image
		.attr('src', chemin);
		

	
	
	//jQuery("#zoom_divimage").html('<img id="zoom_image" src="'+ chemin +'" width="'+ largeur +'" border="0" alt="image" />');
	
	//jQuery("#zoom_conteneur").overlay({effect: 'drop', expose: '#fff', api:true}).load();
	
	
	/*
	jQuery("#success").load("/not-here.php", function(response, status, xhr) {
	  if (status == "error") {
		var msg = "Sorry but there was an error: ";
		jQuery("#error").html(msg + xhr.status + " " + xhr.statusText);
	  }
	});
	*/
}


// Fonction pour pointer une url
function newpage(url){	
	var hash = url;
	hash = hash.replace(/^.*#/, '');	
	jQuery.historyLoad(hash);
}


// Fonction pour pointer une url
function vr_360(fichier,largeur,hauteur){		
	//fenetre(../moteurajax/modules/pages/360/360.asp?nom=folaca.swf,600,280);
	//getURL("javascript: newWindow = window.open('"+Tab_parametres[0]+"','fenetre','width="+Tab_parametres[1]+",height="+Tab_parametres[2]+",scrollbars=no,top=100,left=100,status=no,menubar=no,toolbar=no,location=no,url=no'); newWindow.focus();");
	//alert(fichier+"-"+largeur+"-"+hauteur);
	if(largeur=="undefined" || largeur==null){largeur=600;}
	if(hauteur=="undefined" || hauteur==null){hauteur=280;}
	var chem_fichier = "../moteurajax/modules/pages/360/360.asp?nom="+fichier;
	//alert(fichier+"-"+largeur+"-"+hauteur+"\n"+chem_fichier+"\n"+param_fichier);
	
	window.open(chem_fichier,'vr_360','width='+largeur+',height='+hauteur+',scrollbars=no,top=100,left=100,status=no,menubar=no,toolbar=no,location=no,url=no'); 	
}


/*================= EFFET POUR ZOOM IMAGE ============================*/

// create custom animation algorithm for jQuery called "drop"  
jQuery.easing.drop = function (x, t, b, c, d) { 
    return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 
}; 
 
 
// create custom overlay effect for jQuery Overlay 
jQuery.tools.overlay.addEffect("drop",   
     
    // loading animation 
    function(done) {  
        var animateProps = { 
            top: '+=55',  
            opacity: 1,  
            width: '+=0' 
        }; 
        this.getOverlay().animate(animateProps, "medium", 'drop', done).show(); 
    },  
     
    // closing animation 
    function(done) { 
        var animateProps = { 
            top: '-=55',  
            opacity: 0,  
            width: '-=0' 
        }; 
        this.getOverlay().animate(animateProps, "fast", 'drop', function()  { 
            jQuery(this).hide(); 
            done.call();         
        }); 
    } 
);

