Fx.Scroll=Fx.Base.extend({
options:{
overflown:[],
offset:{'x': 0, 'y':0}
},
initialize:function(element,options){
this.now=[];
this.element=$(element);
this.bound={'stop':this.stop.bind(this,false)};
this.addEvent('onStart',function(){
document.addEvent('mousewheel',this.bound.stop);
}.bind(this));
this.removeEvent('onComplete',function(){
document.removeEvent('mousewheel',this.bound.stop);
}.bind(this));
this.parent(options);
},
setNow:function(){
for(var i=0;i<2;i++)this.now[i]=this.compute(this.from[i],this.to[i]);
},
scrollTo:function(x,y){
if(this.timer && this.options.wait)return this;
var el=this.element.getSize();
var values={'x': x, 'y':y};
for(var z in el.size){
var max=el.scrollSize[z]-el.size[z];
if($chk(values[z]))values[z]=($type(values[z])=='number')?values[z].limit(0,max):max;
else values[z]=el.scroll[z];
values[z]+=this.options.offset[z];
}
return this.start([el.scroll.x,el.scroll.y],[values.x,values.y]);
},
toTop:function(){
return this.scrollTo(false,0);
},
toBottom:function(){
return this.scrollTo(false,'full');
},
toLeft:function(){
return this.scrollTo(0,false);
},
toRight:function(){
return this.scrollTo('full',false);
},
toElement:function(el){
var parent=this.element.getPosition(this.options.overflown);
var target=$(el).getPosition(this.options.overflown);
return this.scrollTo(target.x-parent.x,target.y-parent.y);
},
increase:function(){
this.element.scrollTo(this.now[0],this.now[1]);
}
});
var XHR=new Class({
options:{
method:'post',
async:true,
onRequest:Class.empty,
onSuccess:Class.empty,
onFailure:Class.empty,
urlEncoded:true,
encoding:'utf-8',
autoCancel:false,
headers:{}
},
setTransport:function(){
this.transport=(window.XMLHttpRequest)?new XMLHttpRequest():(window.ie?new ActiveXObject('Microsoft.XMLHTTP'):false);
return this;
},
initialize:function(options){
this.setTransport().setOptions(options);
this.options.isSuccess=this.options.isSuccess || this.isSuccess;
this.headers={};
if(this.options.urlEncoded && this.options.method=='post'){
var encoding=(this.options.encoding)?'; charset=' + this.options.encoding : '';
this.setHeader('Content-type', 'application/x-www-form-urlencoded'+encoding);
}
if(this.options.initialize)this.options.initialize.call(this);
},
onStateChange:function(){
if(this.transport.readyState!=4 ||!this.running)return;
this.running=false;
var status=0;
try{status=this.transport.status}catch(e){};
if(this.options.isSuccess.call(this,status))this.onSuccess();
else this.onFailure();
this.transport.onreadystatechange=Class.empty;
},
isSuccess:function(status){
return((status>=200)&&(status<300));
},
onSuccess:function(){
this.response={
'text':this.transport.responseText,
'xml':this.transport.responseXML
};
this.fireEvent('onSuccess',[this.response.text,this.response.xml]);
this.callChain();
},
onFailure:function(){
this.fireEvent('onFailure',this.transport);
},
setHeader:function(name,value){
this.headers[name]=value;
return this;
},
send:function(url,data){
if(this.options.autoCancel)this.cancel();
else if(this.running)return this;
this.running=true;
if(data && this.options.method=='get') url = url + (url.contains('?') ? '&' : '?')+data,data=null;
this.transport.open(this.options.method,url,this.options.async);
this.transport.onreadystatechange=this.onStateChange.bind(this);
if((this.options.method=='post') && this.transport.overrideMimeType) this.setHeader('Connection', 'close');
$extend(this.headers,this.options.headers);
for(var type in this.headers)try{this.transport.setRequestHeader(type,this.headers[type]);}catch(e){};
this.fireEvent('onRequest');
this.transport.send($pick(data,null));
return this;
},
cancel:function(){
if(!this.running)return this;
this.running=false;
this.transport.abort();
this.transport.onreadystatechange=Class.empty;
this.setTransport();
this.fireEvent('onCancel');
return this;
}
});
XHR.implement(new Chain,new Events,new Options);
var Ajax=XHR.extend({
options:{
data:null,
update:null,
onComplete:Class.empty,
evalScripts:false,
evalResponse:false
},
initialize:function(url,options){
this.addEvent('onSuccess',this.onComplete);
this.setOptions(options);
this.options.data=this.options.data || this.options.postBody;
if(!['post', 'get'].contains(this.options.method)){
this._method='_method='+this.options.method;
this.options.method='post';
}
this.parent();
this.setHeader('X-Requested-With', 'XMLHttpRequest');
this.setHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
this.url=url;
},
onComplete:function(){
if(this.options.update)$(this.options.update).empty().setHTML(this.response.text);
if(this.options.evalScripts || this.options.evalResponse)this.evalScripts();
this.fireEvent('onComplete',[this.response.text,this.response.xml],20);
},
request:function(data){
data=data || this.options.data;
switch($type(data)){
case 'element':data=$(data).toQueryString();break;
case 'object':data=Object.toQueryString(data);
}
if(this._method)data=(data)?[this._method,data].join('&'):this._method;
return this.send(this.url,data);
},
evalScripts:function(){
if(this.options.evalResponse ||/(ecma|java)script/.test(this.getHeader('Content-type')))var scripts=this.response.text;
else{
var script,scripts=[],regexp=/<script[^>]*>([\s\S]*?)<\/script>/gi;
while((script=regexp.exec(this.response.text)))scripts.push(script[1]);
scripts=scripts.join('\n');
}
if(scripts)(window.execScript)?window.execScript(scripts):window.setTimeout(scripts,0);
},
getHeader:function(name){
try{return this.transport.getResponseHeader(name);}catch(e){};
return null;
}
});
Object.toQueryString=function(source){
var queryString=[];
for(var property in source)queryString.push(encodeURIComponent(property)+'='+encodeURIComponent(source[property]));
return queryString.join('&');
};
Element.extend({
send:function(options){
return new Ajax(this.getProperty('action'), $merge({postBody: this.toQueryString()}, options, {method: 'post'})).request();
}
});
Event.implement({
getTarget:function(tag){
var el=(this.srcElement?this.srcElement:this.target);
if(tag)while(el && el.nodeName!=tag)el=el.parentNode;
return el;
}
});
function tfpopup(adresse,nomFenetre,largeur,hauteur,scroll){
var largeurEcran=(screen.width-largeur)/2;
var hauteurEcran=(screen.height-hauteur)/2;
window.open(adresse,nomFenetre,'height=' + hauteur + ', width=' + largeur + ', top=' + hauteurEcran + ', left=' + largeurEcran + ', scrollbars=' + scroll + ', resizable=no');
}
function popup(adresse,nomFenetre,largeur,hauteur,scroll){
tfpopup(adresse,nomFenetre,largeur,hauteur,scroll);
}
function setPopup(params){
var el=$$(params.selector);
for(var i=0;i<el.length;i++){
addEvent(el[i],"click",function(e){
var object=getTarget(e?e:event,'A');
popup(object.href,params.title,params.height,params.width,1);
return false;
},this);
}
}
function fontSizeChange(classname,sizeAdjust,defaut){
if(!classname)return;
if(!sizeAdjust)sizeAdjust=1;
if(!defaut)defaut=11;
var elements=$$('.'+classname);
var oldSize=0,newSize=0;
$A(elements).each(function(el){
oldSize=el.getStyle('font-size');
oldSize=(oldSize?parseInt(oldSize.substr(0,oldSize.length-2),10):defaut);
newSize=oldSize+sizeAdjust;
el.setStyle('font-size',newSize + 'px');
});
}
function createXhrObject(){
var xhr;
if(window.XMLHttpRequest){
xhr=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
xhr=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
}
else{
xhr=false;
}
return xhr;
}
function sendData(data,url,method,callback){
var xhrObj=createXhrObject();
xhrObj.onreadystatechange=function(){
if(xhrObj.readyState==4 && xhrObj.status==200)
callback(xhrObj);
}
if(method=="GET"){
xhrObj.open("GET",(data?url+"?"+data:url),true);
xhrObj.send(null);
}
else if(method=="POST"){
xhrObj.open("POST",url,true);
xhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhrObj.send(data);
}
}
var Overlay={};
Overlay=new Class({
getOptions:function(){
return{
fxDuration:150,
maxOpacity:.5,
className:'overlay',
zIndex:10000
};
},
initialize:function(options){
this.element=this.element || null;
this.options=Object.extend(this.getOptions(),options ||{});
this.setOverlay();
},
setOverlay:function(){
this.overlay=new Element('div').setStyles({
display:'none',
position:'absolute',
top:0,
left:0,
'z-index':this.options.zIndex
}).addClass(this.options.className).injectInside(document.body);
this.overlay.addEvent('click',this.hideFn.bind(this));
this.overlayFx=this.overlay.effect('opacity',{
duration:this.options.fxDuration,
wait:false,
onComplete:this.callBack.bind(this)
}).hide();
},
hideFn:function(e){
this.hide();
new Event(e).stop();
},
show:function(el){
if(this.showed)return;
this.showed=true;
this.el=$(el).setStyles({
position:'absolute',
'z-index': this.options.zIndex + 1 // positionne l'élément un cran au dessus du fond
});
this.overlay.setStyles({
display:'block',
width:Window.getWidth()+'px',
height:Math.max(Window.getScrollHeight(),Window.getHeight())+'px'
});
this.overlayFx.start(0,this.options.maxOpacity);
this.showHide(1);
},
hide:function(){
this.showed=false;
this.el.setStyle('display','none');
this.overlayFx.start(this.options.maxOpacity,0);
},
showEl:function(el){
el.setStyles({
display:'block',
visibility:'hidden'
}).setStyles({
visibility:'visible',
top:((Window.getHeight()-el.offsetHeight)/2)+Window.getScrollTop()+'px',
left:((Window.getWidth()-el.offsetWidth)/2)+'px'
});
},
hideEl:function(){
this.overlay.setStyle('display','none');
this.showHide();
},
callBack:function(){
if(this.showed)this.showEl(this.el);
else this.hideEl();
},
showHide:function(open){
var els=$$('object, embed' + (window.ie && !window.ie7 ? ',select' : ''));
$A(els).each(function(el){el.style.visibility=open?'hidden' : '';});
}
});



