/* Configuration variables */var conf_reflection_p = 1.5;         // Sets the height of the reflection in % of the source image var conf_focus = 2;                  // Sets the numbers of images on each side of the focussed onevar conf_images_cursor = 'pointer';  // Sets the cursor type for all images default is 'default'var conf_slider_cursor = 'default';  // Sets the slider cursor type: try "e-resize" default is 'default'/* Id names used in the HTML */var conf_imageflow = 'imageflow';    // Default is 'imageflow'var conf_loading = 'loading';        // Default is 'loading'var conf_images = 'images';          // Default is 'images'var conf_captions = 'captions';      // Default is 'captions'/* Define global variables */var caption_id = 0;var new_caption_id = 0;var current = 0;var target = 0;var mem_target = 0;var timer = 0;var array_images = new Array();var posx = 0;var new_posx = 0;var angle_bas 			= 0.6; /* coef gérant l'angle du bas que décrivent les images */var image_y_delta		= -75 ; /* décalage Y des images */var image_depart_num	= 1;/* influe sur la taille des images */var xstep 				= 100;var landscape_format	= 132;var imgHeightOrigine	= 220;function step(){		switch (target < current-1 || target > current+1) 	{		case true:			moveTo(current + (target-current)/3);			window.setTimeout(step, 50);			timer = 1;			break;		default:			timer = 0;			break;	}}function glideTo(x, new_caption_id){			/* Animate gliding to new x position */	target = x;	mem_target = x;	if (timer == 0)	{		window.setTimeout(step, 50);		timer = 1;	}		/* Display new caption */	caption_id = new_caption_id;	try{		caption = img_div.childNodes.item(array_images[caption_id]).getAttribute('alt');	}catch(e){		caption = '';	}	if (caption == '') caption = '&nbsp;';	caption_div.innerHTML = '<span>'+caption+'</span>';		try{	if($('p'+img_div.childNodes.item(array_images[caption_id]).getAttribute('id')) != null) {		caption_div.onclick = function(){scroller.toElement('p'+img_div.childNodes.item(array_images[caption_id]).getAttribute('id'));}		caption_div.onmouseover = function(){caption_div.className='captionOver';};		caption_div.onmouseout = function(){caption_div.className='captionOut';};		caption_div.className='captionOut';	} else {		caption_div.onclick = '';		caption_div.onmouseover = '';		caption_div.onmouseout = '';		caption_div.className = '';	}	}catch(e){}	}function moveTo(x){		current = x;	var zIndex = max;		/* Main loop */	for (var index = 0; index < max; index++)	{		var image = img_div.childNodes.item(array_images[index]);		var current_image = index * -xstep;		/* Don't display images that are not conf_focussed */		if ((current_image+max_conf_focus) < mem_target || (current_image-max_conf_focus) > mem_target)		{			image.style.visibility = 'hidden';			image.style.display = 'none';		}		else 		{			var z = Math.sqrt(10000 + x * x) + 100;			var xs = x / z * size + size;			/* Still hide images until they are processed, but set display style to block */			image.style.display = 'block';					/* Process new image height and image width */						var new_img_h = (image.height / image.width * image.pc) / z * size;			switch ( new_img_h > max_height )			{				case false:					var new_img_w = image.pc / z * size;					break;				default:					new_img_h = max_height;					var new_img_w = image.width * new_img_h / image.height;					break;			}						var new_img_top = (images_width * 0.34 - new_img_h) + ((new_img_h / (conf_reflection_p + angle_bas)) * conf_reflection_p) + images_top + image_y_delta;			/* Set new image properties */			image.style.left = xs - (image.pc / 2) / z * size + images_left + 'px';			if(new_img_w && new_img_h)			{ 				image.style.height = new_img_h + 'px'; 				image.style.width = new_img_w + 'px'; 				image.style.top = new_img_top + 'px';			}			image.style.visibility = 'visible';			/* Set image layer through zIndex */			switch ( x < 0 )			{				case true:					zIndex++;					break;				default:					zIndex = zIndex - 1;					break;			}						/* Change zIndex and onclick function of the focussed image */			switch ( image.i == caption_id )			{								case false:					try{					if(typeof(image.onclick) != 'object'){image.removeEvents("click");}					}catch(e){}					image.onclick = function() { glideTo(this.x_pos, this.i); }					break;									default:					zIndex = zIndex + 1;					var source = new String(image.src);					var reg	= new RegExp("(galerie.png)", "g");					var imageURL = source.replace(reg,"produit.jpg")										image.onclick = function(){						showLightbox(imageURL, img_div.childNodes.item(array_images[caption_id]).getAttribute('alt'));					}					break;			}			image.style.zIndex = zIndex;					}		x += xstep;	}	}/* Main function */function refresh(onload){	/* Cache document objects in global variables */	imageflow_div = document.getElementById(conf_imageflow);	img_div = document.getElementById(conf_images);	caption_div = document.getElementById(conf_captions);	/* Cache global variables, that only change on refresh */	images_width = img_div.offsetWidth;	images_top = imageflow_div.offsetTop;	images_left = 0;	max_conf_focus = conf_focus * xstep;	size = images_width * 0.5;	max_height = images_width * 0.51;	/* Change imageflow div properties */	imageflow_div.style.height = max_height + 'px';	/* Change images div properties */	img_div.style.height = images_width * 0.338 + 'px';	/* Change captions div properties */	caption_div.style.width = images_width + 'px';	caption_div.style.marginTop = images_width * 0.03 + 'px';		/* Cache EVERYTHING! */	max = img_div.childNodes.length;	var i = 0;		for (var index = 0; index < max; index++)	{ 		var image = img_div.childNodes.item(index);				if (image.nodeType == 1)		{			array_images[i] = index;						/* Set image onclick by adding i and x_pos as attributes! */			image.onclick = function() { glideTo(this.x_pos, this.i); }			image.x_pos = (-i * xstep);			image.i = i;						/* Add width and height as attributes ONLY once onload */			if(onload == true)			{				image.height = imgHeightOrigine;				image.w = image.width;				image.h = image.height;			}			/* Check source image format. Get image height minus reflection height! */			switch ((image.w + 1) > (image.h / (conf_reflection_p + 1))) 			{				/* Landscape format */				case true:					image.pc = landscape_format; /* % de zoom */					break;				/* Portrait and square format */				default:					image.pc = 100; /* % de zoom */					break;			}						/* Set image cursor type */			image.style.cursor = conf_images_cursor;			i++;		}	}	max = array_images.length;		if(onload == true) {		image_depart_num = array_images.length; // Math.round(array_images.length/2);		target = -(image_depart_num-1)*xstep;		caption_id	= image_depart_num-1;	}	/* Display images in current order */	moveTo(target);	glideTo(target, caption_id);	}/* Show/hide element functions */function show(id){	var element = document.getElementById(id);	element.style.visibility = 'visible';}function hide(id){	var element = document.getElementById(id);	element.style.visibility = 'hidden';	element.style.display = 'none';}/* Hide loading bar, show content and initialize mouse event listening after loading */window.addEvent('domready',function(){	if(document.getElementById(conf_imageflow))	{		hide(conf_loading);		refresh(true);		initMouseWheel();		show(conf_images);		newNum	= Math.round(array_images.length/2);		glideTo(-(newNum-1)*xstep, newNum-1);	}});/* Refresh ImageFlow on window resize */window.onresize = function(){	if(document.getElementById(conf_imageflow)) refresh();}/* Fixes the back button issue */window.onunload = function(){  document = null;}/* Handle the wheel angle change (delta) of the mouse wheel */function handle(delta){	var change = false;	switch (delta > 0)	{		case true:			if(caption_id >= 1)			{				target = target + xstep;				new_caption_id = caption_id - 1;				change = true;			}			break;		default:			if(caption_id < (max-1))			{				target = target - xstep;				new_caption_id = caption_id + 1;				change = true;			}			break;	}	/* Glide to next (mouse wheel down) / previous (mouse wheel up) image */	if (change == true)	{		glideTo(target, new_caption_id);	}}/* Event handler for mouse wheel event */function wheel(event){	var delta = 0;	if (!event) event = window.event;	if (event.wheelDelta)	{		delta = event.wheelDelta / 120;	}	else if (event.detail)	{		delta = -event.detail / 3;	}	if (delta) handle(delta);	if (event.preventDefault) event.preventDefault();	event.returnValue = false;}/* Initialize mouse wheel event listener */function initMouseWheel(){	if(window.addEventListener) imageflow_div.addEventListener('DOMMouseScroll', wheel, false);	imageflow_div.onmousewheel = wheel;}function getKeyCode(event){	event = event || window.event;	return event.keyCode;}document.onkeydown = function(event){	var charCode  = getKeyCode(event);	switch (charCode)	{		/* Right arrow key */		case 39:			handle(-1);			break;				/* Left arrow key */		case 37:			handle(1);			break;	}}
