// modules.solrsearch.lib.js.jquery-bgiframe-fr-fr 
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * jQueryLastChangedDate: 2007-07-22 01:45:56 +0200 (Son, 22 Jul 2007) jQuery
 * jQueryRev: 2447 jQuery
 *
 * Version 2.1.1
 */
(function(jQuery){jQuery.fn.bgIframe=jQuery.fn.bgiframe=function(s){if(jQuery.browser.msie&&/6.0/.test(navigator.userAgent)){s=jQuery.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if(jQuery('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

// modules.solrsearch.lib.js.jquery-ajaxqueue-fr-fr 
/**
 * Ajax Queue Plugin
 * 
 * Homepage: http://jquery.com/plugins/project/ajaxqueue
 * Documentation: http://docs.jquery.com/AjaxQueue
 */

/**

<script>
jQuery(function(){
	jQuery.ajaxQueue({
		url: "test.php",
		success: function(html){ jQuery("ul").append(html); }
	});
	jQuery.ajaxQueue({
		url: "test.php",
		success: function(html){ jQuery("ul").append(html); }
	});
	jQuery.ajaxSync({
		url: "test.php",
		success: function(html){ jQuery("ul").append("<b>"+html+"</b>"); }
	});
	jQuery.ajaxSync({
		url: "test.php",
		success: function(html){ jQuery("ul").append("<b>"+html+"</b>"); }
	});
});
</script>
<ul style="position: absolute; top: 5px; right: 5px;"></ul>

 */
/*
 * Queued Ajax requests.
 * A new Ajax request won't be started until the previous queued 
 * request has finished.
 */

/*
 * Synced Ajax requests.
 * The Ajax request will happen as soon as you call this method, but
 * the callbacks (success/error/complete) won't fire until all previous
 * synced requests have been completed.
 */


(function(jQuery) {
	
	var ajax = jQuery.ajax;
	
	var pendingRequests = {};
	
	var synced = [];
	var syncedData = [];
	
	jQuery.ajax = function(settings) {
		// create settings for compatibility with ajaxSetup
		settings = jQuery.extend(settings, jQuery.extend({}, jQuery.ajaxSettings, settings));
		
		var port = settings.port;
		
		switch(settings.mode) {
		case "abort": 
			if ( pendingRequests[port] ) {
				pendingRequests[port].abort();
			}
			return pendingRequests[port] = ajax.apply(this, arguments);
		case "queue": 
			var _old = settings.complete;
			settings.complete = function(){
				if ( _old )
					_old.apply( this, arguments );
				jQuery([ajax]).dequeue("ajax" + port );;
			};
		
			jQuery([ ajax ]).queue("ajax" + port, function(){
				ajax( settings );
			});
			return;
		case "sync":
			var pos = synced.length;
	
			synced[ pos ] = {
				error: settings.error,
				success: settings.success,
				complete: settings.complete,
				done: false
			};
		
			syncedData[ pos ] = {
				error: [],
				success: [],
				complete: []
			};
		
			settings.error = function(){ syncedData[ pos ].error = arguments; };
			settings.success = function(){ syncedData[ pos ].success = arguments; };
			settings.complete = function(){
				syncedData[ pos ].complete = arguments;
				synced[ pos ].done = true;
		
				if ( pos == 0 || !synced[ pos-1 ] )
					for ( var i = pos; i < synced.length && synced[i].done; i++ ) {
						if ( synced[i].error ) synced[i].error.apply( jQuery, syncedData[i].error );
						if ( synced[i].success ) synced[i].success.apply( jQuery, syncedData[i].success );
						if ( synced[i].complete ) synced[i].complete.apply( jQuery, syncedData[i].complete );
		
						synced[i] = null;
						syncedData[i] = null;
					}
			};
		}
		return ajax.apply(this, arguments);
	};
	
})(jQuery);

// modules.solrsearch.lib.js.thickbox-fr-fr 
/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
		  
var tb_pathToImage = "/media/frontoffice/solrsearch/indicator.gif";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
jQuery(document).ready(function(){   
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
});

//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
	jQuery(domChunk).click(function(){
	var t = this.title || this.name || null;
	var a = this.href || this.alt;
	var g = this.rel || false;
	tb_show(t,a,g);
	this.blur();
	return false;
	});
}

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			jQuery("body","html").css({height: "100%", width: "100%"});
			jQuery("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null){caption="";}
		jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		jQuery('#TB_load').show();//show loader
		
		var baseURL;
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{ 
	   		baseURL = url;
	   }
	   
	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
				
			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if(imageGroup){
				TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
						if (!(TB_TempArray[TB_Counter].href == url)) {						
							if (TB_FoundURL) {
								TB_NextCaption = TB_TempArray[TB_Counter].title;
								TB_NextURL = TB_TempArray[TB_Counter].href;
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
							} else {
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
								TB_PrevURL = TB_TempArray[TB_Counter].href;
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
							}
						} else {
							TB_FoundURL = true;
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
						}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){		
			imgPreloader.onload = null;
				
			// Resizing large images - orginal by Christian Montoya edited by me.
			var pagesize = tb_getPageSize();
			var x = pagesize[0] - 150;
			var y = pagesize[1] - 150;
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (imageWidth > x) {
				imageHeight = imageHeight * (x / imageWidth); 
				imageWidth = x; 
				if (imageHeight > y) { 
					imageWidth = imageWidth * (y / imageHeight); 
					imageHeight = y; 
				}
			} else if (imageHeight > y) { 
				imageWidth = imageWidth * (y / imageHeight); 
				imageHeight = y; 
				if (imageWidth > x) { 
					imageHeight = imageHeight * (x / imageWidth); 
					imageWidth = x;
				}
			}
			// End Resizing
			
			TB_WIDTH = imageWidth + 30;
			TB_HEIGHT = imageHeight + 60;
			jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>"); 		
			
			jQuery("#TB_closeWindowButton").click(tb_remove);
			
			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
					jQuery("#TB_window").remove();
					jQuery("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;	
				}
				jQuery("#TB_prev").click(goPrev);
			}
			
			if (!(TB_NextHTML === "")) {		
				function goNext(){
					jQuery("#TB_window").remove();
					jQuery("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
					return false;	
				}
				jQuery("#TB_next").click(goNext);
				
			}

			document.onkeydown = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				} else if(keycode == 190){ // display previous image
					if(!(TB_NextHTML == "")){
						document.onkeydown = "";
						goNext();
					}
				} else if(keycode == 188){ // display next image
					if(!(TB_PrevHTML == "")){
						document.onkeydown = "";
						goPrev();
					}
				}	
			};
			
			tb_position();
			jQuery("#TB_load").remove();
			jQuery("#TB_ImageOff").click(tb_remove);
			jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show
			};
			
			imgPreloader.src = url;
		}else{//code to show html
			
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );

			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
					urlNoQuery = url.split('TB_');
					jQuery("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
					}else{//iframe modal
					jQuery("#TB_overlay").unbind();
						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}else{// not an iframe, ajax
					if(jQuery("#TB_window").css("display") != "block"){
						if(params['modal'] != "true"){//ajax no modal
						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
						}else{//ajax modal
						jQuery("#TB_overlay").unbind();
						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
						}
					}else{//this means the window is already up, we are just loading new content via ajax
						jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						jQuery("#TB_ajaxContent")[0].scrollTop = 0;
						jQuery("#TB_ajaxWindowTitle").html(caption);
					}
			}
					
			jQuery("#TB_closeWindowButton").click(tb_remove);
			
				if(url.indexOf('TB_inline') != -1){	
					jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
					jQuery("#TB_window").unload(function () {
						jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					jQuery("#TB_load").remove();
					jQuery("#TB_window").css({display:"block"}); 
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){//safari needs help because it will not fire iframe onload
						jQuery("#TB_load").remove();
						jQuery("#TB_window").css({display:"block"});
					}
				}else{
					jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						jQuery("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						jQuery("#TB_window").css({display:"block"});
					});
				}
			
		}

		if(!params['modal']){
			document.onkeyup = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				}	
			};
		}
		
	} catch(e) {
		//nothing here
	}
}

