/**
 * main.js
 *
 * scripts js nécessaires sur toutes les pages
 * @author collomb
 * @version 1.0
 */

var DEVEL_BOX = window.location.hostname.indexOf(".com") == -1;

$(document).ready(onDocumentReadyMain);
/*
 * Trace un message (dans la console s'il y en a une, sinon en utilisant alert)
 */
function trace(msg) {
	if (DEVEL_BOX) {
		console.log(msg);
	}
}

/**
 * Créé une closure
 * @param <object> object   le contexte d'exécution (le plus souvent this)
 * @param <function> method la méthode à lier au contexte
 */
function bindMethod(object, method) {
    return function() {
        return method.apply(object, arguments);
    }
}

/**
 * Effectue un appel cross-domain. Méthode permettant de passer outre la limite de domaine des appel ajax
 */
function xDomainCall(url)
{
  var tag = document.createElement('script');
  tag.id = new Date().getTime(); // genere un id unique
  tag.language="javascript";
  tag.src = url + '&ScriptID=' + tag.id;
  tag.type = 'text/javascript';
  document.body.appendChild(tag);
}

/**
 * Supprime une balise <script> du dom
 */
function removeScriptTag(scriptID)
{
	if (scriptID && (scriptID != '')) {
		$("#" + scriptID).remove();
	}
}

/**
 * Evènement exécuté lorsque la page est chargée
 */
function onDocumentReadyMain() {
	var ie6 = document.all && !window.opera && !window.XMLHttpRequest && $.browser.msie;//$.browser.msie && /6.0/.test(navigator.userAgent);
	$.browser.ie6 = ie6;

	// animation du menu principal
	$("#mainMenuWebtopLink").hover(function(){this.src='resources/pictures/menu/webtop-hover.gif'}, function(){this.src='resources/pictures/menu/webtop.gif'});
	$('li.mainMenu').hover(onMainMenuItemOver, onMainMenuItemOut);

	// formulaire d'identification
	$("#iLogin").inputLabel("nom d'utilisateur");
	$("#iPassword").inputLabel("azerty");

	// fil d'ariane
	$("#breadCrumb").jBreadCrumb();

	//évènements
	$("a.jAskConfirmation").click(onAskConfirmationClick);
	$("a.jxDomainCall").click(onXDomainCallClick);
	$("a.jAskConfirmationAndXDomainCall").click(onAskConfirmationAndXDomainCall);
    
	$(".jExpandable .jExpandButton").click(onExpandButtonClick);
	$(".jExpandable .jExpandTitle").click(onExpandTitleClick);
	$(".jClosable .jCloseButton").click(onCloseButtonClick);

	// modification des liens en target=_blank afin de rester valid XHTML
	$("a.targetBlank").attr("target", "_blank");
	
	// lien a servant de bouton submit sur les formulaires
	$("jSubmit").click(function(){
		$(this).parents('form:first').submit();
		return false;
	});

	// tableau sortable
	$("table.jSortable").each(function(){
		$(this).addClass("sortable");
		if ($(this).hasClass('jFixedHeightBody')) {
			var baseId = $(this).attr('id').split('_')[0];
			$(this).tablesorter({widgets:["zebra"],headerId:baseId+'_header'});
			$(this).find("tbody tr td").mouseover(function(){$(this).parent().addClass('trhover');});
			$(this).find("tbody tr td").mouseout(function() {$(this).parent().removeClass('trhover');});
		} else if (!$(this).hasClass('jFixedHeightHeader')) {
			$(this).tablesorter({widgets:["zebra"]});
			$(this).find("tbody tr td").mouseover(function(){$(this).parent().addClass('trhover');});
			$(this).find("tbody tr td").mouseout(function() {$(this).parent().removeClass('trhover');});
		}
	});

	// ckeditor
	if(typeof(CKEDITOR) != "undefined")
	{
		CKEDITOR.replaceAll( function(textarea, config) {
			config.resize_enabled = false;
			config.emailProtection = 'encode';
			config.removePlugins = 'elementspath';
			if ($(textarea).hasClass('ckeditorBig')) {
				config.height = '30em';
				return true;
			}
			if ($(textarea).hasClass('ckeditorSmall')) {
				return true;
			}
			if ($(textarea).hasClass('ckeditorSmallNoToolbars')) {
				config.height = '8em';
				config.toolbarStartupExpanded = false;
				return true;
			}
			return false;
		});
	}

	/*$("#ArtNewSubCategorie").keypress(function(){
		$("#SubCat").removeClass("dateTimeError");
		$("#ArtSubCategoriesList").html('<option value="-1"></option>');
	}).change(function(){
		$("#SubCat").removeClass("dateTimeError");
		$("#ArtSubCategoriesList").html('<option value="-1"></option>');
	});*/
}
/** Permet de savoir si une animation est en cours sur les éléments du menu */
var animInProgress = false;

