/**
 *
 * @author	Benoit Asselin <benoit(at)agenceici(dot)com>
 * @version	javascript.js, 2010/05/31
 * @link	http://www.agenceici.com/
 *
 */


var windowOnload = '';
window.onload = function(){eval(windowOnload);};



/**
 * Convertir la transparence des images PNG sous Internet Explorer 6.0 et -
 * Ex: window.onload = function() { fixiePNG(); };
 * @param {String} p_path Chemin du fichier NONE.GIF (default: 'images/')
 */
function fixiePNG(p_path) {
	var msie = navigator.userAgent.match(/msie\s([\d\.]+)/i);
	if(msie && msie[1] <= '6.0') {
		p_path = p_path === undefined ? 'images/' : p_path;
		var png = /\.png$/i;
		var imgs = document.getElementsByTagName('img');
		for(var i = 0, l = imgs.length; i < l; i++) {
			if(png.test(imgs.item(i).src)) {
				imgs.item(i).style.width = imgs.item(i).offsetWidth;
				imgs.item(i).style.height = imgs.item(i).offsetHeight;
				imgs.item(i).style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + imgs.item(i).src + '\',sizingMethod=\'image\')';
				imgs.item(i).src = p_path + 'none.gif';
			}
		}
	}
}



/**
 * Mangeur de SPAM
 * @param {String} mt1 XXX_at_xxx_dot_xxx
 * @param {String} mt2 xxx_at_XXX_dot_xxx
 * @param {String} mt3 xxx_at_xxx_dot_XXX
 * @param {String} subject Objet du message
 * @return {Boolean} Toujours false
 */
function noSpam(mt1, mt2, mt3, subject) {
	var link = 'mailto:' + mt1 + '@' + mt2 + '.' + mt3;
	if(subject !== undefined) {link += '?subject=' + encodeURIComponent(subject);}
	window.location.href = link;
	return false;
}



/**
 * Ouvrir un popup
 * @param {String} p_href Lien a ouvrir
 * @return {Boolean} Toujours false
 */
function popup(p_href) {
	var v_w = 800;
	var v_h = 600;
	var v_l = (window.screen.width - v_w) / 2;
	var v_t = (window.screen.height - v_h) / 3;
	window.open(p_href, 'popup', 'scrollbars=yes,status=no,toolbar=no,width='+v_w +',height='+v_h +',left='+v_l +',top='+v_t ).focus();
	return false;
}



/**
 * Classe permettant de determiner la position reelle de l'element
 * @param {Node} p_elt Element a determiner
 * @param {Node} p_ref Element ou stopper la recheche
 * @constructor
 */
function ClassOffset(p_elt, p_ref) {
	/** @return {Number} Position Gauche @default 0 */
	this.left = 0;
	/** @return {Number} Position Haut @default 0 */
	this.top = 0;
	/** @return {Number} Largeur @default 0 */
	this.width = 0;
	/** @return {Number} Hauteur @default 0 */
	this.height = 0;

	/** @return {Node} Node de reference qui stop le comptage // doit etre un element offsetParent! @private */
	this.reference = (p_ref === undefined ? Doc.body() : p_ref);
	/** @return {Node} Node a retrouver dans this.reference @private */
	this.element = p_elt;

	this.getOffset();
}
/** Determiner les Offset @private */
ClassOffset.prototype.getOffset = function() {
	var v_node = this.element;
	while(v_node != null && v_node != this.reference) {
		this.left += v_node.offsetLeft;
		this.top += v_node.offsetTop;
		v_node = v_node.offsetParent;
	}
	this.width = this.element.offsetWidth;
	this.height = this.element.offsetHeight;
};



