Object.extend=function(destination,source) {
	var init=false;
  for(property in source){
		destination[property]=source[property];
		if(property=='initialize') init=true;
	}
	if(init) destination.initialize();
  return destination;
};

function $(){
	if(document.getElementById){
	  var elements=new Array();
	  for(var i=0;i<arguments.length; i++) {
	    var element=arguments[i];
	    if(typeof element=='string') element=document.getElementById(element);
	    if(arguments.length==1) return element;
	    elements.push(element);
	  }
	}else elements=null;
  return elements;
}

Function.prototype.bind = function(object){
  var __method = this;
  return function() {
    return __method.apply(object, arguments);
  };
};

Object.extend(String.prototype,{
	trim : function(a){ if(typeof a!='undefined') return this.replace(new RegExp('(^('+a+')*)|(('+a+')*$)','g'),''); else return this.replace(/(^\s*)|(\s*$)/g,''); },
	ltrim: function(a){ if(typeof a!='undefined') return this.replace(new RegExp('^('+a+')*','g'),''); else return this.replace(/^\s*/g,''); },
	rtrim: function(a){ if(typeof a!='undefined') return this.replace(new RegExp('('+a+')*$','g'),''); else return this.replace(/\s*$/g,''); },
	encodeEntities: function(){
		return this.replace(/\u0026(?!(#[0-9]{1,4}|#x[0-9a-f]{2,5}|[a-zA-Z]+);)/g,'&amp;').replace(/\u003C/g,'&lt;').replace(/\u003E/g,'&gt;').replace(/\u0022/g,'&quot;');
	},
	decodeEntities: function(){
		return this.replace(/\u0026lt;/g,'\u003C').replace(/\u0026gt;/g,'\u003E').replace(/\u0026quot;/g,'\u0022').replace(/\u0026amp;/g,'\u0026');
	}
});

Object.extend(Math,{
	aleatoire: function(min,max){ return (this.floor(this.random()*(max-min))+min); },
	sinoidal: function(pos){ return ((-this.cos(pos*this.PI)/2) + 0.5); },
	linear: function(pos){ return pos; },
	cubic: function(pos){ this.pow(pos,3); },
	circ: function(pos){ this.sqrt(pos); }
});

if(!window.innerWidth){
	if(document.documentElement && document.documentElement.clientWidth){
		window.innerWidth=document.documentElement.clientWidth;
		window.innerHeight=document.documentElement.clientHeight;
	}else if(document.body){
		window.innerWidth=document.body.clientWidth;
		window.innerHeight=document.body.clientHeight;
	}
}

function popup(url,name,w,h,opt){
	if(!w) w=800;
	if(!h) h=600;
	if(!opt) opt=''; else opt=','+opt;
	var leftPos=Math.round((screen.availWidth - w)/2);
	var topPos=Math.round((screen.availHeight - h)/2);
	return window.open(url,name,'width='+w+',height='+h+',left='+leftPos+',top='+topPos+opt);
}

function injectInPopup(txt,w,h){
	var win=popup('','winhelp',0,0,'resizable,scrollbars');
	win.document.open('text/html');
	win.document.write(txt);
	win.document.close();
	win.focus();
}

function help(o){
	var txt='<table cellspacing="2" cellpadding="1" border="1">';
	var i=0;
	var value='';
	for(k in o){
		value='';
		try{ value=String(o[k]); }catch(e){ value='undefined';}
		txt+='<tr><th>'+k+'</th><td>'+value.toString().encodeEntities()+'&nbsp;</td></tr>'+"\n";
	}
	return injectInPopup('<html><title>Help</title><style>*{font-family:Verdana;font-size:9px;}</style><body>'+txt+'</table></body></html>');
}

function getArrayClass(classname){
	if(!window.StoreElmByClass){
		window.StoreElmByClass=new Array();
	  var Childs = document.getElementsByTagName('body')[0].getElementsByTagName('*');
	  for(var i=0;i<=Childs.length;i++){
			if(Childs[i]&&Childs[i].className){
				var name=Childs[i].className.trim();
				if(!StoreElmByClass[name])StoreElmByClass[name]=new Array();
				StoreElmByClass[name].push(Childs[i]);
			}
		}
	}
	return (StoreElmByClass[classname]||null);
}

function getObj(o){
	var elm=$(o);
	if(elm && window.Evt){
		Object.extend(elm,Evt);
		if(window.Obj && elm.nodeName){
			elm.extendwith(Obj);
			if(elm.tag=='form' && window.extForm) elm.extendwith(extForm);
			if(elm.tag=='object' && window.Wpv) elm.extendwith(Wpv);
		}
	}
	return (elm||null);
}

var Cookie={
	init: function(){
		var Cook=document.cookie.split(';');
		this.Elm=[];
		for(var i=0;i<Cook.length;i++){
			var Elm=Cook[i].trim().split('=');
			this.Elm[unescape(Elm[0])]=unescape(Elm[1]);
		}
	},
	get: function(varname){
		if(!this.Elm) this.init();
		if(this.Elm[varname]) return this.Elm[varname];
		return null;
	},
	set: function(name,value,path,expdays,domain,secure){
		if(path===true) path=location.pathname;
		if(parseInt(expdays)>0){
			var date=new Date();
			date.setTime(date.getTime()+expdays*24*60*60*1000);
		}
		document.cookie=name+'='+escape(value)+((expdays)?';expires='+date.toGMTString():'')+((path)?'; path='+path:'')+((domain)?'; domain='+domain:'')+((secure)?'; secure':'');
		if((path==location.pathname||!path)&&!domain)this.Elm[name]=value;
	},
	del: function(name,path,domain){
		if(path===true) path=location.pathname;
		if(this.get(name)){
			document.cookie=name+'='+((path)?'; path='+path:'')+((domain)?'; domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
			this.init();
		}
	}
};

var Get={
	init: function(uri){		
		if(!uri) uri=location.href.decodeEntities();
		this.Elm=[];
		if(uri.lastIndexOf('?')>=0){
			var Gets=uri.substring(uri.lastIndexOf('?')+1,uri.lastIndexOf('#')).split('&');
			for(var i=0;i<Gets.length;i++){
			   var Elm=Gets[i].split('=');
			   if(Elm[0]&&Elm[1])this.Elm[Elm[0]]=unescape(Elm[1]);
			}
		}
	},
	get: function(varname){
		if(!this.Elm) this.init();
		if(this.Elm[varname]) return this.Elm[varname];
		return null;
	},
	add: function(name,value,path,expdays,domain,secure){
		if(path===true) path=location.pathname;
		if(parseInt(expdays)>0){
			var date=new Date();
			date.setTime(date.getTime()+expdays*24*60*60*1000);
		}
		document.cookie=name+'='+escape(value)+((expdays)?';expires='+date.toGMTString():'')+((path)?'; path='+path:'')+((domain)?'; domain='+domain:'')+((secure)?'; secure':'');
		if((path==location.pathname||!path)&&!domain)this.Elm[name]=value;
	},
	del: function(name,path,domain){
		if(path===true) path=location.pathname;
		if(this.get(name)){
			document.cookie=name+'='+((path)?'; path='+path:'')+((domain)?'; domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
			this.init();
		}
	}
};

var Obj={
	initialize: function(){ this.tag=this.nodeName.toLowerCase(); },
	insertFatherNode: function(tag){
		var node=document.createElement(tag);
		while(this.firstChild){	node.appendChild(this.firstChild); }
		return this.appendChild(node);
	},
	getAttr: function(attribute){
		if(document.all){
			switch(attribute){
				case 'class': return this.getAttribute('className'); break;
				case 'style': return this.style.getAttribute('cssText'); break;
			}
		}
		return this.getAttribute(attribute);	
	},
	setAttr: function(attribute,code){
		if(document.all){
			switch(attribute){
				case 'class': return this.setAttribute('className',code); break;
				case 'style': return this.style.setAttribute('cssText',code); break;
			}
		}
		return this.setAttribute(attribute,code);	
	},
	removeAttr: function(attribute){
		if(document.all){
			switch(attribute){
				case 'class': return this.removeAttribute('className'); break;
				case 'style': return this.style.setAttribute('cssText',''); break;
			}
		}
		return this.removeAttribute(attribute);
	},
  getStyle: function(prop){
    var val=this.style[prop];
    if(!val){
      if(window.getComputedStyle){
        var css=document.defaultView.getComputedStyle(this,null);
        val=css ? css.getPropertyValue(prop) : null;
      }else if(this.currentStyle) val=this.currentStyle[prop];
    }
    if(window.opera &&['left','top','right','bottom'].include(prop))
      if(this.getStyle('position')=='static') val='auto';
    return val=='auto' ? null : val;
  },
	setStyle: function(prop,val){ this.style[prop]=val; },
	removeStyle: function(prop){ this.style[prop]=''; },
	resetBlockStyle: function(){ this.setAttr('style','position:static;top:auto;left:auto;bottom:auto;right:auto;float:none;margin:0;border:0;padding:0;width:auto;height:auto;min-width:auto;min-height:auto;background-color:transparent;background-image:none'); },
	setStateClass: function(state){
		if(typeof this.defaultClass=='undefined'){
			switch(this.getAttr('class')){
				case 'on':case 'off':case 'in':case null: this.defaultClass=''; break;
				default: this.defaultClass=this.getAttr('class'); break;
			}
		}
		if(state===null){
			if(this.stateClass && this.stateClass=='on') state='off'; else state='on';
		}
		if(typeof state=='undefined'||state==''){
			this.setAttr('class',this.defaultClass);
			this.stateClass='';
		}else if(!this.stateClass || this.stateClass!=state){
			if(this.defaultClass=='') this.setAttr('class',state);
			else this.setAttr('class',this.defaultClass+'-'+state);
			this.stateClass=state;
		}
		return this.stateClass;
	},
	setStateDisplay: function(state){
		if(typeof this.statedisplay=='undefined'){
			if(this.getStyle('display')=='none') this.stateDisplay=false; 	else this.stateDisplay=true;
		}
		if(typeof state=='undefined'||state===null){
			if(this.statedisplay) state=false; else state=true;
		}
		if(state) this.display(); else this.missing();
		return this.statedisplay;
	},
	display: function(){ this.setStyle('display','block'); this.statedisplay=true; },
	missing: function(){ this.setStyle('display','none'); this.statedisplay=false; },
	show: function(){ this.setStyle('visibility','visible'); },
	hide: function(){ this.setStyle('visibility','hidden'); }
};

var Evt={
	extendwith: function(o){ Object.extend(this,o); },
	addEventList: function(evt,fnc){
		if(this.addEventListener){
			this.addEventListener(evt,fnc,false);
		}else{
			if(!this.StoreEvent) this.StoreEvent={};
			if(!this.StoreEvent[evt])this.StoreEvent[evt]=[];
			this.StoreEvent[evt].push(fnc);
			if(typeof this['on'+evt] != 'function') this['on'+evt]=function(){this.callEventList(evt)};
		}
	},
	callEventList: function(evt){
		if(this.StoreEvent[evt]){
			for(var cle in this.StoreEvent[evt]){
				this.tmpfnc=this.StoreEvent[evt][cle];
				this.tmpfnc();
			}
			this.tmpfnc=null;
		}
	},
	removeEventList: function(evt,fnc){
		if(this.removeEventListener){
			this.removeEventListener(evt,fnc,false);
		}else if(this.detachEvent){
			this.detachEvent('on'+evt,fnc);
		}else if(typeof this['on'+evt] != 'function'){
			this['on'+evt]=function(){;};
		}
	},
	fireEventList: function(evt){
		if(this.fireEvent){
			this.fireEvent('on'+evt);
		}else{
			var oe=window.document.createEvent('MouseEvent');
			oe.initEvent(evt,false,true);
			this.dispatchEvent(oe);
		}
	}
};

var ObjFx={
	getDimensions: function() {
    var display = this.getStyle('display');
    if(display != 'none' && display != null){ // Safari bug
			this.originalWidth=this.offsetWidth;
			this.originalHeight=this.offsetHeight;      
			return {width: this.offsetWidth, height: this.offsetHeight};
		}
    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var os = this.style;
    var originalVisibility = os.visibility;
    var originalPosition = os.position;
    var originalDisplay = os.display;
    os.visibility = 'hidden';
    os.position = 'absolute';
    os.display = 'block';
    var originalWidth = this.clientWidth;
    var originalHeight = this.clientHeight;
    os.display = originalDisplay;
    os.position = originalPosition;
    os.visibility = originalVisibility;
		this.originalWidth=originalWidth;
		this.originalHeight=originalHeight;
    return {width: originalWidth, height: originalHeight};
  },
	getOffset: function(){
	  this.offsetX = this.offsetLeft;
	  this.offsetY = this.offsetTop;
		var o=this.offsetParent;
	  while(o){
			this.offsetX+=o.offsetLeft;
	    this.offsetY+=o.offsetTop;
	    o=o.offsetParent;
	  }
	  return {'x':this.offsetX,'y':this.offsetY};
	},
	setOpacity: function(opacity){
		if(window.ActiveXObject) this.style.filter='alpha(opacity:'+opacity*100+')';
		this.style.KHTMLOpacity=opacity;
		this.style.MozOpacity=opacity;
		this.style.opacity=opacity;
	},
	expand: function(mw,mh,p,step,speed){
		this.expandparam={maxwidth:mw,maxheight:mh,pourcent:p,step:step};
		this.stepExpand();
		this.show();
		this.expandparam.timer = setInterval(this.stepExpand.bind(this),speed);
	},
	stepExpand: function(){
//		window.status=' step:'+this.expandparam.step/10+' sinoidal:'+(Math.sinoidal(this.expandparam.step+1/10));
		this.expandparam.step+=this.expandparam.pourcent;
		if(this.expandparam.step<=100){
			if(this.expandparam.maxwidth>0) this.setStyle('width',Math.floor(this.expandparam.step/100*this.expandparam.maxwidth)+'px');
			if(this.expandparam.maxheight>0) this.setStyle('height',Math.floor(this.expandparam.step/100*this.expandparam.maxheight)+'px');
		}else{
			clearInterval(this.expandparam.timer);
			this.expandparam.timer=null;
			if(this.onExpand) this.onExpand();
		}
	},
	fadeIn: function(opacity,step,speed){
		this.fadeinparam={opacity:opacity,step:step};
		this.setOpacity(opacity);
		this.show();
		this.fadeinparam.timer = setInterval(this.stepFadeIn.bind(this),speed);
	},
	slide: function(direction,control,frame,method){
		this.sens=direction;
		if(control=='open')this.control=true; else this.control=false;
		
		this.dim=this.getDimensions();

		var div=getObj(this.insertFatherNode('div'));
		div.resetBlockStyle();
		div.setStyle('position','absolute');
		div.setStyle('left','0');
		div.setStyle('bottom','0');
		div.setStyle('width',this.dim.width+'px');
		div.setStyle('height',this.dim.height+'px');

		this.method=method;
		
		this.setStyle('overflow','hidden');
		if(!this.control){ this.setStyle(this.sens,0); this.setStyle('visibility','visible'); }
		this.addLoopFctDuring(function(){
			if(this.loopvalue!=this.oldloopvalue){
//				alert(this.loopthreshold+' '+this.loopvalue);
				if(this.control) this.setStyle(this.sens,this.loopvalue+'px');
				else{
					this.setStyle(this.sens,(this.loopthreshold-this.loopvalue)+'px');
					window.status=this.loopthreshold-this.loopvalue;
				}
			}
			this.oldloopvalue=this.loopvalue;
		});
		
		this.addLoopFctEnding(function(){
			if(this.control)this.setStyle('display','none');
//			this.setStyle('overflow','inherit');
		});
		if(!frame) frame=150;
		this.loop(frame,this.dim[this.sens],method)
	},
	stepbystep: function(){
		var frame=this.looptotalframe-this.loopi;
		switch(this.loopeffect){
			case 'rebond': this.loopvalue=Math.floor(Math['sinoidal'](1-(frame/this.loopfactor))*(this.loopfactor*frame)); break;
			case 'sinuosidal': this.loopvalue=Math.floor(Math['sinoidal'](frame/this.looptotalframe)*(this.loopfactor*frame)); break;
			case 'sinuosidal2': this.loopvalue=Math.floor(Math['sinoidal'](frame/this.totalframe)*(this.loopfactor*frame));	break;	
		}
//		var value=Math.floor(this.max-(Math['sinoidal'](1-(this.loopi/this.produit))*(this.produit*frame)));
//		var value=Math.floor(this.max-(Math['sinoidal'](frame/this.totalframe)*(this.produit*frame)));
//		var value=Math.floor(Math['sinoidal'](frame/this.totalframe)*(this.produit*frame));
//		window.status=this.loopi +' -- value='+value+' frame='+Math.sinoidal(frame/this.totalframe)+' * '+((this.max/this.totalframe)*frame);

		if(this.loopvalue<=0){
			clearInterval(this.interval);
			for(var cle in this.LoopFctEnding){
				this.loopendingfct=this.LoopFctEnding[cle];
				this.loopendingfct();
			}
		}
		for(var cle in this.LoopFctDuring){
			this.loopduringfct=this.LoopFctDuring[cle];
			this.loopduringfct();
		}
		this.loopi++;
	},
	loop: function(totalframe,threshold,effect){
		this.loopthreshold=threshold;
		this.looptotalframe=totalframe;
		this.loopeffect=effect;
		this.loopfactor=threshold/totalframe;
		this.loopi=0;
		this.interval=setInterval(this.stepbystep.bind(this),15);
	},
	addLoopFctDuring: function(fct){
		if(!this.LoopFctDuring) this.LoopFctDuring=[];
		this.LoopFctDuring.push(fct);
	},
	addLoopFctEnding: function(fct){
		if(!this.LoopFctEnding) this.LoopFctEnding=[];
		this.LoopFctEnding.push(fct);
	},
	stepFadeIn: function(){
		/*window.status='opacity:'+this.opacity+' stepopacity:'+this.stepopacity;*/
		this.fadeinparam.opacity+=this.fadeinparam.step;
		if(this.fadeinparam.opacity<1){
			this.setOpacity(this.fadeinparam.opacity);
		}else{
			clearInterval(this.fadeinparam.timer);
			this.fadeinparam.timer=null;
			this.setOpacity(1);
			if(this.onFadeIn) this.onFadeIn();
		}
	},
	setOverflowInnerWindow: function(marge){
		if(this.getStyle('position')=='absolute'){
			this.getOffset();
			if(typeof(marge)=='undefined') marge=5;
			var hmax=(window.innerHeight-this.offsetY)-marge;
			var wmax=(window.innerWidth-this.offsetX)-marge;
			var w=this.offsetWidth;
			var wscr=window.getScrollerWidth();

			if(this.offsetWidth>wmax || this.offsetHeight>hmax){
				if(this.getStyle('border-left-width')) w=w-this.getStyle('border-left-width').match(/\d+/);
				if(this.getStyle('border-right-width')) w=w-this.getStyle('border-right-width').match(/\d+/);
				if(this.getStyle('padding-left-width')) w=w-this.getStyle('padding-left-width').match(/\d+/);
				if(this.getStyle('padding-right-width')) w=w-this.getStyle('padding-right-width').match(/\d+/);
				if(!this.style['width']) this.setStyle('width',(w+wscr)+'px');
				this.setStyle('overflow','auto');
			}
			this.setStyle('maxHeight',hmax+'px');
			this.setStyle('maxWidth',wmax+'px');
		}
	}
};

/* Obtenir la largeur de l’ascenceur du navigateur*/
function getScrollerWidth(){
	if(!window.scrollerWidth){
		var wNoScroll=0;
		var wScroll=0;
		var body=document.getElementsByTagName('body')[0];

		var div=document.createElement('div');
		div.style['position']='absolute';
		div.style['top']='-1000px';
		div.style['left']='-1000px';		
		div.style['width']='100px';
		div.style['height']='50px';
		div.style['overflow']='hidden';

		var inn=document.createElement('div');
		inn.style['width']='100%';
		inn.style['height']='200px';

		div.appendChild(inn);
		div=body.appendChild(div);
		wNoScroll=inn.offsetWidth;
		div.style['overflow']='auto';
		wScroll=inn.offsetWidth;
		body.removeChild(div);
		window.scrollerWidth=(wNoScroll - wScroll);
	}
	return window.scrollerWidth;
}

var SlideShow={
	initialize: function(){
		switch(this.tag()){
			case 'dl': this.tagitem='dt'; this.desc=true; break;
			case 'ul': this.tagitem='li'; this.desc=false; break;
			default: return false;
		}
		this.Imgs=[];
		this.Desc=[];
		this.Ids=[];
		this.pos=0;
		var div=document.createElement('div');
		this.parentNode.insertBefore(div,this);
		div.appendChild(this);
		div.className='global-'+this.className;
		if(this.desc){
			this.showdesc=div.appendChild(document.createElement('div'));
			this.showdesc.className='description';		
		}
		this.showp=getObj(div.appendChild(document.createElement('p')));
		this.showp.className='visuel';
		this.showspan=getObj(this.showp.appendChild(document.createElement('span')));
		this.showpic=this.showspan.appendChild(document.createElement('img'));
		
		this.showpic.src='/htc/px.png';
		this.showpic.slideshow=this;
		this.showspan.showp=this.showp;
		
		this.showspan.onFadeIn=function(){ this.showp.setStyle('backgroundImage','none'); };
		this.showpic.onload=function(){ this.slideshow.magnifyshow(this.src); };
		
		this.showmenu=this;
		
		Object.extend(this,Obj);
		
		if(this.showmenu.getElementsByTagName(this.tagitem)){
			var list=this.showmenu.getElementsByTagName(this.tagitem);
			var e=0;
			for(var i=0;i<list.length;i++){
				if(list[i].getElementsByTagName('a') && list[i].getElementsByTagName('a')[0]){
					var item=getObj(list[i]);
					var a=item.getElementsByTagName('a')[0];
					var o=item.nextSibling;
					if(this.desc){
						a.Desc=new Array();
						while(o && o.nodeName.toLowerCase()!=this.tagitem){
							if(o.nodeName.toLowerCase()=='dd') a.Desc[a.Desc.length]=getObj(o);
							o=o.nextSibling;
						}
						var o=this.firstChild;
						while(o && o.nodeName!='DT' && o.nodeName!='DD') o=o.firstChild;
						if(o && o.nodeName!='DD') o=null;
						this.Desc[e]=o;
					}
					Object.extend(a,Obj);
					a.oldhref=a.href;
					this.Imgs[e]=a;
					if(item.id) this.Ids[item.id]=e;
					a.href='javascript:;';
					a.slideshow=this;
					a.numpic=e;
					a.onclick=function(){ this.slideshow.activate(this.numpic); this.blur(); };
					e++;
				}
			}
			var prev=div.insertBefore(document.createElement('a'),this.showmenu);
			prev.className='prev';
			prev.href='javascript:;';
			var img=prev.appendChild(document.createElement('img'));
			img.src='/htc/px.png';
			
			prev.slideshow=this;
			prev.onclick=function(){
//				alert(this.slideshow.showmenu.view);
				var list=this.slideshow.showmenu.getElementsByTagName('dt');
				if(this.slideshow.showmenu.view<list.length){
					for(var i=list.length-1;i>=0;i--){
						if(list[i].style.display=='none'){
							list[i].style.display='block';
							this.slideshow.showmenu.view++;
							break;
						}
					}
				}
				this.blur();
			};
			this.showmenu.view=this.showmenu.getElementsByTagName(this.tagitem).length;
			var next=this.appendChild(document.createElement('a'));
			next.className='next';
			next.href='javascript:;';
			img=next.appendChild(document.createElement('img'));
			img.src='/htc/px.png';
			
			next.slideshow=this;
			next.onclick=function(){
//				alert(this.slideshow.showmenu.view);
				if(this.slideshow.showmenu.view>4){
					var list=this.slideshow.showmenu.getElementsByTagName('dt');
					for(var i=0;i<list.length;i++){
						if(list[i].style.display!='none'){
							list[i].style.display='none';
							this.slideshow.showmenu.view--;
							break;
						}
					}
				}
				this.blur();
			};
		}
		var select=0;
		var id=this.getAttr('id');
		if(id){
			var num=Get.get(id);
			if(this.Ids[id+'_'+num]) select=this.Ids[id+'_'+num];
		}
		this.pos=select; //pour désactiver l'image précédente
		this.activate(select);
//	help(this.Imgs);
	},
	setSrc: function(){
		this.showpic.src=this.Imgs[this.pos].oldhref;
	},
	activate: function(num){
		if(this.Imgs[num]){
			this.Imgs[this.pos].setStateClass('off');
			if(this.desc) for(var i=0;i<this.Imgs[this.pos].Desc.length;i++){ this.Imgs[this.pos].Desc[i].setStateClass('off'); }
			this.pos=num;
			this.Imgs[num].setStateClass('on');
			if(this.desc && this.Imgs[this.pos].Desc[0]) this.showdesc.innerHTML=this.Imgs[this.pos].Desc[0].innerHTML;
			this.showspan.setOpacity(0);	
			this.showp.setStyle('backgroundImage',this.showspan.getStyle('backgroundImage'));
	
			setTimeout(this.setSrc.bind(this),10);
	//		for(var e=0;e<o.length;e++){ if(e!=this.def)o[e].style['display']='none'; }
		}
	},
	magnifyshow: function(src){
		this.showspan.setStyle('backgroundImage','url('+src+')');
		this.showspan.fadeIn(0.1,0.1,100);
	}
};


var FadeTransition={
	initialize: function(){
		if(!this.Args['change']) this.change=this.Args['change']; else this.change=2000;
		this.Ref=new Array();
		if(this.nodeName.toLowerCase()=='ul' && this.getElementsByTagName('ul')[0]){
			var Lis=this.getElementsByTagName('li');
			for(var i=0;i<Lis.length;i++){
				if(Lis[i].getElementsByTagName('ul')[0]) this.Ref.push(getObj(Lis[i]));
			}
		}else{
			var Lis=this.getElementsByTagName('li');
			var li=null;
			for(var i=0;i<Lis.length;i++){
				li=getObj(Lis[i]);
				if(li.getElementsByTagName('img')[0]){
					li.extendwith(ObjFx);
					this.Ref.push(li);
				}
			}
		}
		for(var j=0;j<this.Ref.length;j++){
			this.Ref[j].ac=this.Ref[j].getElementsByTagName('a')[0];
			var ac=getObj(this.Ref[j].ac);
			ac.extendwith(ObjFx);
			var Imgs=this.Ref[j].getElementsByTagName('img');
			ac.ImgSrc=new Array();
			for(var i=0;i<Imgs.length;i++){
				ac.ImgSrc[i]=new Image(120,80);
				ac.ImgSrc[i].src=Imgs[i].src;
			}
			ac.counter=0;
			ac.setStyle('backgroundImage','url('+ac.ImgSrc[0].src+')');
			ac.master=this;
			if(j==this.Ref.length-1){
				ac.onFadeIn=function(){ setTimeout(this.master.fadeRecursive.bind(this.master),this.master.change); };
			}else{
				ac.onFadeIn=function(){ this.master.fadeRecursive(); };
			}
			ac.counter=0;
			var toto=getObj(this.Ref[j].getElementsByTagName('img')[0]);
			toto.extendwith(ObjFx);
			toto.hide();
		}
		this.counter=0;
		this.fadeRecursive();
	},
	fadeRecursive: function(){
		var ac=this.Ref[this.counter].ac;
		this.Ref[this.counter].setStyle('backgroundImage','url('+ac.ImgSrc[ac.counter].src+')');
		ac.counter++;
		if(!ac.ImgSrc[ac.counter]) ac.counter=0;
		ac.setStyle('backgroundImage','url('+ac.ImgSrc[ac.counter].src+')');
		if(typeof document.body.style.maxHeight != 'undefined') ac.fadeIn(0.1,0.1,100); else ac.fadeIn(0,1,900);
		this.counter++;
		if(this.counter==this.Ref.length) this.counter=0;
	}
};
var Marquee={
	initialize: function(){
		this.idint=null; //id de l'interval prochainement exécuté.
		if(!this.speed) this.speed=6;
		if(!this.foot) this.foot=6;

		if(typeof document.body.style.maxHeight != 'undefined'){
			this.setStyle('position','absolute');
			this.setStyle('left','-10000px');
			if(this.offsetWidth && this.offsetWidth>0 && this.parentNode){
				this.pwidth=this.offsetWidth;
				this.pinit=this.parentNode.offsetWidth;
				this.pas=-this.pinit;
				this.setStyle('left','');
				this.setStyle('position','static');
				this.onmouseover=function(){ clearInterval(this.idint); };
				this.onmouseout=function(){ this.mstart(); };
				this.show();
				this.mstart();
			}
		}else{
			var marquee=document.createElement('marquee');
			marquee.appendChild(document.createTextNode(this.firstChild.data));
		 	marquee=this.parentNode.replaceChild(marquee,this);
		}
	},
	mboucle: function(){
		if(this.foot>=this.pwidth) this.foot=-this.pinit; else this.foot=this.foot+this.speed;
		this.setStyle('marginLeft',(-this.foot)+'px');
	},
	mstart: function(){ this.idint=setInterval(this.mboucle.bind(this),100); }
};

var Defil={
	initialize: function(){		
				
		switch(this.tag()){
			case 'dl': this.tagitem='dt'; this.desc=true; break;
			case 'ul': this.tagitem='li'; this.desc=false; break;
			default: return false;
		}

		var containerwidth=this.offsetWidth;

		var div=getObj(document.createElement('div'));
		this.parentNode.insertBefore(div,this);
		div.appendChild(this);
		div.setAttr('class',this.getAttr('class'));
		this.removeAttr('class');
		
 		this.speed=4; // vitesse par défaut
		this.posoffset=0;
		
		var posoffset=0;
		var item=null;
		var Items=this.getElementsByTagName(this.tagitem);
		var nbitems=Items.length;
		for(var i=0;i<nbitems;i++){
			item=getObj(Items[i]);
			item.setAttr('style','float:none;position:absolute;top:0;left:'+posoffset+'px');
			item.posoffset=posoffset;
			posoffset+=item.offsetWidth;
		}

		var lastpos=posoffset;

		if(posoffset<containerwidth){
			var nbmulti=Math.ceil(containerwidth/posoffset);
			for(var e=1;e<nbmulti;e++){
				for(i=0;i<nbitems;i++){
					item=getObj(this.appendChild(Items[i].cloneNode(true)));
					posoffset=lastpos*e+Items[i].posoffset;
					item.setStyle('left',posoffset+'px');
				}
			}
			lastpos=posoffset+Items[--i].offsetWidth;
		}
		this.lastpos=lastpos;
		this.setAttr('style','position:absolute;top:0;left:0;padding:0;margin:0;width:'+lastpos+'px');		
		
		this.clone=getObj(div.appendChild(this.cloneNode(true)));
		this.clone.setAttr('style','position:absolute;top:0;left:-'+lastpos+'px;padding:0;margin:0;width:'+lastpos+'px');
		this.clone.posoffset=-lastpos;


//		window.onunload=function(){ window.clearInterval(this.idint); }
		div.defil=this;
		div.idint=null; //id de l'interval prochainement exécuté.
		div.idout=null; //id du settimeout du défilement différé.
		div.getOffset();
		this.offsetMax=div.offsetWidth;

		div.onmousemove=this.position;
		div.onmouseout=this.stopdefil;
		div.onmouseover=this.startdefil;

		if(this.Args){
			if(this.Args['speed'])this.step=this.Args['speed'];
			if(this.Args['delayed']){
				if(this.Args['delayed']>0) div.idout=window.setTimeout(div.onmouseover.bind(div),this.Args['delayed']);
				else div.onmouseover();
			}
		}
	},
	startdefil: function(){
		if(!this.idint) this.idint=setInterval(this.defil.stepdefil.bind(this.defil),100);
		if(this.idout){ window.clearTimeout(this.idout); this.idout=null; }
	},
	stopdefil: function(){
		window.clearInterval(this.idint);
		this.idint=null;
	},
	position: function(e){
		if(window.event){
			var x = event.clientX-this.offsetX;
			var y = event.clientY-this.offsetY;
		}else{
			var x = e.pageX-this.offsetX;
			var y = e.pageY-this.offsetY;
		}
//		window.status=' x:'+x+' y:'+y+' '+Math.round(x/(this.offsetWidth/20)-10);
		this.defil.step=Math.round(x/(this.offsetWidth/60)-30);
	},
	stepdefil: function(){
		this.posoffset=this.posoffset-this.step;
		this.setStyle('left',this.posoffset+'px');
		this.clone.posoffset=this.clone.posoffset-this.step;
		this.clone.setStyle('left',this.clone.posoffset+'px');
		if(this.step>0){
			if(this.offsetWidth+this.posoffset<=0){
				this.posoffset=this.lastpos+(this.offsetWidth+this.posoffset);
				this.setStyle('left',this.posoffset+'px');
			}
			if(this.offsetWidth+this.clone.posoffset<=0){
				this.clone.posoffset=this.lastpos+(this.offsetWidth+this.clone.posoffset);
				this.clone.setStyle('left',this.clone.posoffset+'px');
			}
		}else{
			if(this.posoffset>=this.offsetMax){
				this.posoffset=this.clone.posoffset-this.offsetWidth;
				this.setStyle('left',this.posoffset+'px');
			}
			if(this.clone.posoffset>=this.offsetMax){
				this.clone.posoffset=this.posoffset-this.offsetWidth;
				this.clone.setStyle('left',this.clone.posoffset+'px');
			}
		}
	}
};

var Drawer={
	initialize: function(){

		if(this.tag=='dl'){
			this.active=null;
			this.evt='click';
			this.Elms=[];
			
			if(!this.id){
				if(!this.num) this.num=Math.aleatoire(100,1000);
				this.id=this.className+'-'+this.num;
			}
			var num=0;
		
			var o=getObj(this.firstChild);
			var elm=null;
			var tab=false;
			var dt=1;
			var e=0;

			while(o){
				switch(o.tag){
					case 'dt':
						if(!tab && elm && !elm.DrawerChilds[0]) tab=true;
						elm=o;
						elm.num=dt++;
						elm.master=this;
						elm.addEventList(this.evt,this.callevent);
						elm.DrawerChilds=[];
						this.Elms[elm.num]=elm;
					break;
					case 'dd':
						if(elm){
							if(tab) e++; else e=elm.num;
							if(this.Elms[e]){
								o.drawer=this.Elms[e];
								this.Elms[e].DrawerChilds.push(o);
							}
						}
					break;
				}
				o=getObj(o.nextSibling);
			}

			if(tab){
				this.closeold=true;
				this.yoyo=false;
				this.openfirst=true;
				this.record=true;
			}else{
				this.closeold=false;
				this.yoyo=true;
				this.openfirst=false;
				this.record=false;
			}
			if(this.Args) this.extendwith(this.Args);
			if(this.openfirst){
				if(this.record) num=Cookie.get(this.id); else num=this.openfirst;
				if(!num||num<2) num=1;
				if(this.Elms[num]) this.applystate(this.Elms[num],'on');
			}
		}
	},
	applystate: function(o,state){
		o.setStateClass(state);
		if(o.DrawerChilds){
			for(var i=0;i<o.DrawerChilds.length;i++) state=o.DrawerChilds[i].setStateClass(state);
		}
		if(state=='on'){
			if(o.DrawerChilds.length==1){
				o.DrawerChilds[0].extendwith(ObjFx);
				o.DrawerChilds[0].setOverflowInnerWindow();
			}
			this.active=o;
			if(this.record) Cookie.set(this.id,o.num);
		}
	},
	callevent: function(){
		var m=this.master;
		if(m.closeold && m.active && m.active!=this) m.applystate(m.active,'off');
		if(m.yoyo) m.applystate(this,null); else m.applystate(this,'on');
	},
	disabledevent: function(num){
		if(this.Elms[num]){
			this.applystate(this.Elms[num],'in');
			this.Elms[num].removeEventList(this.evt,this.callevent);
		}
	},
	addevent: function(num,fnc){
		if(this.Elms[num]) this.Elms[num].addEventList(this.evt,fnc);
		if(this.Elms[num]==this.active) fnc();
	},
	addfire: function(b){
		if(b){
			var o=getObj(b);
			while(o){
				if(o.drawer && o.drawer.master==this){
					b.drawer=o.drawer;
					b.addEventList(this.evt,function(){this.drawer.fireEventList(this.drawer.master.evt)});
					break;
				}else o=o.parentNode;
			}
		}
	}
};

var ExtendLink={
	initialize: function(){
		var Elms=[];
		switch(this.tag){
			case 'dl': Elms=this.getElementsByTagName('dd'); break;
			case 'ul':case 'ol': Elms=this.getElementsByTagName('li'); break;
			case 'table': Elms=this.getElementsByTagName('tbody')[0].getElementsByTagName('tr');  break;
			default: Elms=[this]; break;
		}

		for(var i=0;i<Elms.length;i++){
			var o=getObj(Elms[i]);
			if(o.getElementsByTagName('a')[0] && o.getElementsByTagName('a')[0].href!=''){
				o.onclick=function(){ window.location.href=this.getElementsByTagName('a')[0].href; };
				o.onmouseover=function(){ this.setStateClass('over'); };
				o.onmouseout=function(){ this.setStateClass('out'); };
			}else o.setStateClass('off');
		}
	}
};
var LinkTargetWindow={
	initialize: function(){
		if(this.tag=='a'){ this.a=this; }else{
			if(this.getElementsByTagName('a')[0]){ this.a=this.getElementsByTagName('a')[0]; }else{ return false; }
		}
		if(this.a.title=='') this.a.title = 'S’ouvre dans une nouvelle fenêtre';		
		this.onclick = function(){
			window.open(this.a.href);
			return false; // inhibe le lien réel.
		};
	}
};
var ZoomImg={
	initialize: function(){					
		var span=getObj(document.createElement('span'));
		span.setStyle('position','relative');
		span.className='zoomimg';
		span.appendChild(this.cloneNode(false));
		span.onmouseover=function(){ this.span.className='on'; };
		span.onmouseout=function(){ this.span.className='off'; };
		var span2=getObj(span.appendChild(document.createElement('span')));
		span.span=span2;
		var img=getObj(document.createElement('img'));
		img.src=this.src.replace(/-[a-z0-9]+\.(jpg|png|gif)$/g,'.$1');
		span2.appendChild(img);
		this.parentNode.replaceChild(span,this);
	}
};
var VirtualPopUp={
	initialize: function(){
		this.hide();
		this.setStateClass('on');
		this.onclick=function(){ this.setStateClass('off'); };
		setTimeout(this.temporize.bind(this),400);
	},
	temporize: function(){
		this.fadeIn(0.1,0.1,100);
	}
};

var Permute={
	initialize: function(){
		if(!this.tagglobal) this.tagglobal='dl';
		if(!this.tagclick) this.tagclick='dt';
		if(!this.tagcache) this.tagcache='dd';

		if(this.nodeName.toLowerCase()==this.tagglobal){
			var dts=this.getElementsByTagName(this.tagclick);
			for(var i=0;i<dts.length;i++){
				var objA=getObj(dts[i]);
				var o=getObj(objA.nextSibling);
				while(o && o.nodeName.toLowerCase()!=this.tagclick){
					if(o.nodeName.toLowerCase()==this.tagcache){
						var objB=o;
						objA.onmouseover=this.mouseover;
						objB.onmouseout=this.mouseout;
						objA.permute=objB;
						objB.permute=objA;
						if(objB.getElementsByTagName('a')[0]){
							if(objB.getElementsByTagName('a')[0].title) objB.title=objB.getElementsByTagName('a')[0].title;
							objB.onclick=function(){ window.location.href=this.getElementsByTagName('a')[0].href; };
						}
						o=false;
					}else o=getObj(o.nextSibling);
				}
			}
		}
	},
	mouseover: function(){
		this.setStyle('display','none');
		this.permute.setStyle('display','block');
	},
	mouseout: function(){
		this.setStyle('display','none');
		this.permute.setStyle('display','block');
	}
};


function applyclass(method,classname){
	var Elms=getArrayClass(classname);
	if(Elms && window[method]){
		for(var e=0;e<Elms.length;e++){
			var o=getObj(Elms[e]);
			o.num=e+1;
			if(arguments[2]) o.Args=arguments[2];
			o.extendwith(window[method]);
		}
	}
}