/**
 * Evènement lorsque le pointeur entre sur un élément du menu
 */
function onMainMenuItemOver() {
	if (animInProgress) {
		$(this).find('ul').css('display', 'block');
	} else {
		animInProgress = true;
		$(this).find('ul').css('display', 'block').fadeIn('fast', bindMethod(this, onMainMenuAnimationEnded));
	}
}

/**
 * Evènement lorsqu'une animation du menu se termine
 */
function onMainMenuAnimationEnded() {
	animInProgress = false;
	if ($.browser.msie) {
		this.style.removeAttribute('filter');
	}
}

/**
 * Evènement lorsque le pointeur soirt d'un élément du menu
 */
function onMainMenuItemOut() {
	$(this).find('ul').fadeOut('fast');
}

/**
* Fonction générique pour onAskConfirmationClick et onAskConfirmationAndXDomainCall
*/
function askConfirmation(event, $elt, xdc) {
	var message = $elt.text();
	if (message == '') {
		message = $elt.attr('title') + ' ?';
	} else {
		message += ' ?' + (($elt.attr('title') != '') ? ('\n(' + $elt.attr('title') + ')') : '');
	}

	jConfirm(message, 'Confirmation', function(r) {if (r) {if (xdc) xDomainCall($elt.attr('href')); else document.location.href = $elt.attr('href');}});
	event.preventDefault();
	event.stopPropagation();
	return false;
}

/**
 * Demande confirmation lors du click sur un lien ayant la classe jAskConfirmation
 */
function onAskConfirmationClick(event) {
	return askConfirmation(event, $(this), false);
}

/**
* Demande confirmation lors du click sur un lien cross domain call ayant la classe jAskConfirmationAndXDomainCall
*/
function onAskConfirmationAndXDomainCall(event) {
	return askConfirmation(event, $(this), true);
}

/**
 * Effectue un appel cross-domain sur un lien ayant la classe jXDomainCall
 */
function onXDomainCallClick(event) {
	xDomainCall(this.href);
	event.preventDefault();
	return false;
}

/**
 * Annule l'action d'un lien ayant la classe guest
 */
function onGuestClick(event) {
	alert("Votre statut d'invité ne vous permet pas de réaliser cette action.");
	event.preventDefault();
	return false;
}

/**
 * Réduit ou étend une fenêtre ayant la classe jExpandable
 */
function onExpandTitleClick() {	
	$(this).parent().find('.jExpandButton').toggleClass('jMinimized').parents('.jExpandable').find('.jExpandableContent').slideToggle('fast');
}
function onExpandButtonClick() {
	$(this).toggleClass('jMinimized').parents('.jExpandable').find('.jExpandableContent').slideToggle('fast');
}

/**
 * Ferme une fenêtre ayant la classe jClosable
 */
function onCloseButtonClick() {
	$(this).parents('.jClosable').remove();
}