/**
 * Classe permettant de deplacer un element en left et en top (Inspirer de mootools)
 * @param {Object} p_params
 *	{
 *		element: HTMLElement OR 'id',	Element ou IDenfifiant HTML
 *		property: String,		Propriete CSS a manipuler			Liste: 'width', 'height', 'left', 'top'..., 'margin'..., 'borderWidth'..., 'padding'..., 'fontSize', 'letterSpacing', 'lineHeight', 'opacity'...
 *		start: Number,			Point de depart ( default detection )
 *		end: Number,			Point d'arrivee
 *		inc: Number,			Incrementation
 *		mini: Number,			Valeur minimum ( facultatif )
 *		maxi: Number,			Valeur maximum ( facultatif )
 *		transition: String,		Type d'animation ( default 'normal' )		Liste: 'linear', 'normal', 'pow', 'expo', 'circ', 'sine', 'back', 'bounce', 'elastic'
 *		ease: String,			Effet au debut et/ou a la fin ( default 'out')	Liste: 'in', 'out', 'inout'
 *		duration: Number,		Duree de l'animation en ms ( default 1000 )
 *		fps: Number,			Image par seconde ( default 50 )
 *		listen: Function,		Fonction qui ecoute le changement de valeur ( default false )
 *		callback: Function,		Fonction de retour en fin d'animation ( default false )
 *		wait: Boolean			Attendre avant de demarrer ( default false )
 *	}
 * @constructor
 */
