// script issu de : http://www.webbricks.org/bricks/Animate/
function transfer(a,b){var c,transfered={};for(c in b){transfered[c]=b[c]}for(c in a){transfered[c]=a[c]}return transfered}function easeInOut(a,b,c,d,e){var f=b-a;var g=a+(Math.pow(((1/c)*d),e)*f);return g}function Animate(d,e){this.defSettings={"elem":window.document.body,"from":{},"to":{},"restart":false,"ease":1,"duration":1000,"frameRate":30,"onFinish":false};this.defSettings=transfer(d,this.defSettings);this.guessProp=function(a){var b=this.options.elem;switch(a){case'width':return b.offsetWidth+'px';case'height':return b.offsetHeight+'px';case'top':return(typeof(getPos)=='undefined')?'0px':getPos(b).t+'px';case'bottom':return(typeof(getPos)=='undefined')?'0px':getPos(b).b+'px';case'left':return(typeof(getPos)=='undefined')?'0px':getPos(b).l+'px';case'right':return(typeof(getPos)=='undefined')?'0px':getPos(b).r+'px';case'borderWidth':return'1px';case'borderColor':return'rgb(0,0,0)';case'backgroundColor':return'rgb(255,255,255)';case'color':return'rgb(0,0,0)';case'opacity':return 1;default:return 0}return false};this.readProp=function(a){var b={};b.asked=a+'';b.unit=b.asked.match(/px|em|%/);b.clean=parseFloat(b.asked);var c=b.asked.match(/rgb|(#[a-f0-9]{3,6})/i);if(typeof rgbString2Array=='function'&&typeof sharp2rgb=='function'&&c){b.clean=b.asked;b.rgb=rgbString2Array(sharp2rgb(b.asked));if(!b.rgb){b.rgb=rgbString2Array(b.asked)}}return b};this.readFromTo=function(a){if(!a){return false}var i,lg,tmp,prop,eachDeclared={};if(typeof a=='string'){a=a.trim();var b=a.split(/;/);lg=b.length;for(i=0;i<lg;i++){if(!b[i]){b.splice(i,1)}}lg=b.length;a={};for(i=0;i<lg;i++){tmp=b[i].split(/:/);prop=tmp[0].trim();a[prop]=tmp[1].trim()}}for(prop in a){eachDeclared[prop]=this.readProp(a[prop]+'')}return eachDeclared};this.go=function(a){var b,prop;this.options=transfer(a?a:{},this.defSettings);var c=this.options.elem.style;this.totalFrames=Math.ceil(this.options.duration/1000*this.options.frameRate);if(this.options.restart){this.frameNb=0}else{this.frameNb=this.framesLeft?this.framesLeft:0}this.from=this.readFromTo(this.options.from?this.options.from:this.defSettings.from);this.to=this.readFromTo(this.options.to?this.options.to:this.defSettings.to);for(prop in this.to){if(!this.from[prop]){if(c[prop]||c[prop]===0){this.from[prop]=this.readProp(c[prop])}if(!this.from[prop]){this.from[prop]=this.readProp(this.guessProp(prop))}}}for(prop in this.from){c[prop]=this.from[prop].clean}this.next()};this.frame=function(){var a=this.options.elem.style;var c,coulFrom,coulTo,prop;for(prop in this.to){if(this.to[prop].rgb){coulTo=this.to[prop].rgb;coulFrom=this.from[prop].rgb;var r=easeInOut(parseInt(coulFrom[0],10),parseInt(coulTo[0],10),this.totalFrames,this.frameNb,this.options.ease);var g=easeInOut(parseInt(coulFrom[1],10),parseInt(coulTo[1],10),this.totalFrames,this.frameNb,this.options.ease);var b=easeInOut(parseInt(coulFrom[2],10),parseInt(coulTo[2],10),this.totalFrames,this.frameNb,this.options.ease);a[prop]='rgb('+Math.round(r)+','+Math.round(g)+','+Math.round(b)+')'}else{c=easeInOut(this.from[prop].clean,this.to[prop].clean,this.totalFrames,this.frameNb,this.options.ease);if(this.to[prop].units==='px'){c=parseInt(c,10)}a[prop]=c+this.to[prop].unit;if(prop==='opacity'&&typeof setOpacity=='function'){setOpacity(this.options.elem,c)}}}if(this.frameNb===this.totalFrames){if(typeof this.options.onFinish=='function'){setTimeout(this.options.onFinish,1)}}else{this.frameNb++;this.framesLeft=this.totalFrames-this.frameNb;this.next()}};this.next=function(){this.prog=setTimeout(function(){f.frame()},1000/this.options.frameRate)};this.pause=function(){clearTimeout(this.prog)};var f=this;if(e){this.go(typeof e=='object'?e:{})}}