// Modification des fonction fade* de jQuery afin de rétablir l'antialiasing en fin d'animation - http://malsup.com/jquery/fadetest.html
jQuery.fn.fadeIn = function(speed, callback) {return this.animate({opacity: 'show'}, speed, function() {if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); });};
jQuery.fn.fadeOut = function(speed, callback) {return this.animate({opacity: 'hide'}, speed, function() {if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback();});};
jQuery.fn.fadeTo = function(speed,to,callback) {return this.animate({opacity: to}, speed, function() {if (to == 1 && jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback();});};

// jQuery Initial input value replacer - http://plugins.jquery.com/project/inputLabel
(function(jQuery){jQuery.fn.inputLabel=function(text,opts){o=jQuery.extend({color:"#999",e:"focus",force:false,keep:true},opts||{});var clearInput=function(e){var target=jQuery(e.target);var value=jQuery.trim(target.val());if(e.type==e.data.obj.e&&value==e.data.obj.innerText){jQuery(target).css("color","").val("");if(!e.data.obj.keep){jQuery(target).unbind(e.data.obj.e+" blur",clearInput);}}else if(e.type=="blur"&&value==""&&e.data.obj.keep){jQuery(this).css("color",e.data.obj.color).val(e.data.obj.innerText);}};return this.each(function(){o.innerText=(text||false);if(!o.innerText){var id=jQuery(this).attr("id");o.innerText=jQuery(this).parents("form").find("label[for="+id+"]").hide().text();} else if(typeof o.innerText!="string"){o.innerText=jQuery(o.innerText).text();} o.innerText=jQuery.trim(o.innerText);if(o.force||jQuery(this).val()==""){jQuery(this).css("color",o.color).val(o.innerText);} jQuery(this).bind(o.e+" blur",{obj:o},clearInput);});};})(jQuery);

// idTabs - Sean Catchpole - Version 2.2 - MIT/GPL http://www.sunsean.com/idTabs/
(function(){var dep={"jQuery":"http://code.jquery.com/jquery-latest.min.js"};var init=function(){(function($){$.fn.idTabs=function(){var s={};for(var i=0;i<arguments.length;++i){var a=arguments[i];switch(a.constructor){case Object:$.extend(s,a);break;case Boolean:s.change=a;break;case Number:s.start=a;break;case Function:s.click=a;break;case String:if(a.charAt(0)=='.')s.selected=a;else if(a.charAt(0)=='!')s.event=a;else s.start=a;break;}}
if(typeof s['return']=="function")
s.change=s['return'];return this.each(function(){$.idTabs(this,s);});}
$.idTabs=function(tabs,options){var meta=($.metadata)?$(tabs).metadata():{};var s=$.extend({},$.idTabs.settings,meta,options);if(s.selected.charAt(0)=='.')s.selected=s.selected.substr(1);if(s.event.charAt(0)=='!')s.event=s.event.substr(1);if(s.start==null)s.start=-1;var showId=function(){if($(this).is('.'+s.selected))
return s.change;var id="#"+this.href.split('#')[1];var aList=[];var idList=[];$("a",tabs).each(function(){if(this.href.match(/#/)){aList.push(this);idList.push("#"+this.href.split('#')[1]);}});if(s.click&&!s.click.apply(this,[id,idList,tabs,s]))return s.change;for(i in aList)$(aList[i]).removeClass(s.selected);for(i in idList)$(idList[i]).hide();$(this).addClass(s.selected);$(id).show();return s.change;}
var list=$("a[href*='#']",tabs).unbind(s.event,showId).bind(s.event,showId);list.each(function(){$("#"+this.href.split('#')[1]).hide();});var test=false;if((test=list.filter('.'+s.selected)).length);else if(typeof s.start=="number"&&(test=list.eq(s.start)).length);else if(typeof s.start=="string"&&(test=list.filter("[href*='#"+s.start+"']")).length);if(test){test.removeClass(s.selected);test.trigger(s.event);}
return s;}
$.idTabs.settings={start:0,change:false,click:null,selected:".selected",event:"!click"};$.idTabs.version="2.2";$(function(){$(".idTabs").idTabs();});})(jQuery);}
var check=function(o,s){s=s.split('.');while(o&&s.length)o=o[s.shift()];return o;}
var head=document.getElementsByTagName("head")[0];var add=function(url){var s=document.createElement("script");s.type="text/javascript";s.src=url;head.appendChild(s);}
var s=document.getElementsByTagName('script');var src=s[s.length-1].src;var ok=true;for(d in dep){if(check(this,d))continue;ok=false;add(dep[d]);}if(ok)return init();add(src);})();

//jQuery Alert Dialogs Plugin - http://abeautifulsite.net/notebook/87
(function($){$.alerts={verticalOffset:-75,horizontalOffset:0,repositionOnResize:true,overlayOpacity:.50,overlayColor:'#FFF',draggable:true,okButton:'&nbsp;OK&nbsp;',cancelButton:'&nbsp;Annuler&nbsp;',dialogClass:null,alert:function(message,title,callback){if(title==null)title='Alerte';$.alerts._show(title,message,null,'alert',function(result){if(callback)callback(result);});},confirm:function(message,title,callback){if(title==null)title='Confirmation';$.alerts._show(title,message,null,'confirm',function(result){if(callback)callback(result);});},prompt:function(message,value,title,callback){if(title==null)title='Entrée';$.alerts._show(title,message,value,'prompt',function(result){if(callback)callback(result);});},_show:function(title,msg,value,type,callback){$.alerts._hide();$.alerts._overlay('show');$("BODY").append('<div id="popup_container">'+'<h1 id="popup_title"></h1>'+'<div id="popup_content">'+'<div id="popup_message"></div>'+'</div>'+'</div>');if($.alerts.dialogClass)$("#popup_container").addClass($.alerts.dialogClass);var pos=($.browser.msie&&parseInt($.browser.version)<=6)?'absolute':'fixed';$("#popup_container").css({position:pos,zIndex:99999,padding:0,margin:0});$("#popup_title").text(title);$("#popup_content").addClass(type);$("#popup_message").text(msg);$("#popup_message").html($("#popup_message").text().replace(/\n/g,'<br />'));$("#popup_container").css({minWidth:$("#popup_container").outerWidth(),maxWidth:$("#popup_container").outerWidth()});$.alerts._reposition();$.alerts._maintainPosition(true);switch(type){case'alert':$("#popup_message").after('<div id="popup_panel"><input type="button" value="'+$.alerts.okButton+'" id="popup_ok" /></div>');$("#popup_ok").click(function(){$.alerts._hide();callback(true);});$("#popup_ok").focus().keypress(function(e){if(e.keyCode==13||e.keyCode==27)$("#popup_ok").trigger('click');});break;case'confirm':$("#popup_message").after('<div id="popup_panel"><input type="button" value="'+$.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+$.alerts.cancelButton+'" id="popup_cancel" /></div>');$("#popup_ok").click(function(){$.alerts._hide();if(callback)callback(true);});$("#popup_cancel").click(function(){$.alerts._hide();if(callback)callback(false);});$("#popup_ok").focus();$("#popup_ok, #popup_cancel").keypress(function(e){if(e.keyCode==13)$("#popup_ok").trigger('click');if(e.keyCode==27)$("#popup_cancel").trigger('click');});break;case'prompt':$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="'+$.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+$.alerts.cancelButton+'" id="popup_cancel" /></div>');$("#popup_prompt").width($("#popup_message").width());$("#popup_ok").click(function(){var val=$("#popup_prompt").val();$.alerts._hide();if(callback)callback(val);});$("#popup_cancel").click(function(){$.alerts._hide();if(callback)callback(null);});$("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(e){if(e.keyCode==13)$("#popup_ok").trigger('click');if(e.keyCode==27)$("#popup_cancel").trigger('click');});if(value)$("#popup_prompt").val(value);$("#popup_prompt").focus().select();break;}
if($.alerts.draggable){try{$("#popup_container").draggable({handle:$("#popup_title")});$("#popup_title").css({cursor:'move'});}catch(e){}}},_hide:function(){$("#popup_container").remove();$.alerts._overlay('hide');$.alerts._maintainPosition(false);},_overlay:function(status){switch(status){case'show':$.alerts._overlay('hide');$("BODY").append('<div id="popup_overlay"></div>');$("#popup_overlay").css({position:'absolute',zIndex:99998,top:'0px',left:'0px',width:'100%',height:$(document).height(),background:$.alerts.overlayColor,opacity:$.alerts.overlayOpacity});break;case'hide':$("#popup_overlay").remove();break;}},_reposition:function(){var top=(($(window).height()/2)-($("#popup_container").outerHeight()/2))+$.alerts.verticalOffset;var left=(($(window).width()/2)-($("#popup_container").outerWidth()/2))+$.alerts.horizontalOffset;if(top<0)top=0;if(left<0)left=0;if($.browser.msie&&parseInt($.browser.version)<=6)top=top+$(window).scrollTop();$("#popup_container").css({top:top+'px',left:left+'px'});$("#popup_overlay").height($(document).height());},_maintainPosition:function(status){if($.alerts.repositionOnResize){switch(status){case true:$(window).bind('resize',function(){$.alerts._reposition();});break;case false:$(window).unbind('resize');break;}}}}
jAlert=function(message,title,callback){$.alerts.alert(message,title,callback);}
jConfirm=function(message,title,callback){$.alerts.confirm(message,title,callback);};jPrompt=function(message,value,title,callback){$.alerts.prompt(message,value,title,callback);};})(jQuery);

// Table sorter 2.0.3  http://tablesorter.com/docs/
(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}
this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}
function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}
var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,cells[i]);}
if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}
return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}return parsers[0];}
function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}
function buildCache(table){if(table.config.debug){var cacheTime=new Date();}
var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}
cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}
return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}return t;}
function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}
var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}
if(table.config.appender){table.config.appender(table,rows);}
rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}
applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}
var meta=($.metadata)?true:false;if(table.config.headerId) $tableHeaders=$("#"+table.config.headerId+" thead th");else
$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}
table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}
return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}
return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}
function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}
function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}
function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}return i;}
function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}
function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}
function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}
function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}
function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}
var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}
var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}
dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}
return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if((!this.tHead&&!settings.headerId)||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};
config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);
$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}
config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});
$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);
setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}
if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}
applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}
if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';
return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}
empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"url",
is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});
ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",
is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;
return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}
$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
//Metadata - jQuery plugin for parsing metadata from elements
(function($){$.extend({metadata:{defaults:{type:'class',name:'metadata',cre:/({.*})/,single:'metadata'},setType:function(type,name){this.defaults.type=type;this.defaults.name=name;},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length)settings.single='metadata';var data=$.data(elem,settings.single);if(data)return data;data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m)
data=m[1];}else if(settings.type=="elem"){if(!elem.getElementsByTagName) return undefined;var e=elem.getElementsByTagName(settings.name);if(e.length) data=$.trim(e[0].innerHTML);}else if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr) data=attr;}
if(data.indexOf('{')<0) data="{"+data+"}";data=eval("("+data+")");$.data(elem,settings.single,data);return data;}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts);};})(jQuery);
// parser ajouté par m.c.
$.tablesorter.addParser({id: 'filesize', is: function(s) {return false;}, format: function(s) {
	var sp = s.split(new RegExp("[ ]+", "g"));
	if (sp.length == 2)
	{
		var size = parseInt(sp[0]);
		sp[1] = sp[1].toLowerCase();
		if (sp[1] == 'ko') size *= 1000;
		else if (sp[1] == 'mo') size *= 1000000;
		return size;
	} else return 0;
}, type: 'numeric'});
$.tablesorter.addParser({
	id: 'datetimeFR',
	is: function(s) {
		return  /^\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\s\d{1,2}[h:]\d{1,2}$/.test(s);
	},
	format: function(s) {
		if (s.length < 10)
			return $.tablesorter.formatFloat("0");

		var elts = s.split(new RegExp("[\/-]+", "g"));

		if (elts.length != 3)
			return $.tablesorter.formatFloat("0");

		var formatedDate = elts[1] + '/' + elts[0] + '/' + elts[2].replace(/h/,':') + ':00';
		return $.tablesorter.formatFloat(new Date(formatedDate).getTime());
	},
	type: 'numeric'});
