/************************************/
/* GESTION DE LA TAILLE DES POLICES */
/************************************/

net_fontsize = Class.create();
net_fontsize.prototype = {
	initialize: function( options) {
		if( !options || !options.moins || !options.plus ) {
			return false;
		}
		this.taille_police = options.taille_police ? options.taille_police : 100;
		this.increment_police = options.increment_police ? options.increment_police : 10;
		this.min_police = options.min_police ? options.min_police : 0;
		this.max_police = options.max_police ? options.max_police : 500;
		this.debug_actif = options.debug ? options.debug : false;
		
		this.body_obj = document.body;
		this.set_taille_police();
		
		// variable créé pour accéder à l'objet dans les evenements click
		var net_fs = this;
		// Ajout des evenements click sur les boutons 
		$(options.plus).observe( "click", function() {
			net_fs.taille_police_plus();
		});
		$(options.moins).observe( "click", function() {
			net_fs.taille_police_moins();
		});
	}, 
	
	/*
	 * Nom : set_taille_police
	 * Description : Met à jour la taille de la police du BODY à la valeur de taille_police (variable global)
	 */
	set_taille_police: function() {
		$(this.body_obj).setStyle({
			fontSize: this.taille_police+"%"
		});
		this.net_debug();
	}, 
	
	/*
	 * Nom : taille_police_plus
	 * Description : Ajoute la valeur increment_police (variable global) à la valeur de taille_police (variable global) puis appel set_taille_police
	 */
	taille_police_plus: function() {
		this.taille_police += this.increment_police;
		if( this.taille_police > this.max_police ) {
			this.taille_police = this.max_police;
		}
		this.set_taille_police();
	}, 
	
	/*
	 * Nom : taille_police_moins
	 * Description : Soustrait la valeur increment_police (variable global) à la valeur de taille_police (variable global) puis appel set_taille_police
	 */
	taille_police_moins: function() {
		this.taille_police -= this.increment_police;
		if( this.taille_police < this.min_police ) {
			this.taille_police = this.min_police;
		}
		this.set_taille_police();
	}, 
	
	/*
	 * Nom : taille_police_moins
	 * Description : Soustrait la valeur increment_police (variable global) à la valeur de taille_police (variable global) puis appel set_taille_police
	 */
	net_debug: function() {
		if( this.debug_actif ) {
			var txt_debug = "";
			txt_debug += "taille_police : "+this.taille_police+"\n";
			txt_debug += "increment_police : "+this.increment_police+"\n";
			txt_debug += "min_police : "+this.min_police+"\n";
			txt_debug += "max_police : "+this.max_police;
			console.log( txt_debug);
		}
	}
}