window.onDomReady(daMenu_onload);
var daMenuTimeout=null;
var daMenuCurrent=null;
function daMenu_onload(){
daMenu_init('headermenu');
}
function daMenu_hideall(id){
var navroot=document.getElementById(id);
if(!navroot)return;
var li=navroot.getElementsByTagName("LI");
for(var i=0;i<li.length;i++){
var active=li[i].className.indexOf("active");
if(active>=0)
li[i].className=li[i].className.substr(0,active);
}
}
function daMenu_show(elt){
if(!elt)
return;
if(elt.className.indexOf("active")<0)
elt.className+=" active";
}
function daMenu_init(id){
var navroot=document.getElementById(id);
if(!navroot)return;
var li=navroot.getElementsByTagName("LI");
for(var i=0;i<li.length;i++){
var ul=li[i].getElementsByTagName("UL");
if(ul.length>0){
li[i].onmouseover=function(){
if(daMenuTimeout){
daMenuTimeout=clearTimeout(daMenuTimeout);
}
if(this.className.indexOf("active")<0){
daMenu_hideall(id);
daMenu_show(this);
}
}
if(li[i].className.indexOf("active")>=0){
daMenuCurrent=li[i];
}
}
}
document.getElementById('headermenu').onmouseout=function(){
if(!daMenuTimeout){
daMenuTimeout=setTimeout("daMenu_default()",5000);
}
}
}
function daMenu_default(){
daMenu_hideall('headermenu');
daMenu_show(daMenuCurrent);
}
window.onDomReady(dTable2_init);
function dTable2_init(){
var table=document.getElementsByTagName("TABLE");
for(var i=0;i<table.length;i++){
if(table[i].className.indexOf('cal')>=0){
var th=table[i].getElementsByTagName("TH");
if(th.length==0) return false;
th[0].onclick=dTable2_showHide;
if(th[0].className.indexOf('tetiere-ferme')>=0){
var tbody=table[i].getElementsByTagName("TBODY");
var tr=tbody[0].getElementsByTagName("TR");
for(var j=0;j<tr.length;j++){
tr[j].style.display='none';
}
}
else{
th[0].className='tetiere-ouvert';
}
}
}
}
function dTable2_showHide(e){
var table=new Event(e).getTarget('TABLE');
var tbody=table.getElementsByTagName("TBODY");
var tr=tbody[0].getElementsByTagName("TR");
for(var i=0;i<tr.length;i++){
tr[i].style.display=(tr[i].style.display=='none' ? (document.all ? 'block' : 'table-row') : 'none');
}
this.className=(this.className=='tetiere-ouvert' ? 'tetiere-ferme' : 'tetiere-ouvert');
}
window.onDomReady(faq_init);
function faq_init(){
var faq=document.getElementById("faq");
if(faq){
var ul=faq.getElementsByTagName("UL");
for(var i=0,n1=ul.length;i<n1;i++){
var li=ul[i].getElementsByTagName("LI");
for(var j=0,n2=li.length;j<n2;j++){
var div=li[j].getElementsByTagName("DIV");
div[0].onclick=function(){
the_div=this.nextSibling
while(the_div.nodeName && the_div.nodeName!="DIV")
the_div=the_div.nextSibling;
the_div.style.display=(the_div.style.display=="block"?"none":"block");
}
}
}
}
}