/**
* TransitionBox jQuery plugin
* @version : 1.09 iXoft 2010.10.26 powered by Kynes. easing added. first positionning fixed.
* @dependency: jQuery 1.4.2 or newer

TERMS OF USE

Copyright © 2010 iXoft
All rights reserved.

This code is distributed as freeware, so it can be used for free but can not be sold.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function(s){function u(l,b){var o=true;if(isNaN(parseInt(b.height,10))||parseInt(b.height,10)!=b.height-0)o=false;else if(b.height<1)o=false;var p=true;if(isNaN(parseInt(b.width,10))||parseInt(b.width,10)!=b.width-0)p=false;else if(b.width<1)p=false;if(!o){if(!p)b.width=400;b.height=b.width}if(!p){if(!o)b.height=400;b.width=b.height}var r=s('<div style="position: relative; top: 0; left: 0; width: '+b.width+"px; height: "+b.height+'px; overflow: hidden;">').appendTo(l),g=s('<img src="" />').appendTo(r);
g.css({position:"absolute",top:0,left:0,"max-width":b.width+"px","max-height":b.height+"px"});var f=s('<img src="" />').appendTo(r);f.css({position:"absolute",top:b.height,left:0,"max-width":b.width+"px","max-height":b.height+"px"});var m=true,d={src:b.image,top:0,left:0,width:0,height:0,bottom:0,right:0};b.image!=""&&Object.prototype.toString(b.image)!=="[object String]"&&g.bind("load",function(){d.width=parseInt(g.width());d.height=parseInt(g.height());d.top=Math.floor((b.height-d.height)/2);d.left=
Math.floor((b.width-d.width)/2);d.bottom=d.top+d.height;d.right=d.left+d.width;g.css({top:d.top+"px",left:d.left+"px",opacity:1});g.unbind("load")}).attr("src",b.image);var i={src:"",top:b.height,left:0,width:0,height:0},v={slidetop:true,slidebottom:true,slideleft:true,slideright:true,crosstop:true,crossbottom:true,crossleft:true,crossright:true,stretchtop:true,stretchbottom:true,stretchleft:true,stretchright:true,fliphorizontal:true,flipvertical:true,zoom:true,fade:true},w={linear:true,easeinquad:true,
easeincubic:true,easeinoutcubic:true,easeoutcubic:true,easeoutbounce:true,easeoutsoftbounce:true},e=this,t=this;this.show=function(a,k,c,h,j,n){if(f.is(":animated")||g.is(":animated"))return this;a=this.getParamFichierImage(a);k=this.getParamEffet(k);c=this.getParamDuration(c);h=this.getParamEasing(h);var q=(j=this.getParamFadeOut(j))?0:1;n=typeof n=="function"?n:s.noop;this.prepareEffect();switch(k){case "slidetop":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("bottom");m?e.hideMain(c,
j):g.stop(true,false).animate({top:-d.height-1+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "slidebottom":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("top");m?e.hideMain(c,j):g.stop(true,false).animate({top:b.height+1+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "slideleft":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("right");m?e.hideMain(c,j):g.stop(true,false).animate({left:-d.width-1+"px",opacity:q},c,h);e.animeTemp(a,
c,h,n)}).attr("src",a);break;case "slideright":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("left");m?e.hideMain(c,j):g.stop(true,false).animate({left:b.width+1+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "crosstop":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("bottom");m?e.hideMain(c,j):g.stop(true,false).animate({top:b.height+1+"px",opacity:q},c);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "crossbottom":f.bind("load",function(){e.prepareAnimate(a);
e.placementTemp("top");m?e.hideMain(c,j):g.stop(true,false).animate({top:-d.height-1+"px",opacity:q},c);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "crossleft":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("right");m?e.hideMain(c,j):g.stop(true,false).animate({left:b.width+1+"px",opacity:q},c);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "crossright":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("left");m?e.hideMain(c,j):g.stop(true,false).animate({left:-d.width-
1+"px",opacity:q},c);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "stretchtop":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("bottom");f.css({width:i.width+"px",height:0});m?e.hideMain(c,j):g.stop(true,false).animate({top:d.top+"px",left:d.left+"px",width:d.width+"px",height:0,opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "stretchbottom":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("top",true);f.css({width:i.width+"px",height:0});m?e.hideMain(c,
j):g.stop(true,false).animate({top:d.bottom+"px",height:0,width:d.width+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "stretchleft":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("right");f.css({width:0,height:i.height+"px"});m?e.hideMain(c,j):g.stop(true,false).animate({left:d.left+"px",width:0,height:d.height+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "stretchright":f.bind("load",function(){e.prepareAnimate(a);e.placementTemp("left",
true);f.css({width:0,height:i.height+"px"});m?e.hideMain(c,j):g.stop(true,false).animate({left:d.right+"px",width:0,height:d.height+"px",opacity:q},c,h);e.animeTemp(a,c,h,n)}).attr("src",a);break;case "flipvertical":f.bind("load",function(){e.prepareAnimate(a);f.css({top:Math.floor(b.height/2)+"px",left:Math.floor((b.width-i.width)/2)+"px",width:i.width+"px",height:0,opacity:0});g.stop(true,false).animate({top:Math.floor(b.height/2)+"px",left:d.left+"px",width:d.width+"px",height:0,opacity:q},c,function(){f.stop(true,
false).animate({top:i.top+"px",left:i.left+"px",width:i.width+"px",height:i.height+"px",opacity:1},c,h,function(){t.endEffect(a);n.call(this)})});f.unbind("load")}).attr("src",a);break;case "fliphorizontal":f.bind("load",function(){e.prepareAnimate(a);f.css({top:Math.floor((b.height-i.height)/2)+"px",left:Math.floor(b.width/2)+"px",width:0,height:i.height+"px",opacity:0});g.stop(true,false).animate({top:d.top+"px",left:Math.floor(b.width/2)+"px",width:0,height:d.height+"px",opacity:q},c,function(){f.stop(true,
false).animate({top:i.top+"px",left:i.left+"px",width:i.width+"px",height:i.height+"px",opacity:1},c,h,function(){t.endEffect(a);n.call(this)})});f.unbind("load")}).attr("src",a);break;case "zoom":f.bind("load",function(){e.prepareAnimate(a);f.css({top:Math.floor(b.height/2)+"px",left:Math.floor(b.width/2)+"px",width:0,height:0,opacity:0});m&&e.hideMain(c,j);g.stop(true,false).animate({opacity:0},c*1.2,h);f.stop(true,false).animate({top:i.top+"px",left:i.left+"px",width:i.width+"px",height:i.height+
"px",opacity:1},c,h,function(){t.endEffect(a);n.call(this)});f.unbind("load")}).attr("src",a);break;default:f.bind("load",function(){e.prepareAnimate(a);f.css({top:i.top+"px",left:i.left+"px",opacity:0});m?e.hideMain(c,j):g.stop(true,false).animate({opacity:0},c);f.stop(true,false).animate({opacity:1},c,h,function(){t.endEffect(a);n.call(this)});f.unbind("load")}).attr("src",a)}b.image=a;return this};this.hide=function(a,k,c,h,j){if(f.is(":animated")||g.is(":animated"))return this;a=this.getParamEffet(a);
k=this.getParamDuration(k);c=this.getParamEasing(c);h=(h=this.getParamFadeOut(h))?0:1;j=typeof j=="function"?j:s.noop;this.prepareEffect();if(a=="slidetop"||a=="crossbottom")g.stop(true,false).animate({top:-d.height-1+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="slidebottom"||a=="crosstop")g.stop(true,false).animate({top:b.height+1+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="slideleft"||a=="crossright")g.stop(true,false).animate({left:-b.width-
1+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="slideright"||a=="crossleft")g.stop(true,false).animate({left:b.width+1+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="stretchtop")g.stop(true,false).animate({height:0,width:d.width+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="stretchbottom")g.stop(true,false).animate({top:Math.min(b.height,d.height*1.1),height:0,width:d.width+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});
else if(a=="stretchleft")g.stop(true,false).animate({width:0,height:d.height+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="stretchright")g.stop(true,false).animate({left:Math.min(b.width,d.right*1.1)+"px",width:0,height:d.height+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else if(a=="flipvertical")g.stop(true,false).animate({top:Math.floor(b.height/2)+"px",left:d.left+"px",width:d.width+"px",height:0,opacity:h},k,c,function(){e.clearMain();j.call(this)});
else if(a=="fliphorizontal")g.stop(true,false).animate({top:d.top+"px",left:Math.floor(b.width/2)+"px",width:0,height:d.height+"px",opacity:h},k,c,function(){e.clearMain();j.call(this)});else a=="zoom"?g.stop(true,false).animate({top:Math.floor(b.height/2)+"px",left:Math.floor(b.width/2)+"px",width:0,height:0,opacity:h},k,c,function(){e.clearMain();j.call(this)}):g.stop(true,false).animate({opacity:0},k,c,function(){e.clearMain();j.call(this)});this.clearCache();return this};this.clearCache=function(){m=
true;return this};this.image=function(a){if(a==undefined)return g.attr("src");else{b.image=this.getParamFichierImage(a);return this}};this.effect=function(a){if(a==undefined)return b.effect;else{b.effect=this.getParamEffet(a);return this}};this.duration=function(a){if(a==undefined)return b.duration;else{b.duration=this.getParamDuration(a);return this}};this.easing=function(a){if(a==undefined)return b.easing;else{b.easing=this.getParamEasing(a);return this}};this.fadeOut=function(a){if(a==undefined)return b.fadeOut;
else{b.fadeOut=this.getParamFadeOut(a);return this}};this.getConf=function(){return b};this.getImage=function(){return g};this.getRoot=function(){return r};this.prepareEffect=function(){f.attr("src","");d.src=g.attr("src");if(d.src!=""){d.top=parseInt(g.css("top"));d.left=parseInt(g.css("left"));d.width=parseInt(g.width());d.height=parseInt(g.height());d.bottom=d.top+d.height;d.right=d.left+d.width}else{d.top=0;d.left=0;d.width=0;d.height=0;d.bottom=0;d.right=0}f.css({top:b.height+20+"px",left:0,
opacity:1})};this.prepareAnimate=function(a){f.css({width:"auto",height:"auto"});i.src=a;i.width=f.width();i.height=f.height();i.top=Math.floor((b.height-i.height)/2);i.left=Math.floor((b.width-i.width)/2)};this.hideMain=function(a,k){var c=k?a:50;g.stop(true,false).animate({opacity:0},c);m=false};this.placementTemp=function(a,k){if(k==undefined)k=false;switch(a){case "bottom":var c=d.bottom==0||m?b.height:d.bottom;f.css({top:c+"px",left:i.left+"px",opacity:0});break;case "left":c=k?0:i.width;c=d.left==
0||m?-c-1:d.left-c;f.css({top:i.top+"px",left:c+"px",opacity:0});break;case "right":c=d.right==0||m?b.width:d.right;f.css({top:i.top+"px",left:c+"px",opacity:0});break;default:c=k?0:i.height;c=d.top==0||m?-c-1:d.top-c;f.css({top:c+"px",left:i.left+"px",opacity:0})}};this.animeTemp=function(a,k,c,h){f.stop(true,false).animate({top:i.top+"px",left:i.left+"px",width:i.width+"px",height:i.height+"px",opacity:1},k,c,function(){e.endEffect(a);h.call(this)});f.unbind("load")};this.endEffect=function(a){g.stop(true,
false).attr("src",a).css({top:i.top+"px",left:i.left+"px",width:i.width+"px",height:i.height+"px",opacity:1});f.css({top:b.height+20+"px",left:0,opacity:0})};this.clearMain=function(){g.attr("src","");b.image=""};this.displayError=function(a){throw Error("Error in TransitionBox: "+a,"");};this.getParamFichierImage=function(a){if(a==undefined)a=b.image;else if(Object.prototype.toString.call(a)!=="[object String]")a="";return a};this.getParamEffet=function(a){if(a==undefined)a=b.effect;else if(Object.prototype.toString.call(a)!==
"[object String]")a="fade";else if(a=="")a="fade";else{a=a.toLowerCase();v.hasOwnProperty(a)||(a="fade")}return a};this.getParamEasing=function(a){if(a==undefined)a=b.easing;else if(Object.prototype.toString.call(a)!=="[object String]")a="linear";else if(a=="")a="linear";else{a=a.toLowerCase();w.hasOwnProperty(a)||(a="linear")}return a};this.getParamDuration=function(a){a=a==undefined?b.duration:isNaN(parseInt(a,10))||parseInt(a,10)!=a-0?600:Math.min(1E4,Math.max(1,parseInt(a)));return parseInt(a)};
this.getParamFadeOut=function(a){if(a==undefined)a=b.fadeOut;else if(a!==false)a=true;return a};this.getParamApi=function(a){if(a==undefined)a=b.api;else if(a!==false)a=true;return a}}jQuery.easing.easeinquad=function(l,b,o,p,r){return p*(b/=r)*b+o};jQuery.easing.easeincubic=function(l,b,o,p,r){return p*(b/=r)*b*b+o};jQuery.easing.easeinoutcubic=function(l,b,o,p,r){if((b/=r/2)<1)return p/2*b*b*b+o;return p/2*((b-=2)*b*b+2)+o};jQuery.easing.easeoutcubic=function(l,b,o,p,r){return p*((b=b/r-1)*b*b+
1)+o};jQuery.easing.easeoutbounce=function(l,b,o,p,r){return(b/=r)<1/2.75?p*7.5625*b*b+o:b<2/2.75?p*(7.5625*(b-=1.5/2.75)*b+0.75)+o:b<2.5/2.75?p*(7.5625*(b-=2.25/2.75)*b+0.9375)+o:p*(7.5625*(b-=2.625/2.75)*b+0.984375)+o};jQuery.easing.easeoutsoftbounce=function(l){return l<0.6?2.7777*l*l:l<0.88?4.2327+l*-9.0613+l*l*6.1225:10.7773+l*-20.8879+l*l*11.1106};s.fn.transitionBox=function(l){l=s.extend(true,{},{width:0,height:0,duration:600,effect:"fade",easing:"linear",fadeOut:true,image:"",api:true},l);
var b=new u(this,l);return l.api?b:this}})(jQuery);