$.tablesorter.addParser({
	id: 'dateFR',
	is: function(s) {
		return  /^\d{1,2}[\/-]\d{1,2}[\/-]\d{4}$/.test(s);
	},
	format: function(s) {
		var elts = s.split(new RegExp("[\/-]+", "g"));
		var formatedDate = elts[1] + '/' + elts[0] + '/' + elts[2];
		return $.tablesorter.formatFloat((s != "") ? new Date(formatedDate).getTime() : "0");
	},
	type: 'numeric'});

// jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(a,b,c,d,e){return jQuery.easing[jQuery.easing.def](a,b,c,d,e)},easeInQuad:function(a,b,c,d,e){return d*(b/=e)*b+c},easeOutQuad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c},easeInOutQuad:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b+c;return-d/2*((--b)*(b-2)-1)+c},easeInCubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeOutCubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeInOutCubic:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b+c;return d/2*((b-=2)*b*b+2)+c},easeInQuart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c},easeOutQuart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeInOutQuart:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b+c;return-d/2*((b-=2)*b*b*b-2)+c},easeInQuint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeOutQuint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeInOutQuint:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b*b+c;return d/2*((b-=2)*b*b*b*b+2)+c},easeInSine:function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c},easeOutSine:function(a,b,c,d,e){return d*Math.sin(b/e*(Math.PI/2))+c},easeInOutSine:function(a,b,c,d,e){return-d/2*(Math.cos(Math.PI*b/e)-1)+c},easeInExpo:function(a,b,c,d,e){return(b==0)?c:d*Math.pow(2,10*(b/e-1))+c},easeOutExpo:function(a,b,c,d,e){return(b==e)?c+d:d*(-Math.pow(2,-10*b/e)+1)+c},easeInOutExpo:function(a,b,c,d,e){if(b==0)return c;if(b==e)return c+d;if((b/=e/2)<1)return d/2*Math.pow(2,10*(b-1))+c;return d/2*(-Math.pow(2,-10*--b)+2)+c},easeInCirc:function(a,b,c,d,e){return-d*(Math.sqrt(1-(b/=e)*b)-1)+c},easeOutCirc:function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)*b)+c},easeInOutCirc:function(a,b,c,d,e){if((b/=e/2)<1)return-d/2*(Math.sqrt(1-b*b)-1)+c;return d/2*(Math.sqrt(1-(b-=2)*b)+1)+c},easeInElastic:function(a,b,c,d,e){var f=1.70158;var g=0;var h=d;if(b==0)return c;if((b/=e)==1)return c+d;if(!g)g=e*.3;if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);return-(h*Math.pow(2,10*(b-=1))*Math.sin((b*e-f)*(2*Math.PI)/g))+c},easeOutElastic:function(a,b,c,d,e){var f=1.70158;var g=0;var h=d;if(b==0)return c;if((b/=e)==1)return c+d;if(!g)g=e*.3;if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*b)*Math.sin((b*e-f)*(2*Math.PI)/g)+d+c},easeInOutElastic:function(a,b,c,d,e){var f=1.70158;var g=0;var h=d;if(b==0)return c;if((b/=e/2)==2)return c+d;if(!g)g=e*(.3*1.5);if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);if(b<1)return-.5*(h*Math.pow(2,10*(b-=1))*Math.sin((b*e-f)*(2*Math.PI)/g))+c;return h*Math.pow(2,-10*(b-=1))*Math.sin((b*e-f)*(2*Math.PI)/g)*.5+d+c},easeInBack:function(a,b,c,d,e,f){if(f==undefined)f=1.70158;return d*(b/=e)*b*((f+1)*b-f)+c},easeOutBack:function(a,b,c,d,e,f){if(f==undefined)f=1.70158;return d*((b=b/e-1)*b*((f+1)*b+f)+1)+c},easeInOutBack:function(a,b,c,d,e,f){if(f==undefined)f=1.70158;if((b/=e/2)<1)return d/2*(b*b*(((f*=(1.525))+1)*b-f))+c;return d/2*((b-=2)*b*(((f*=(1.525))+1)*b+f)+2)+c},easeInBounce:function(a,b,c,d,e){return d-jQuery.easing.easeOutBounce(a,e-b,0,d,e)+c},easeOutBounce:function(a,b,c,d,e){if((b/=e)<(1/2.75)){return d*(7.5625*b*b)+c}else if(b<(2/2.75)){return d*(7.5625*(b-=(1.5/2.75))*b+.75)+c}else if(b<(2.5/2.75)){return d*(7.5625*(b-=(2.25/2.75))*b+.9375)+c}else{return d*(7.5625*(b-=(2.625/2.75))*b+.984375)+c}},easeInOutBounce:function(a,b,c,d,e){if(b<e/2)return jQuery.easing.easeInBounce(a,b*2,0,d,e)*.5+c;return jQuery.easing.easeOutBounce(a,b*2-e,0,d,e)*.5+d*.5+c}});
(function($){var _options={};var _container={};var _breadCrumbElements={};var _autoIntervalArray=[];jQuery.fn.jBreadCrumb=function(options){_options=$.extend({},$.fn.jBreadCrumb.defaults,options);return this.each(function(){_container=$(this);setupBreadCrumb()})};function setupBreadCrumb(){_breadCrumbElements=jQuery(_container).find('li');jQuery(_container).find('ul').wrap('<div style="overflow:hidden;position:relative;width: '+jQuery(_container).css("width")+';"><div>');jQuery(_container).find('ul').width(5000);if(_breadCrumbElements.length>0){jQuery(_breadCrumbElements[_breadCrumbElements.length-1]).addClass('last');jQuery(_breadCrumbElements[0]).addClass('first');var w=0;_breadCrumbElements.each(function(){w+=$(this).width()+20});if(w>jQuery(_container).width()){compressBreadCrumb()}}};function compressBreadCrumb(){var finalElement=jQuery(_breadCrumbElements[_breadCrumbElements.length-1]);if(jQuery(finalElement).width()>_options.maxFinalElementLength){if(_options.beginingElementsToLeaveOpen>0){_options.beginingElementsToLeaveOpen--}if(_options.endElementsToLeaveOpen>0){_options.endElementsToLeaveOpen--}}if(jQuery(finalElement).width()<_options.maxFinalElementLength&&jQuery(finalElement).width()>_options.minFinalElementLength){if(_options.beginingElementsToLeaveOpen>0){_options.beginingElementsToLeaveOpen--}}var itemsToRemove=_breadCrumbElements.length-1-_options.endElementsToLeaveOpen;jQuery(_breadCrumbElements[_breadCrumbElements.length-1]).css({background:'none'});$(_breadCrumbElements).each(function(i,listElement){if(i>_options.beginingElementsToLeaveOpen&&i<itemsToRemove){jQuery(listElement).find('a').wrap('<span></span>').width(jQuery(listElement).find('a').width()+10);jQuery(listElement).append(jQuery(_options.overlayClass+'.main').clone().removeClass('main').css({display:'block'})).css({background:'none'});if(isIE6OrLess()){fixPNG(jQuery(listElement).find(_options.overlayClass).css({width:'20px',right:"-1px"}))}var options={id:i,width:jQuery(listElement).width(),listElement:jQuery(listElement).find('span'),isAnimating:false,element:jQuery(listElement).find('span')};jQuery(listElement).bind('mouseover',options,expandBreadCrumb).bind('mouseout',options,shrinkBreadCrumb);jQuery(listElement).find('a').unbind('mouseover',expandBreadCrumb).unbind('mouseout',shrinkBreadCrumb);listElement.autoInterval=setInterval(function(){clearInterval(listElement.autoInterval);jQuery(listElement).find('span').animate({width:_options.previewWidth},_options.timeInitialCollapse,_options.easing)},(150*(i-2)))}})};function expandBreadCrumb(e){var elementID=e.data.id;var originalWidth=e.data.width;jQuery(e.data.element).stop();jQuery(e.data.element).animate({width:originalWidth},{duration:_options.timeExpansionAnimation,easing:_options.easing,queue:false});return false};function shrinkBreadCrumb(e){var elementID=e.data.id;jQuery(e.data.element).stop();jQuery(e.data.element).animate({width:_options.previewWidth},{duration:_options.timeCompressionAnimation,easing:_options.easing,queue:false});return false};function isIE6OrLess(){var isIE6=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent);return isIE6};function fixPNG(element){var image;if(jQuery(element).is('img')){image=jQuery(element).attr('src')}else{image=$(element).css('backgroundImage');image.match(/^url\(["']?(.*\.png)["']?\)$/i);image=RegExp.$1;}$(element).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='"+image+"')"})};
    jQuery.fn.jBreadCrumb.defaults =
    {
        maxFinalElementLength: 400,
        minFinalElementLength: 200,
        minimumCompressionElements: 4,
        endElementsToLeaveOpen: 1,
        beginingElementsToLeaveOpen: 1,
        minElementsToCollapse: 4,
        timeExpansionAnimation: 800,
        timeCompressionAnimation: 500,
        timeInitialCollapse: 600,
        easing: 'easeOutQuad',
        overlayClass: '.chevronOverlay',
        previewWidth: 50
    };

})(jQuery);