//helper functions below
function tb_showIframe(){
	jQuery("#TB_load").remove();
	jQuery("#TB_window").css({display:"block"});
}

function tb_remove() {
 	jQuery("#TB_imageOff").unbind("click");
	jQuery("#TB_closeWindowButton").unbind("click");
	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	jQuery("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		jQuery("body","html").css({height: "auto", width: "auto"});
		jQuery("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}

function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}




// modules.solrsearch.lib.js.jquery-autocomplete-fr-fr 
/*
 * jQuery Autocomplete plugin 1.1
 *
 * Copyright (c) 2009 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
 */;(function(jQuery){jQuery.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=jQuery.extend({},jQuery.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?jQuery.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new jQuery.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});jQuery.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=jQuery(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=jQuery.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=jQuery.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;jQuery.browser.opera&&jQuery(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind((jQuery.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&jQuery.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}jQuery.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){jQuery.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind((jQuery.browser.opera ? "keypress" : "keydown") + ".autocomplete");$input.unbind();jQuery(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=jQuery(input).selection().start;var wordAt,progress=0;jQuery.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[jQuery.trim(value)];return jQuery.map(value.split(options.multipleSeparator),function(word){return jQuery.trim(value).length?jQuery.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=jQuery(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));jQuery(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};jQuery.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});jQuery.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:jQuery.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=jQuery.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};jQuery.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};jQuery.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};jQuery.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];jQuery.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];jQuery.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};jQuery.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=jQuery("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=jQuery("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=jQuery("li",list).removeClass(CLASSES.ACTIVE).index(target(event));jQuery(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){jQuery(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=jQuery("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];jQuery.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if(jQuery.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=jQuery(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:jQuery(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if(jQuery.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&jQuery.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};jQuery.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);

// modules.imgslider.lib.js.carousel-fr-fr 
;(function($){

	// IMAGES PRELOADER
	$.fn.carousel = function(params)
	{
		var params = $.extend({
			direction: "horizontal",
			loop: false,
			dispItems: 1,
			pagination: false,
			miniatures: false,
			miniaturesMargin: 0,
			page: 0,
			paginationPosition: "inside",
			pagiminiatures: false,
			rolloverpagination: false,
			rolloverbackgroundcolor: '#CCCCCC',
			rolloverbordercolor: '#000000',
			rolloverbordersize: 1,
			nextBtn: '<span role="button"></span>',
			prevBtn: '<span role="button"></span>',
			btnsPosition: "outside",
			nextBtnInsert: "appendTo",
			prevBtnInsert: "prependTo",
			nextBtnInsertFn: false,
			prevBtnInsertFn: false,
			autoSlide: false,
			autoSlideInterval: 3000,
			activeRelativePageMiniatures: true,
			btnAutoSlide: false,
			btnAutoSlidePosition: "top-right",
			visualbtnscarrousel: false,
			btnMargin: 0,
			combinedClasses: false,
			effect: "slide",
			slideEasing: "swing",
			animSpeed: "normal",
			equalWidths: "true",
			callback: function(){},
			useAddress: false,
			adressIdentifier: "carousel",
			useBtNav: true,
			carouselWidth: 0,
			carouselHeight: 0,
			miniatureWidth: 0,
			miniatureHeight: 0
		}, params);

		// Preload images
		var carousel = $(this);
		var carouselParams = params;

		return this.each(function(){
			var carousel_preload_count = $(this).children().children().length;
			var miniatures_preload_count = 0;
			var carousel_preload_ready = 0;

			var images = {};

			// Preload Carrousel Img
			$(this).children().children().each(function(index){

				// Image with link
				if($(this).children().children().length > 0) {
					var image=$(this).children().children().get(0);
				}

				// Image without link
				else {
					var image=$(this).children().get(0);
				}

				$(this).addClass('hidden'); // Hide li
				images[index] = ({'type':'display', 'url':$(image).attr('src')});
			});

			// Preload Miniature Img
			if(params.miniatures){
				// Count items
				var miniatures_location = $('.mini-' + carouselParams.carouselId).children().children();
				miniatures_preload_count = miniatures_location.children().length;
				miniatures_location.children().each(function(index){
					var miniature = $(this).children().get(0);
					$(this).addClass('hidden');
					images[(index+carousel_preload_count)] = ({'type':'miniature', 'url':$(miniature).attr('src')});
				});
			}
			
			if(!params.miniatures && params.rolloverpagination)
			{
				for (var a in params.pagiminiatures)
				{			
					miniatures_preload_count++;
					images[(carousel_preload_count + parseInt(a))] = ({'type':'miniature', 'url':params.pagiminiatures[a]});
				}

			}
			
			for (var i in images){
				// Image Object
				var preloadImage = new Image();
				preloadImage.type = images[i].type;
				preloadImage.onload = function()
				{
					if(this.type == "display"){
						// Set Display's Max-Width
						if(this.width > carouselParams.carouselWidth) {
							carouselParams.carouselWidth = this.width;
						}

						// Set Display's Max-Height
						if(this.height > carouselParams.carouselHeight) {
							carouselParams.carouselHeight = this.height;
						}
					}

					else {
						// Set Miniature's Max-Width
						if(this.width > carouselParams.miniatureWidth) {
							carouselParams.miniatureWidth = this.width;
						}

						// Set Miniature's Max-Height
						if(this.height > carouselParams.miniatureHeight) {
							carouselParams.miniatureHeight = this.height;
						}
					}

					if (++carousel_preload_ready == (carousel_preload_count + miniatures_preload_count)) {
						carousel.carouselrun(carouselParams);
					}

				}
				preloadImage.src = images[i].url;
			}

		});
	}

	$.fn.carouselrun = function(params){
		// Buttons position
		if (params.direction == "vertical"){
			params.prevBtnInsert = "insertBefore";
			params.nextBtnInsert = "insertAfter";
		}

		return this.each(function(){

			// Env object
			var env = {
				$elts: {},
				params: params,
				launchOnLoad: []
			};

			// Carousel main container
			env.$elts.carousel = $(this).addClass("js"); // correspond à div class="carousel big js"

			// Carousel content
			env.$elts.content = $(this).children().css({position: "absolute", "top": 0}); // correspond à ul

			// Content wrapper
			env.$elts.wrap = env.$elts.content.wrap('<div class="carousel-wrap"></div>').parent().css({overflow: "hidden", position: "relative"});
			env.$elts.carrouselnavigation = env.$elts.wrap.wrap('<div class="carrousel-navigation"></div>');


			// env.steps object
			env.steps = {
				first: 0,
				count: env.$elts.content.children().length
			};

			// Last visible step
			env.steps.last = env.steps.count - 1;

			// Prev Button
			if ($.isFunction(env.params.prevBtnInsertFn)) {
				env.$elts.prevBtn = env.params.prevBtnInsertFn(env.$elts);
			}

			else {
				env.$elts.prevBtn = $(params.prevBtn)[params.prevBtnInsert](env.$elts.carousel);
			}

			// Next Button
			if ($.isFunction(env.params.nextBtnInsertFn)) {
				env.$elts.nextBtn = env.params.nextBtnInsertFn(env.$elts);
			}

			else {
				env.$elts.nextBtn = $(params.nextBtn)[params.nextBtnInsert](env.$elts.carousel);
			}

			// Add buttons classes / data
			env.$elts.nextBtn.addClass("carousel-control next carousel-next" + " " + env.params.direction);
			env.$elts.prevBtn.addClass("carousel-control previous carousel-previous" + " " + env.params.direction);

			if(!env.params.useBtNav) {
				env.$elts.nextBtn.addClass("hidden");
				env.$elts.prevBtn.addClass("hidden");
			}


			// Bind events on next / prev buttons
			initButtonsEvents(env);

			// Address plugin
			initAddress(env);

			// On document load...
			$(function(){

				// First item
				var $firstItem = env.$elts.content.children(":first");

				// Width 1/3 : Get default item width
				var maxW = env.params.carouselWidth;
				env.itemWidth = maxW;

				var maxH = env.params.carouselHeight;
				env.itemHeight = maxH;

				// Width 2/3 : Define content width
				env.$elts.content.children().each(function(){
					$(this).width(maxW);
						$(this).height(maxH);
						$(this).removeClass('hidden');
				});

				if (params.direction == "vertical"){
					env.$elts.nextBtn.css('width', maxW).css('margin-top', env.params.btnMargin);
					env.$elts.prevBtn.css('width', maxW).css('margin-bottom', env.params.btnMargin);
					env.contentWidth = env.itemWidth;
					env.$elts.content.parent().css('width', maxW).css('height', maxH * env.params.dispItems);
					env.$elts.carrouselnavigation.parent().css('width', maxW);
				}

				else {
					env.$elts.carrouselnavigation.parent().addClass('horizontal');
					env.$elts.nextBtn.css('height', maxH).css('margin-left', env.params.btnMargin);
					env.$elts.prevBtn.css('height', maxH).css('margin-right', env.params.btnMargin);;
					env.contentWidth = env.itemWidth * env.steps.count;
					env.$elts.content.parent().css('width', maxW * env.params.dispItems).css('height', maxH);
					env.$elts.carrouselnavigation.parent().css('width', (maxW * env.params.dispItems));
				}

				// Width 3/3 : Set content width to container
				env.$elts.content.width( env.contentWidth );

				// Height 1/2 : Get default item height
				env.itemHeight = $firstItem.outerHeight();

				// Height 2/2 : Set content height to container
				if (params.direction == "vertical"){
					env.$elts.content.css({height:env.itemHeight * env.steps.count + "px"});
					env.$elts.content.parent().css({height:env.itemHeight * env.params.dispItems + "px"});

				} else {
					env.$elts.content.parent().css({height:env.itemHeight + "px"});
				}

				// Launch function added to "document ready" event
				$.each(env.launchOnLoad, function(i,fn){
					fn();
				});

				// Miniatures
				if(env.params.miniatures) {
					initMiniatures(env)
				}

				// Pagination
				if (env.params.pagination) {
					initPagination(env);
				}

				// Update Next / Prev buttons state
				updateButtonsState(env);


				// Bouton AutoSlide
				if(env.params.btnAutoSlide) {
					initBtnAutoSlide(env);
					getPositionOfAutoSlideBtn(env, env.params.btnAutoSlidePosition);
				}

				// Load customs buttons
				if(env.params.visualbtnscarrousel)
				{
					switch (env.params.direction)
					{
						case 'horizontal':
							// Carousel buttons
							if(env.params.visualbtnscarrousel["next"] != "null") {
								env.$elts.nextBtn.css('background-image', 'url('+ env.params.visualbtnscarrousel["next"]["url"] + ')').css('width', env.params.visualbtnscarrousel["next"]["width"]);
							}
							if(env.params.visualbtnscarrousel["prev"] != "null") {
								env.$elts.prevBtn.css('background-image', 'url('+ env.params.visualbtnscarrousel["prev"]["url"] + ')').css('width', env.params.visualbtnscarrousel["prev"]["width"]);
							}

							// Miniatures buttons
							if(env.params.visualbtnscarrousel["next-mini"] != "null" && env.params.miniatures){
								env.$elts.miniBtnNext.css('background-image', 'url('+ env.params.visualbtnscarrousel["next-mini"]["url"] + ')');
							}
							if(env.params.visualbtnscarrousel["prev-mini"] != "null" && env.params.miniatures){
								env.$elts.miniBtnPreced.css('background-image', 'url('+ env.params.visualbtnscarrousel["prev-mini"]["url"] + ')');
							}

						break;

						case 'vertical':
							// Carousel buttons
							if(env.params.visualbtnscarrousel["next"] != "null") {
								env.$elts.nextBtn.css('background-image', 'url('+ env.params.visualbtnscarrousel["next"]["url"] + ')').css('height', env.params.visualbtnscarrousel["next"]["height"]);
							}

							if(env.params.visualbtnscarrousel["prev"] != "null") {
								env.$elts.prevBtn.css('background-image', 'url('+ env.params.visualbtnscarrousel["prev"]["url"] + ')').css('height', env.params.visualbtnscarrousel["prev"]["height"]);
							}

							// Miniatures buttons
							if(env.params.visualbtnscarrousel["next-mini"] != "null" && env.params.miniatures){
								env.$elts.miniBtnNext.css('background-image', 'url('+ env.params.visualbtnscarrousel["next-mini"]["url"] + ')');
							}
							if(env.params.visualbtnscarrousel["prev-mini"] != "null" && env.params.miniatures){
								env.$elts.miniBtnPreced.css('background-image', 'url('+ env.params.visualbtnscarrousel["prev-mini"]["url"] + ')');
							}

						break;
					}
				}

				// Launch autoslide
				if (env.params.autoSlide){
					playAutoSlide(env);
				}
			});

		});

	};

	// Next / Prev buttons events only
	function initButtonsEvents(env){

		env.$elts.nextBtn.add(env.$elts.prevBtn)

			.bind("enable", function(){

				var $this = $(this)
					.unbind("click")
					.bind("click", function(){
						goToStep( env, getRelativeStep(env, ($this.is(".next")? "next" : "prev" )) );
						stopAutoSlide(env);

						// Get relative page of miniatures
						getRelativePageOfMiniatures(env);

					})
					.removeClass("disabled");

				// Combined classes (IE6 compatibility)
				if (env.params.combinedClasses) {
					$this.removeClass("next-disabled previous-disabled");
				}
			})
			.bind("disable", function(){

				var $this = $(this).unbind("click").addClass("disabled");

				// Combined classes (IE6 compatibility)
				if (env.params.combinedClasses) {

					if ($this.is(".next")) {
						$this.addClass("next-disabled");

					} else if ($this.is(".previous")) {
						$this.addClass("previous-disabled");

					}
				}
			})
			.hover(function(){
				$(this).toggleClass("hover");
			});
	};

	// Pagination
	function initPagination(env){
		env.$elts.pagination = $('<div class="center-wrap"><div class="carousel-pagination"><ul class="pagi"></ul></div></div>').insertAfter(env.$elts.nextBtn).find("ul");
		if(env.params.direction == "vertical"){
			env.$elts.pagination.parent().parent().css('width', env.$elts.carrouselnavigation.outerWidth());
			env.$elts.pagination.parent().addClass('vertical');
		}
		else{
			env.$elts.pagination.parent().addClass('horizontal');
			env.$elts.pagination.parent().parent().appendTo(env.$elts.content.parents('.carrousel-navigation'));
		}
		env.$elts.paginationBtns = $([]);

		env.$elts.content.find("li").each(function(i){
			if (i % env.params.dispItems == 0) {
				if(env.params.rolloverpagination){
					env.$elts.paginationBtns = env.$elts.paginationBtns.add( $('<li><a role="button"><span>'+( env.$elts.paginationBtns.length + 1 )+'</span></a><div class="block-mini"><ul class="ul-pagi-mini"></ul></div></li>').data("firstStep", i) );
				}

				else {
					env.$elts.paginationBtns = env.$elts.paginationBtns.add ( $('<li><a role="button"><span>'+( env.$elts.paginationBtns.length + 1 )+'</span></a></li>').data("firstStep", i) );
				}
			}
		});
		
		if(env.params.rolloverpagination){
			env.$elts.paginationBtns.each(function(i){
				for(z=i*env.params.dispItems;z<((i*env.params.dispItems)+parseInt(env.params.dispItems));z++)
				{
					if(z < env.steps.count) {
						$(this).children('div').children('ul').append('<li class="pagi-mini"><img src="'+ env.params.pagiminiatures[z] +'"/></li>');
					}
				}
			});
		}

		env.$elts.paginationBtns.appendTo(env.$elts.pagination);

		env.$elts.paginationBtns.slice(0,1).addClass("active");

		// Events (click pagination)
		env.$elts.paginationBtns.each(function(i){
			$(this).click(function(){
				if(env.params.rolloverpagination){
					$(this).children('div').fadeOut('fast');
				}
				goToStep(env, $(this).data("firstStep"));
				stopAutoSlide(env);
				getRelativePageOfMiniatures(env);
			});
		});

		if(env.params.rolloverpagination)
		{
			// Events (hover pagination)
			env.$elts.paginationBtns.each(function(i){
				
				// Fix margin-top
				var fixmargin = 0;
				
				if($.browser.msie){
					fixmargin = env.params.miniatureHeight + (env.params.rolloverbordersize*2);
				}
				
				else{
					fixmargin = $(this).children('div').outerHeight();
				}
				
				$(this).children('div').css('margin-top', -(fixmargin + 30 + (env.params.rolloverbordersize*2))).css('background', env.params.rolloverbackgroundcolor).css('border-color', env.params.rolloverbordercolor).css('border-width', env.params.rolloverbordersize);
		        $(this).hover(function(){
		        	$(this).children('div').stop(true, true).fadeIn().css('display', 'block');
				 },function(){
					$(this).children('div').fadeOut('fast').css('display', '');
				});
		    });
		}
	};

	// Miniatures
	function initMiniatures(env){

		// Initialize
		var maxMiniatureWidth = 0;
		var maxMiniatureHeight = 0;

		// Define elements
		env.$elts.miniwrap = env.$elts.content.parents('.js').nextAll('.mini-' + env.params.carouselId);
		env.$elts.miniatures = env.$elts.miniwrap.children();
		env.$elts.minicarrousel = env.$elts.miniatures.find('.mini-carrousel');


		// AppendTo
		env.$elts.miniwrap.appendTo(env.$elts.content.parents('.carrousel-navigation'));

		// Get Max-width and Max-height of miniatures
		maxMiniatureWidth = env.params.miniatureWidth;
		maxMiniatureHeight = env.params.miniatureHeight;

		// Define max-width and max-height + margin of miniatures
		env.miniatureWidth = (maxMiniatureWidth + env.params.miniaturesMargin);
		env.miniatureHeight = (maxMiniatureHeight + env.params.miniaturesMargin);

		// Get minicarousel options
		env.minioptions = miniCarouselOptions(env);

		// Active or not btns previous and next
		env.minioptions.btnPosition.before('<span class="mini-preced"></span>').after('<span class="mini-next"></span>');

		// Define Btns
		env.$elts.miniBtnPreced = env.$elts.miniwrap.find('.mini-preced');
		env.$elts.miniBtnNext = env.$elts.miniwrap.find('.mini-next');

		// Custom buttons
		var tmaxMiniWidth = 10;
		var tmaxMiniHeight = 10;
		var zmaxMiniWidth = maxMiniatureWidth;
		var zmaxMiniHeight = maxMiniatureHeight;

		if(env.minioptions.nbPages <= 1) {
			env.$elts.miniBtnPreced.addClass('hidden');
			env.$elts.miniBtnNext.addClass('hidden');
		}

		else {
			if(env.params.visualbtnscarrousel["next-mini"] != "null"){

				// Width
				if(env.params.visualbtnscarrousel["next-mini"]["width"] > tmaxMiniWidth){
					tmaxMiniWidth = env.params.visualbtnscarrousel["next-mini"]["width"];
				}
				if(env.params.visualbtnscarrousel["next-mini"]["width"] > zmaxMiniWidth){
					zmaxMiniWidth = env.params.visualbtnscarrousel["next-mini"]["width"];
				}


				// Height
				if(env.params.visualbtnscarrousel["next-mini"]["height"] > zmaxMiniHeight){
					zmaxMiniHeight = env.params.visualbtnscarrousel["next-mini"]["height"];
				}
				if(env.params.visualbtnscarrousel["next-mini"]["height"] > tmaxMiniHeight){
					tmaxMiniHeight = env.params.visualbtnscarrousel["next-mini"]["height"];
				}
			}

			if(env.params.visualbtnscarrousel["prev-mini"] != "null"){

				// Width
				if((env.params.visualbtnscarrousel["prev-mini"]["width"]) > tmaxMiniWidth){
					tmaxMiniWidth = env.params.visualbtnscarrousel["prev-mini"]["width"];
				}
				if(env.params.visualbtnscarrousel["prev-mini"]["width"] > zmaxMiniWidth){
					zmaxMiniWidth = env.params.visualbtnscarrousel["prev-mini"]["width"];
				}

				// Height
				if(env.params.visualbtnscarrousel["prev-mini"]["height"] > zmaxMiniHeight){
					zmaxMiniHeight = env.params.visualbtnscarrousel["prev-mini"]["height"];
				}
				if(env.params.visualbtnscarrousel["prev-mini"]["height"] > tmaxMiniHeight){
					tmaxMiniHeight = env.params.visualbtnscarrousel["prev-mini"]["height"];
				}
			}
		}


		// Resize all li.mini (our miniatures)
		env.$elts.miniwrap.find('.mini-carrousel').children().each(function(index){
			$(this).removeClass('hidden');
			$(this).css('width', (maxMiniatureWidth)).css('height', (maxMiniatureHeight));
		});

		// Generate our CSS for Horizontal or Vertical display
		switch(env.params.direction)
		{
			// Horizontal display
			case 'horizontal':

				// Block's styles
				env.$elts.miniwrap.css('height', zmaxMiniHeight).addClass('horizontal');

				// Horizontal class
				env.$elts.wrap.css('margin-bottom', '4px');
				env.$elts.carrouselnavigation.parent().css('width',(env.params.carouselWidth * env.params.dispItems) + (tmaxMiniWidth*2));				
				env.$elts.miniatures.css('width', env.minioptions.nbVisuelsPerPage * env.miniatureWidth).css('height', maxMiniatureHeight).css('overflow', 'hidden');
				env.$elts.minicarrousel.css('width', env.steps.count * env.miniatureWidth).css('height', maxMiniatureHeight);
				env.$elts.minicarrousel.children().css('margin-right', (env.params.miniaturesMargin/2)).css('margin-left', (env.params.miniaturesMargin/2));

				// Button's Styles
				env.$elts.miniBtnPreced.addClass('horizontal').css('height', zmaxMiniHeight).css('width', tmaxMiniWidth).css('background-position', 'right center');
				env.$elts.miniBtnNext.addClass('horizontal').css('height', zmaxMiniHeight).css('width', tmaxMiniWidth).css('background-position', 'left center');

				// Adjust marge to center miniatures with our buttons
				if(env.minioptions.nbPages > 1) {
					newMarge = (((env.$elts.miniwrap.outerWidth() - (tmaxMiniWidth*2)) - (env.$elts.miniwrap.find('.miniatures').outerWidth()))/2 );
					newMargeTop = (zmaxMiniHeight - maxMiniatureHeight) / 2
				}
				else {
					newMarge = (((env.$elts.miniwrap.outerWidth()) - (env.$elts.minicarrousel.outerWidth()))/2);
					newMargeTop = 0;
				}

				env.$elts.miniatures.css('margin-left', newMarge).css('margin-top', newMargeTop);

			break;


			// Vertical display
			case 'vertical':
				// Load good styles
				env.$elts.miniwrap.addClass('vertical');

				// Block's styles
				env.$elts.wrap.addClass('vertical').css('margin-top', tmaxMiniHeight);
				env.$elts.miniwrap.css('width', zmaxMiniWidth);
				env.$elts.carrouselnavigation.parent().css('height', (env.params.carouselHeight * env.params.dispItems) + (tmaxMiniHeight*2));
				env.$elts.miniwrap.css('height', env.$elts.wrap.outerHeight());

				// Vertical class
				env.$elts.wrap.css('margin-right', '4px');
				env.$elts.carrouselnavigation.parent().css('width',(env.params.carouselWidth +4) + zmaxMiniWidth);
				env.$elts.miniatures.css('width', maxMiniatureWidth).css('height', env.miniatureHeight * env.minioptions.nbVisuelsPerPage).css('overflow', 'hidden');
				env.$elts.minicarrousel.css('width', maxMiniatureWidth).css('height', maxMiniatureHeight * env.steps.count);
				env.$elts.minicarrousel.children().css('margin-bottom', (env.params.miniaturesMargin/2)).css('margin-top', (env.params.miniaturesMargin/2));

				// Button's Styles
				env.$elts.miniBtnPreced.css('width',zmaxMiniWidth).addClass('vertical').css('height', tmaxMiniHeight).css('background-position', 'center bottom');
				env.$elts.miniBtnNext.css('width',zmaxMiniWidth).addClass('vertical').css('height', tmaxMiniHeight).css('background-position', 'center top');

				if (env.minioptions.nbPages <= 1) {
					env.$elts.miniwrap.css('margin-top', '10px');
				}

				// Adjust marge to center miniatures with our buttons
				newMarge = (env.$elts.carrouselnavigation.outerHeight() - env.$elts.miniatures.outerHeight())/2;
				newMargeLeft = ((zmaxMiniWidth - maxMiniatureWidth)/2);
				env.$elts.miniatures.css('margin-top', newMarge).css('margin-bottom', newMarge).css('margin-left', newMargeLeft);

			break;

		}


		// EVENTS LIST:

		// Init
		env.params.page = 0;

		// Btn Next
		env.$elts.miniBtnNext.bind('click', function(){
			if(env.params.page < env.minioptions.nbPages-1) {
				env.params.page++;
				env.params.activeRelativePageMiniatures = false;
		        miniAnimate(env, env.params.page, env.params.direction);
			}
		});

		// Btn Preced
		env.$elts.miniBtnPreced.bind('click', function(){
			if(env.params.page > 0){
				env.params.page--;
				env.params.activeRelativePageMiniatures = false;
				miniAnimate(env, env.params.page, env.params.direction);
			}
		});

		// Events (click miniatures)
		env.$elts.miniwrap.find('.mini-carrousel').children().each(function(i){
	        $(this).click(function(){
				goToStep(env, i);
				stopAutoSlide(env);
	        });
	    });


	}

	// Miniatures animations
	function miniAnimate(env, mPAGE, mORIENTATION)
	{
		
		switch(mORIENTATION)
		{
			case 'vertical':
				env.$elts.minicarrousel.animate({ 
		            marginTop : - (env.miniatureHeight * mPAGE * env.minioptions.nbVisuelsPerPage) 
		        }); 
			break;
		
			
			case 'horizontal':
				env.$elts.minicarrousel.animate({ 
		            marginLeft : - (env.miniatureWidth * mPAGE * env.minioptions.nbVisuelsPerPage) 
		        }); 
			break;
		}

	}



	// Address plugin
	function initAddress(env) {

		if (env.params.useAddress && $.isFunction($.fn.address)) {

			$.address
				.init(function(e) {
					var pathNames = $.address.pathNames();
					if (pathNames[0] === env.params.adressIdentifier && !!pathNames[1]) {
						goToStep(env, pathNames[1]-1);
					} else {
						$.address.value('/'+ env.params.adressIdentifier +'/1');
					}
				})
				.change(function(e) {
					var pathNames = $.address.pathNames();
					if (pathNames[0] === env.params.adressIdentifier && !!pathNames[1]) {
						goToStep(env, pathNames[1]-1);
					}
				});
		} else {
			env.params.useAddress = false;
		}
	};

	function goToStep(env, step) {

		// Callback
		env.params.callback(step);

		// Launch animation
		transition(env, step);

		// Update first step
		env.steps.first = step;

		// Update buttons status
		updateButtonsState(env);

		// Update address (jQuery Address plugin)
		if ( env.params.useAddress ) {
			$.address.value('/'+ env.params.adressIdentifier +'/' + (step + 1));
		}

	};

	// Get next/prev step, useful for autoSlide
	function getRelativeStep(env, position) {
		if (position == "prev") {

			if ( (env.steps.first - env.params.dispItems) >= 0 ) {
				return env.steps.first - env.params.dispItems;

			} else {

				if(env.steps.first > 0)
				{
					return 0;
				}
				else {
					return ( (env.params.loop)? (env.steps.count - env.params.dispItems) : false );
				}
			}

		} else if (position == "next") {

			if ( (env.steps.first - -env.params.dispItems) < env.steps.count ) {
				return env.steps.first - -env.params.dispItems;

			} else {
				return ( (env.params.loop)? 0 : false );
			}
		}
	};

	// Animation
	function transition(env, step) {
			// Effect
			switch (env.params.effect){

				// No effect
				case "no":
					if (env.params.direction == "vertical"){
						env.$elts.content.css("top", -(env.itemHeight * step) + "px");
					} else {
						env.$elts.content.css("left", -(env.itemWidth * step) + "px");
					}
				break;

				// Fade effect
				case "fade":
					if (env.params.direction == "vertical"){
						env.$elts.content.stop(true, true).fadeOut('slow', function () {
							env.$elts.content.css("top", -(env.itemHeight * step) + "px")}).fadeIn('slow');
					} else {
						env.$elts.content.stop(true, true).fadeOut('slow', function () {
							env.$elts.content.css("left", -(env.itemWidth * step) + "px")}).fadeIn('slow');

					}
				break;

				// Flash
				case "flash":
					if (env.params.direction == "vertical"){
						env.$elts.content.hide().css("top", -(env.itemHeight * step) + "px").fadeIn(env.params.animSpeed);
					} else {
						env.$elts.content.hide().css("left", -(env.itemWidth * step) + "px").fadeIn(env.params.animSpeed);
					}
				break;


				// Easing effect
				default:

					// Define parameters
					if(env.params.effect != "slide"){
						env.params.slideEasing = env.params.effect;
						env.params.animSpeed = 1000;
					}

					// Animation
					if (env.params.direction == "vertical"){
						if(step < env.steps.first){
							env.$elts.content.stop().animate({top : -(env.itemHeight * step)}, {duration:env.params.animSpeed, easing:env.params.slideEasing});
						}
						else {
							env.$elts.content.stop().animate({top : -(env.itemHeight * step)}, {duration:env.params.animSpeed, easing:env.params.slideEasing});
						}
					} else {
						if(step < env.steps.first){
							env.$elts.content.stop().animate({left : -(env.itemWidth * step)}, {duration:env.params.animSpeed, easing:env.params.slideEasing});
						}
						else {
							env.$elts.content.stop().animate({left : -(env.itemWidth * step)}, {duration:env.params.animSpeed, easing:env.params.slideEasing});
						}
					}
				break;
			}
	};

	// Update all buttons state : disabled or not
	function updateButtonsState(env){

		if (getRelativeStep(env, "prev") !== false) {
			env.$elts.prevBtn.trigger("enable");

		} else {
				env.$elts.prevBtn.trigger("disable");
		}

		if (getRelativeStep(env, "next") !== false) {
			env.$elts.nextBtn.trigger("enable");

		} else {
			env.$elts.nextBtn.trigger("disable");
		}

		if (env.params.pagination){
			env.$elts.paginationBtns.removeClass("active")
			.filter(function(){ return ($(this).data("firstStep") == env.steps.first) }).addClass("active");
		}
	};

	// Play autoslide
	function playAutoSlide(env) {

		env.interval = window.setInterval(function(){

			// AutoStop
			if(!env.params.loop){
				if((getRelativeStep(env, "next") +parseInt(env.params.dispItems)) >= env.steps.count){
					stopAutoSlide(env);
				}
			}

			// Go to next pellicule
			goToStep( env, getRelativeStep(env, "next") );

			// Update Miniatures Page
			if(env.params.activeRelativePageMiniatures == true){
				getRelativePageOfMiniatures(env);
			}

		}, env.params.autoSlideInterval);

		// load custom buttons
		if(env.params.btnAutoSlide) {
			env.$elts.btnAutoSlide.addClass('playing');
			loadCustomControlBtns(env, 'playing');
		}
	}

	// Stop autoslide
	function stopAutoSlide(env) {

		// ClearInterval
		if (!!env.interval){
			window.clearInterval(env.interval);
		}

		// load custom buttons
		if(env.params.btnAutoSlide) {
			env.$elts.btnAutoSlide.removeClass('playing');
			loadCustomControlBtns(env, 'stop');
		}
	}


	function miniCarouselOptions(env)
	{
		// Calcul
		if (env.params.direction == "vertical")
		{
			var nbvisuels = Math.round((env.$elts.wrap.outerHeight()/(env.$elts.miniwrap.find(".mini-carrousel").children().length*env.miniatureHeight)) * env.$elts.miniwrap.find(".mini-carrousel").children().length);
		}
		else
		{
			var nbvisuels = Math.round((env.$elts.wrap.outerWidth()/(env.$elts.miniwrap.find(".mini-carrousel").children().length*env.miniatureWidth)) * env.$elts.miniwrap.find(".mini-carrousel").children().length);
		}

		nbvisuels--;
		if(nbvisuels < 1)
		{
			nbvisuels = 1;
		}
		if(nbvisuels > env.steps.count)
		{
			nbvisuels = env.steps.count;
		}

		var pages = Math.ceil(env.steps.count/nbvisuels);
		var position = env.$elts.miniwrap.find(".miniatures");


		// Get data
		var optionsObject = {
			nbVisuelsPerPage: nbvisuels,
			nbPages: pages,
			btnPosition: position
		};

		// Return
		return optionsObject;

	}

	function getPositionOfAutoSlideBtn(env, AutoSlidePosition)
	{
		// Define
		var K_IMGWIDTH = env.$elts.btnAutoSlide.outerWidth();
		var K_IMGHEIGHT = env.$elts.btnAutoSlide.outerHeight();
		var K_SPACE = 5;

		switch (AutoSlidePosition)
		{
			case 'top-right':
				var vLeft = (env.$elts.wrap.outerWidth() - (K_IMGWIDTH + K_SPACE));
				var vTop = K_SPACE;
			break;

			case 'top-left':
				var vLeft = K_SPACE;
				var vTop = K_SPACE;
			break;

			case 'bottom-right':
				var vLeft = (env.$elts.wrap.outerWidth() - (K_IMGWIDTH + K_SPACE));
				var vTop = (env.$elts.wrap.outerHeight() - (K_IMGHEIGHT + K_SPACE));
			break;

			case 'bottom-left':
				var vLeft = K_SPACE;
				var vTop = (env.$elts.wrap.outerHeight() - (K_IMGHEIGHT + K_SPACE));
			break;

		}

		// apply
		env.$elts.btnAutoSlide.css('left', vLeft).css('top', vTop);

	}

	function initBtnAutoSlide(env)
	{
		// Init
		env.$elts.btnAutoSlide = env.$elts.wrap.append('<span class="btnAutoSlide"> </span>');
		env.$elts.btnAutoSlide = env.$elts.wrap.find('.btnAutoSlide');

		// addClass
		if(env.params.autoSlide) {
			env.$elts.btnAutoSlide.addClass('playing');
		}

		loadCustomControlBtns(env);

		// Events click
		env.$elts.btnAutoSlide.bind('click', function(){

			// Small effect
			env.$elts.btnAutoSlide.stop(true, true).fadeOut(400);

			// Desactive
			if(env.$elts.btnAutoSlide.hasClass('playing')) {
				stopAutoSlide(env);
			}

			// Active
			else {
				env.params.activeRelativePageMiniatures = true;
				playAutoSlide(env);
			}

			env.$elts.btnAutoSlide.fadeIn(400);
		});
	}



	function getRelativePageOfMiniatures(env)
	{
		// Get relative page of miniatures
		if(env.params.miniatures)
		{
			if(env.minioptions.nbPages > 1)
			{
				actualPage = env.steps.first +1;
				if(actualPage <= ((env.params.page+1) * env.minioptions.nbVisuelsPerPage) && actualPage > ((env.params.page) * env.minioptions.nbVisuelsPerPage))
				{
					PageBoolean = true;
				}
				else
				{
					PageBoolean = false;
					pageToGo = 1;
					while(PageBoolean == false)
					{
						if(((env.minioptions.nbVisuelsPerPage * pageToGo) / actualPage) >= 1) {
							env.params.page = pageToGo-1;
							miniAnimate(env, pageToGo-1, env.params.direction);
							pageToGo = 1;
							PageBoolean = true;
						}

						else {
							pageToGo++;
						}
					}
				}
			}
		}
	}

	function loadCustomControlBtns(env, btnType)
	{
		if(!btnType){
			className = env.$elts.btnAutoSlide.attr('class').split(' ');
			 btnType = className[1];
		}

		switch(btnType)
		{
			case 'playing':
				if(env.params.visualbtnscarrousel["stop"] != "null") {
					env.$elts.btnAutoSlide.css('background-image', 'url('+ env.params.visualbtnscarrousel["stop"]["url"] + ')').css('width', env.params.visualbtnscarrousel["stop"]["width"]).css('height', env.params.visualbtnscarrousel["stop"]["height"]);
				}
				else {
					removeCssOfElement(env, env.$elts.btnAutoSlide, ['background-image', 'width', 'height']);
				}
			break;


			default:
				if(env.params.visualbtnscarrousel["play"] != "null") {
					env.$elts.btnAutoSlide.css('background-image', 'url('+ env.params.visualbtnscarrousel["play"]["url"] + ')').css('width', env.params.visualbtnscarrousel["play"]["width"]).css('height', env.params.visualbtnscarrousel["play"]["height"]);
				}
				else {
					removeCssOfElement(env, env.$elts.btnAutoSlide, ['background-image', 'width', 'height']);
				}
			break;

		}

		// Apply position
		getPositionOfAutoSlideBtn(env, env.params.btnAutoSlidePosition);

	}


	function removeCssOfElement(env, element, css)
	{
		for (var i in css){
			element.css(css[i], '');
		}
	}


})(jQuery);