function ClassCoreFX(p_params) {
	/** @returns {Object} Les parametres de l'utilisateur */
	this.params = p_params;

	/** @return {HTMLElement} Element a manipuler */
	this.elt = typeof this.params.element == 'object' ? this.params.element : Doc.id(this.params.element);

	/** @return {String} Propriete CSS */
	this.styleProperty = this.params.property;
	/** @return {Number} Valeur de depart */
	this.valueStart = this.params.start === undefined ? false : this.params.start;
	/** @return {Number} Valeur d'arrive */
	this.valueEnd = this.params.end === undefined ? false : this.params.end;
	/** @return {Number} Valeur a incrementer */
	this.valueInc = this.params.inc === undefined ? 0 : this.params.inc;
	/** @return {Number} Valeur minimum */
	this.valueMini = this.params.mini === undefined ? false : this.params.mini;
	/** @return {Number} Valeur maximum */
	this.valueMaxi = this.params.maxi === undefined ? false : this.params.maxi;

	/** @return {String} Type de transition */
	this.fxTransition = this.params.transition === undefined ? 'normal' : this.params.transition;
	/** @return {String} Effet au debut et/ou a la fin */
	this.fxEase = this.params.ease === undefined ? 'out' : this.params.ease;
	/** @return {Number} Duree de l'effet */
	this.duration = this.params.duration === undefined ? 1000 : parseInt(this.params.duration);
	/** @return {Number} Image par seconde */
	this.fps = this.params.fps === undefined ? 50 : parseInt(this.params.fps);
	/** @retrun {Function} Fonction qui ecoute le changement de valeur */
	this.listen = (this.params.listen === undefined || this.params.listen === false) ? function(){} : this.params.listen;
	/** @return {Function} Fonction de retour */
	this.callback = (this.params.callback === undefined || this.params.callback === false) ? function(){} : this.params.callback;


	/** @return {Number} Temps de pause pour setTimeout */
	this.delay = Math.round(1000 / this.fps);
	/** @return {Number} Variable pour setTimeout */
	this.timeout = false;
	/** @return {String} Type de valeur du style	Liste: 'px', 'opacity', '' */
	this.styleType = 'px';
	/** @return {Number} Maintenant */
	this.time = 0;

	this._fixDbFX();
	this._detectStyleType();
	this._detectValueStart();
	if(!this.params.wait) {
		this.start();
	}
}
ClassCoreFX.prototype = {
	/**
	 * Date actuelle
	 * @return {Number}
	 */
	_dateNow : function() {
		return Date.now ? Date.now() : +new Date;
	},
	/**
	 * Bloquer la superposition de 2 effets identifiques
	 */
	_fixDbFX : function() {
		if(!this.elt._CoreFX) {this.elt._CoreFX = [];}
		if(!this.elt._CoreFX[this.styleProperty]) {
			this.elt._CoreFX[this.styleProperty] = this;
		} else {
			window.clearTimeout(this.elt._CoreFX[this.styleProperty].timeout);
			this.elt._CoreFX[this.styleProperty] = this;
		}
	},
	/**
	 * Detecter le type de valeur du style
	 */
	_detectStyleType : function() {
		switch(this.styleProperty) {
			case 'width' : case 'height' :
			case 'left' : case 'right' : case 'top' : case 'bottom':
			case 'margin' : case 'marginLeft' : case 'marginRight' : case 'marginTop' : case 'marginBottom' :
			case 'borderWidth' : case 'borderLeftWidth' : case 'borderRightWidth' : case 'borderTopWidth' : case 'borderBottomWidth' :
			case 'padding' : case 'paddingLeft' : case 'paddingRight' : case 'paddingTop' : case 'paddingBottom' :
			case 'fontSize' : case 'letterSpacing' : case 'lineHeight' :
				this.styleType = 'px';
				break;
			case 'opacity' :
				this.styleType = 'opacity';
				break;
			default :
			case 'zIndex' :
				this.styleType = '';
				break;
		}
	},
	/**
	 * Detecter la valeur du style
	 */
	_detectValueStart : function() {
		if(this.valueStart === false) {
			switch(this.styleProperty) {
				case 'opacity' :
					if(this.elt.style[this.styleProperty]) {
						this.valueStart = parseInt(this.elt.style[this.styleProperty] * 100);
					}
					break;
				default :
					if(this.elt.style[this.styleProperty]) {
						this.valueStart = parseInt(this.elt.style[this.styleProperty]);
					}
					break;
			}
			if(this.valueStart === false) {
				switch(this.styleProperty) {
					case 'width' :this.valueStart = this.elt.offsetWidth;break;
					case 'height' :this.valueStart = this.elt.offsetHeight;break;
					case 'left' :this.valueStart = this.elt.offsetLeft;break;
					case 'top' :this.valueStart = this.elt.offsetTop;break;
					default :this.valueStart = 0;break;
				}
			}
		}
	},
	/**
	 * Type de calcul pour les transitions
	 * @param {Number} p
	 * @param {Number} x ?
	 * @return {Number}
	 */
	_transition : function(p, x) {
		switch(this.fxTransition) {
			case 'linear' :
				return p;
				break;
			default :
			case 'normal' :
				return -(Math.cos(Math.PI * p) - 1) / 2;
				break;
			case 'pow' :
//				return Math.pow(p, x[0] || 6);
				return Math.pow(p, 6);
				break;
			case 'expo' :
				return Math.pow(2, 8 * (p - 1));
				break;
			case 'circ' :
				return 1 - Math.sin(Math.acos(p));
				break;
			case 'sine' :
				return 1 - Math.sin((1 - p) * Math.PI / 2);
				break;
			case 'back' :
//				x = x[0] || 1.618;
				x = 1.618;
				return Math.pow(p, 2) * ((x + 1) * p - x);
				break;
			case 'bounce' :
				var value;
				for(var a = 0, b = 1; 1; a += b, b /= 2) {
					if(p >= (7 - 4 * a) / 11) {
						value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
						break;
					}
				}
				return value;
				break;
			case 'elastic' :
//				return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
				return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (1) / 3);
				break;
		}
	},
	/**
	 * Effet au debut et/ou a la fin
	 * @param {Number} p
	 * @param {Number} x ?
	 * @return {Number}
	 */
	_ease : function(p, x) {
		switch(this.fxEase) {
			case 'in' :
				return this._transition(p, x);
				break;
			default :
			case 'out':
				return 1 - this._transition(1 - p, x);
				break;
			case 'inout' :
				return (p <= 0.5) ? this._transition(2 * p, x) / 2 : (2 - this._transition(2 * (1 - p), x)) / 2;
				break;
		}
	},
	/**
	 * Calcul de la value
	 * @param {Number} p_from Debut
	 * @param {Number} p_to Fin
	 * @param {Number} p_delta Delta
	 * @return {Number}
	 */
	_compute : function(p_from, p_to, p_delta) {
		return (p_to - p_from) * p_delta + p_from;
	},
	/**
	 * Etape par etape ( boucle )
	 */
	_step : function() {
		var v_now = this._dateNow();
		if(v_now < this.time + this.duration) {
			var v_delta = (v_now - this.time) / this.duration;
			this.set(this._compute(this.valueStart, this.valueEnd, this._ease(v_delta)));

			this.timeout = window.setTimeout(this._step._bind(this), this.delay);

		} else {
			window.clearTimeout(this.timeout);
			this.timeout = false;
			this.set(this._compute(this.valueStart, this.valueEnd, 1));
			this.callback(this);
		}
	},
	/**
	 * Controler les limites ( mini et/ou maxi )
	 * @param {Number} p_value Valeur a controler
	 * @return {Number} Valeur controlee
	 */
	_limit : function(p_value) {
		if(this.valueMini !== false && p_value < this.valueMini) {p_value = this.valueMini;}
		if(this.valueMaxi !== false && p_value > this.valueMaxi) {p_value = this.valueMaxi;}
		return p_value;
	},
	/**
	 * Enregistrement de la valeur en CSS
	 * @param {Number} p_value
	 */
	set : function(p_value) {
		p_value = this._limit(p_value);
		this.listen(p_value, this);

		if(this.styleType == 'px') {
			this.elt.style[this.styleProperty] = p_value + 'px';
		} else if(this.styleType == 'opacity') {
			this.elt.style.opacity = (p_value / 100); // css3
			this.elt.style.mozOpacity = (p_value / 100); // moz
			this.elt.style.khtmlOpacity = (p_value / 100); // khtml
			this.elt.style.filter = 'alpha(opacity=' + p_value + ')'; // msie
		} else {
			this.elt.style[this.styleProperty] = p_value;
		}
	},
	/**
	 * Demarrage ou reprise
	 */
	start : function() {
		this.time = this._dateNow() - this.time;
		if(this.valueInc != 0) {
			if(this.valueEnd === false) {
				this.valueEnd = this.valueStart;
			}
			this.valueEnd += this.valueInc;
		}
		this._step();
	},
	/**
	 * Arret ou pause
	 */
	stop : function() {
		if(!this.timeout) {return;}
		this.time = this._dateNow() - this.time;
		window.clearTimeout(this.timeout);
		this.timeout = false;
	},
	/**
	 * Deplacer a X
	 * @param {Number} p_value
	 */
	move : function(p_value) {
		this.time = 0; // raz
		this.valueStart = false;
		this._detectValueStart();
		this.valueEnd = p_value;
		this.valueInc = 0;

		this.start();
	},
	/**
	 * Deplacer de X
	 * @param {Number} p_value
	 */
	translate : function(p_value) {
		this.time = 0; // raz
		this.valueStart = false;
		this._detectValueStart();
		this.valueInc = p_value;

		this.start();
	},
	/**
	 * Retourner la valeur
	 * @return {Number}
	 */
	get : function() {
		return this.valueEnd;
	}
};



