function imprimer(){
	window.print();
}

//######################################################################################################################
//## Changement de la taille du texte 
//######################################################################################################################
	function findBodyRule(Nom_Classe) {
		if (navigator.appName == 'Microsoft Internet Explorer'){
			for (var rule = 0; rule < document.styleSheets(0).rules.length; rule++){
				if (document.styleSheets(0).rules(rule).selectorText.toLowerCase() == Nom_Classe.toLowerCase()){
					return rule;
				}
			}    
			return null;
		}else{
			for (var rule = 0; rule < document.styleSheets[0].cssRules.length; rule++)    {
				if (document.styleSheets[0].cssRules[rule].selectorText == Nom_Classe){
					return rule;
				}
			}    
			return null;
		}
	}

	function lancement(type,valeur,Class){
		var NumClasse = findBodyRule(Class);
		if (navigator.appName != 'Microsoft Internet Explorer') {
			var oStyle = document.styleSheets[0].cssRules[NumClasse].style; //Mozilla
			oStyle.setProperty(type,valeur,'');// Mozilla
		}else{
			var miRegla = document.styleSheets[0].rules[NumClasse]; //IE
			if (type == "font-size"){
				miRegla.style.fontSize= valeur;
			}

		}
	}
//######################################################################################################################





function tailletexte(taille){
	if(taille=="1"){
		lancement('font-size',"0.8em",'body');
	}else{
		lancement('font-size',"0.6em",'body');
	}
	
	Ajax_GestionOrdre(taille)
	
}

function Ajax_GestionOrdre(taille){
	jQuery.ajax({   
		type: "POST",   
		url: "/changement_taille.php",   
		data: "taille="+taille  
  });
}
jQuery(document).ready(function(){
	yOffset = 30;//left
	xOffset = 20;

	jQuery("img[id*=photos]").hover(function(e){
		this.t = this.title;
		var chaine=this.id;
		var reg=new RegExp("(_)", "g");
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		jQuery("body").append("<p id='preview'><img src='"+ chaine.replace(reg,"/") +"' alt='Image preview' />"+ c +"</p>");								 
		var height=jQuery("#preview").height();//hauteur de l'élément à positionner
		var width=jQuery("#preview").width();//largeur de l'élément à positionner
		//myParent=jQuery("#preview").parent;
		
		
		  var pWidth = 0, pHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			pWidth = window.innerWidth;
			pHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			pWidth = document.documentElement.clientWidth;
			pHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			pWidth = document.body.clientWidth;
			pHeight = document.body.clientHeight;
		  }
		
		  var sTop = 0, sLeft = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			sTop = window.pageYOffset;
			sLeft = window.pageXOffset;
			//alert(sTop)
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			sTop = document.body.scrollTop;
			sLeft = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			sTop = document.documentElement.scrollTop;
			sLeft = document.documentElement.scrollLeft;
		  }
		
		var posY=(pHeight/2)-(height/2)+sTop//Calcul de la position en Y
		var posX=(pWidth/2)-(width/2)+sLeft //Calcul de la position en X
		var LargeurMaxDepassee = e.pageX+width
		var HauteurMaxDepassee = e.pageY+height
		
		if (LargeurMaxDepassee > jQuery("body").width()){
			jQuery("#preview").css("left",e.pageX-yOffset-width + "px");
		}else{
			jQuery("#preview").css("left",(e.pageX + yOffset) + "px");
		}	
		if (HauteurMaxDepassee > pHeight){
			jQuery("#preview").css("top",e.pageY-xOffset-height+ "px")
		}else{
			jQuery("#preview").css("top",e.pageY+xOffset+ "px")
		}	
		jQuery("#preview").fadeIn("fast");
    },
	function(){
		this.title = this.t;	
		jQuery("#preview").remove();
    });	
	jQuery("img[id*=photos]").mousemove(function(e){
		var height=jQuery("#preview").height();//hauteur de l'élément à positionner
		var width=jQuery("#preview").width();//largeur de l'élément à positionner
		myParent=jQuery("#preview").parent;
		  var pWidth = 0, pHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			pWidth = window.innerWidth;
			pHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			pWidth = document.documentElement.clientWidth;
			pHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			pWidth = document.body.clientWidth;
			pHeight = document.body.clientHeight;
		  }
		
		  var sTop = 0, sLeft = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			sTop = window.pageYOffset;
			sLeft = window.pageXOffset;
			//alert(sTop)
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			sTop = document.body.scrollTop;
			sLeft = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			sTop = document.documentElement.scrollTop;
			sLeft = document.documentElement.scrollLeft;
		  }
		var posY=(pHeight/2)-(height/2)+sTop//Calcul de la position en Y
		var posX=(pWidth/2)-(width/2)+sLeft //Calcul de la position en X
		var LargeurMaxDepassee = e.pageX+width
		var HauteurMaxDepassee = e.pageY+height-sTop
		
		if (LargeurMaxDepassee > jQuery("body").width()){
			jQuery("#preview").css("left",e.pageX-yOffset-width + "px");
		}else{
			jQuery("#preview").css("left",(e.pageX + yOffset) + "px");
		}	
		
		if (HauteurMaxDepassee > pHeight){
			jQuery("#preview").css("top",e.pageY-xOffset-height+ "px")
		}else{
			jQuery("#preview").css("top",e.pageY+xOffset+ "px")
		}	
		
		jQuery("#preview").fadeIn("fast");
	});			


})

	function new_freecap(){
		// loads new freeCap image
		if(document.getElementById)
		{
			// extract image name from image source (i.e. cut off ?randomness)
			thesrc = document.getElementById("freecap").src;
			thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
			// add ?(random) to prevent browser/isp caching
			document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
		} else {
			//alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
		}
	}