/**
 * Classe permettant d'executer des fondus sur un lot d'images
 * @param {HTMLElement} p_elt Element a manipuler ( ou IDentifiant String )
 * @constructor
 */
function ClassCoreFXs01(p_elt) {
	/** @return {HTMLElement} Element a manipuler */
	this.elt = typeof p_elt == 'object' ? p_elt : Doc.id(p_elt);
	/** @return {HTMLElement} Les images */
	this.images = this.elt.getElementsByTagName('img');

	/** @return {Number} Image actuelle */
	this.imageActive = 0;
	/** @return {Number} Image suivante */
	this.imageNext = 0;

	this.init();
	this.start();
}
ClassCoreFXs01.prototype = {
	/**
	 * Initialisation de l'effet
	 */
	init : function() {
		var v_z = this.images.length;
		for(var v_i = 0, v_l = this.images.length; v_i < v_l; v_i++) {
			this.images.item(v_i).style.position = 'absolute';
			this.images.item(v_i).style.zIndex = v_z;
			this.images.item(v_i).coreFX = {};
			v_z--;
		}
	},
	/**
	 * Demarrage de l'effet
	 */
	start : function() {
		this.images.item(this.imageActive).coreFX.left = new ClassCoreFX({
			element: this.images.item(this.imageActive),
			property: 'left',
			start: 0,
			end: -this.images.item(this.imageActive).offsetWidth,
			transition: 'linear',
			duration: '20000',
			fps: 50,
			listen: this.fxListenLeft._bind(this)
			});
	},
	/**
	 * Ecouteur de changeur de valeur
	 * @param {String} p_value Valeur
	 * @param {ClassCoreFX} p_this Reference de this
	 */
	fxListenLeft : function(p_value, p_this) {
		if(p_value < -(this.images.item(this.imageActive).offsetWidth - (this.elt.offsetWidth * 1.5)) && !this.images.item(this.imageActive).coreFX.opacity) {
			this.images.item(this.imageActive).coreFX.opacity = new ClassCoreFX({
				element: this.images.item(this.imageActive),
				property: 'opacity',
				start: 100,
				end: 0,
				transition: 'linear',
				duration: '2000',
				fps: 50,
				callback: this.next._bind(this)
				});

			this.imageNext = (this.imageActive + 1 >= this.images.length) ? (0) : (this.imageActive + 1);
			this.images.item(this.imageNext).coreFX.left = new ClassCoreFX({
				element: this.images.item(this.imageNext),
				property: 'left',
				start: 0,
				end: -this.images.item(this.imageNext).offsetWidth,
				transition: 'linear',
				duration: '30000',
				fps: 50,
				listen: this.fxListenLeft._bind(this)
				});
		}
	},
	/**
	 * Image suivante
	 */
	next : function() {
		// Rebuild style.zIndex
		for(var v_i = 0, v_l = this.images.length; v_i < v_l; v_i++) {
			var v_z = ((Number(this.images.item(v_i).style.zIndex) + 1) > v_l) ? (1) : (Number(this.images.item(v_i).style.zIndex) + 1);
			this.images.item(v_i).style.zIndex = v_z;
		}

		this.images.item(this.imageActive).coreFX.opacity.stop();
		this.images.item(this.imageActive).coreFX.opacity.set(100);
		this.images.item(this.imageActive).coreFX.opacity = false;
		this.images.item(this.imageActive).coreFX.left.stop();
		this.images.item(this.imageActive).coreFX.left.set(0);
		this.images.item(this.imageActive).coreFX.left = false;

		this.imageActive = this.imageNext;
	}

};




/**
 * Classe permettant une navigation par pages
 * @param {HTMLElement} p_id Element a manipuler
 * @param {String} p_goto Aller a la page X
 * @constructor
 */
function ClassPages(p_id, p_goto) {
	/** @return {HTMLElement} DIV contenant les pages */
	this.id = Doc.id(p_id);
	/** @return {HTMLElement} Element permettant d'afficher le numero de page */
	this.id_ = Doc.id(p_id + '_');
	/** @return {HTMLElement} UL contenant les pages */
	this.book = null;
	/** @return {Array} LI les pages */
	this.pagesElement = [];
	/** @return {Number} Nombre total de page */
	this.pagesLength = 0;			/* readonly - Integer */
	/** @return {Number} Page affichee */
	this.pageShow = 0;
	/** @return {Number} Vitesse du timeout en MS ( min: 10 || max: ++ ) */
	this.pageTimeout = 20;
	/** @return {Number} Largueur d'une page en PX */
	this.pageWidth = 0;
//	/** @return {Number} Hauteur d'une page en PX */
//	this.pageHeight = 0;			/* readonly - Integer (px) */
	/** @return {Array} Les intervaux de largeur de chaque page */
	this.intervalWidth = [];
	/** @return {Boolean} La souris est au-dessus du DIV */
	this.mouseOver = false;
	/** @return {Number} Position de la souris au-dessus du DIV (px) */
	this.mousePosX = 0;
	/** @return {Number} Retour du setTimeout() */
	this.timeout = null;

	/** @return {ClassCoreFX} Deplacer le DIV contenant les pages */
	this.moveBook = null;

	/** @return {Boolean} La position de la souris permet de tourner les pages */
	this.withMouseMove = false;
	/** @return {Boolean} Boucle l'effet en cas d'atteinte d'une limite */
	this.withLoop = true;

	this.getPages();
	this.getSize();
	this.setCss();
	this.setMoveBook();
	this.setEvents();
	this.setPageNumber();
	if(p_goto !== undefined) {
		this.turn(p_goto);
	}
}
ClassPages.prototype = {
	/**
	 * Determiner les pages
	 */
	getPages : function() {
		var v_childNodes = this.id.childNodes;
		for(var v_i = 0, v_l = v_childNodes.length; v_i < v_l; v_i++) {
			if(v_childNodes[v_i].nodeType == 1) {
				this.book = v_childNodes[v_i];
				break;
			}
		}
		var v_childNodes = this.book.childNodes;
		var v_array = 0;
		for(var v_i = 0, v_l = v_childNodes.length; v_i < v_l; v_i++) {
			if(v_childNodes[v_i].nodeType == 1) {
				this.pagesElement[v_array] = v_childNodes[v_i];
				v_array++;
			}
		}
		this.pagesLength = this.pagesElement.length;
	},
	/**
	 * Determiner la largeur et la hauteur d'une page
	 */
	getSize : function() {
//		this.pageWidth = this.id.offsetWidth;
//		this.pageHeight = this.id.offsetHeight;

		for(var v_i = 0, v_l = this.pagesLength, v_c = 0; v_i < v_l; v_i++) {
			this.intervalWidth[v_i] = [];
			this.intervalWidth[v_i]['min'] = v_c;
			v_c += this.pagesElement[v_i].offsetWidth;
			this.intervalWidth[v_i]['max'] = v_c;
		}
	},
	/**
	 * Initialiser les styles des differents elements et de la page
	 */
	setCss : function() {
//		this.id.style.overflow = 'hidden';
//		this.id.style.position = 'relative';
		this.book.style.position = 'absolute';
		this.book.style.left = '0';
		for(var v_i = 0, v_l = this.pagesLength; v_i < v_l; v_i++) {
			this.pagesElement[v_i].style.position = 'absolute';
//			this.pagesElement[v_i].style.left = (this.pageWidth * v_i) + 'px';
			this.pagesElement[v_i].style.left = this.intervalWidth[v_i]['min'] + 'px';
			this.pagesElement[v_i].style.top = '0';
//			this.pagesElement[v_i].style.width = (this.pageWidth) + 'px';
//			this.pagesElement[v_i].style.height = (this.pageHeight) + 'px';
		}
	},
	/**
	 * Initialiser le this.moveBook
	 */
	setMoveBook : function() {
//		this.moveBook = new ClassCoreMove(this.book);
////		this.moveBook.setLimitsLeft(-(this.pageWidth * (this.pagesLength-1)), 0);
//		this.moveBook.setLimitsLeft(-this.intervalWidth[this.pagesLength-1]['min'], 0);
		this.moveBook = new ClassCoreFX({
			element: this.book,
			property: 'left',
			mini: -this.intervalWidth[this.pagesLength-1]['min'],
			maxi: 0,
			transition: (this.id.id == 'parcours-pages' ? 'bounce' : 'expo'),
			wait:true
			});
	},
	/**
	 * Initialiser les evenements
	 */
	setEvents : function() {
		if(this.withMouseMove) {
			this.id.onmouseover = this.divOnmouseover._bindEvent(this);
			this.id.onmousemove = this.divOnmousemove._bindEvent(this);
			this.id.onmouseout = this.divOnmouseout._bindEvent(this);
		}
	},
	previousPageShow : -1,
	/**
	 * Afficher le numero de la page
	 */
	setPageNumber : function() {
//		if(this.id_) {
//			this.id_.innerHTML = String(this.pageShow + 1);
//		}
		if(this.id.id == 'parcours-pages') {
			if(Doc.id('p-c-'+this.previousPageShow)) { Doc.id('p-c-'+this.previousPageShow).className = ''; }
			this.previousPageShow = String(this.pageShow + 1);
			if(Doc.id('p-c-'+this.previousPageShow)) { Doc.id('p-c-'+this.previousPageShow).className = 'active'; }
		}
	},
	/**
	 * Tourner une page
	 * @param {String} p_mode Mode ('left', 'right') ou numero de page
	 */
	turn : function(p_mode) {
		if(!isNaN(p_mode)) {
			if(p_mode <= 0) {
				p_mode = 0;
			} else if(p_mode >= this.pagesLength) {
				p_mode = this.pagesLength - 1;
			} else {
				p_mode = p_mode - 1;
			}
			this.pageShow = p_mode;
		} else if(p_mode == 'left') {
			if((this.pageShow - 1) < 0) {
				if(this.withLoop) {
					this.pageShow = this.pagesLength - 1;
				}
			} else {
				this.pageShow = this.pageShow - 1;
			}
		} else if(p_mode == 'right') {
			if((this.pageShow + 1) >= this.pagesLength) {
				if(this.withLoop) {
					this.pageShow = 0;
				}
			} else {
				this.pageShow = this.pageShow + 1;
			}
		} else {
			this.pageShow = 0;
		}
		this.setPageNumber();
////		this.moveBook.moveLeft(-(this.pageWidth * this.pageShow));
//		this.moveBook.moveLeft(-this.intervalWidth[this.pageShow]['min']);
		this.moveBook.move(-this.intervalWidth[this.pageShow]['min'])
	},
	/**
	 * Souris au-dessus du DIV
	 * @param {MouseEvent} p_e
	 */
	divOnmouseover : function(p_e) {
		this.mouseOver = true;
		this.divMove();
	},
	/**
	 * Souris qui se deplace au-dessus du DIV
	 * @param {MouseEvent} p_e
	 */
	divOnmousemove : function(p_e) {
		var v_offset = new ClassOffset(this.id);
		this.mousePosX = FixEvent.pointerX(p_e) - v_offset.left;
	},
	/**
	 * Souris sort du DIV
	 * @param {MouseEvent} p_e
	 */
	divOnmouseout : function(p_e) {
		this.mouseOver = false;
		window.clearTimeout(this.timeout);
	},
	/**
	 * Deplacement du DIV selon la position de la souris ( boucle )
	 */
	divMove : function() {
		if(this.mouseOver) {
			var v_speed = 0;
			// vitesse
			if(this.mousePosX < 50) {
				v_speed = 4;
			} else if(this.mousePosX >= 50 && this.mousePosX < 100) {
				v_speed = 2;
			} else if(this.mousePosX >= 100 && this.mousePosX < 200) {
				v_speed = 1;
				// -
			} else if(this.mousePosX >= 400 && this.mousePosX < 500) {
				v_speed = -1;
			} else if(this.mousePosX >= 400 && this.mousePosX < 550) {
				v_speed = -2;
			} else if(this.mousePosX >= 550) {
				v_speed = -4;
			}
//			this.moveBook.translateLeft(v_speed);
			this.moveBook.translate(v_speed);
//			this.pageShow = - Math.round(this.moveBook.getLeft() / this.pageWidth);
//			for(var v_i = 0, v_l = this.pagesLength, v_left = this.moveBook.getLeft(); v_i < v_l; v_i++) {
			for(var v_i = 0, v_l = this.pagesLength, v_left = this.moveBook.get(); v_i < v_l; v_i++) {
				if(-this.intervalWidth[v_i]['min'] >= v_left && -this.intervalWidth[v_i]['max'] <= v_left) {
					this.pageShow = v_i;
					break;
				}
			}
			this.setPageNumber();

			this.timeout = window.setTimeout(this.divMove._bind(this), this.pageTimeout);
		}
	}
};



/**
 * page-parcours.php
 * @constructor
 */
var PageParcours = {
	/** @return {ClassPages} Navigation des elements */
	pages : false,
	/**
	 * Chargement de la page
	 */
	onload : function() {
		var v_goto = Number(window.location.hash.replace('#',''));
		if(isNaN(v_goto)) { v_goto = undefined; }
		this.pages = new ClassPages('parcours-pages', v_goto);
	},
	/**
	 * Tourner les pages a gauche
	 * @return {Boolean} False
	 */
	turnLeftClick : function() {
		if(this.pages) {
			this.pages.turn('left');
		}
		return false;
	},
	/**
	 * Tourner les pages a droite
	 * @return {Boolean} False
	 */
	turnRightClick : function() {
		if(this.pages) {
			this.pages.turn('right');
		}
		return false;
	},
	/**
	 * Tourner une page
	 * @param {Number} p_x Numero de page
	 * @return {Boolean} False
	 */
	turnPage : function(p_x) {
		if(this.pages) {
			this.pages.turn(p_x);
		}
		return false;
	}
};


/**
 * page-galerie.php
 * @constructor
 */
var PageGaleries = {
	/**
	 * Chargement de la page
	 * /
	onload : function() { },
	 */
};



