/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function(c){function n(a){a=a||{};a.transition&&(a[q+"transition"]=a.transition);a.transform&&(a[q+"transform"]=a.transform);return a}var l=document.createElement("div"),l=l.style,m={},s="-webkit- -moz- -o- -ms- -khtml-".split(" "),r="Webkit Moz O ms Khtml".split(" "),q="";m.transition=!1;for(var j=0;j<r.length;j++)if(l[r[j]+"Transition"]===""){m.transition=r[j]+"Transition";q=s[j];break}m.css3d=m.transition&&"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix&&!navigator.userAgent.match(/Chrome/i);
l=null;c.widgetkit={};c.widgetkit.effects={defaults:{slices:20,duration:500,animated:"random",easing:"swing"},bindTransitionEnd:function(a){var f=this;c(a).one("webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd",function(){f.fx=null;f.next.css({"z-index":"2",left:0,top:0}).show();f.current.hide();f.slicer.remove()})},show:function(){c.widgetkit.effects[this.animated]?(this.fx=!0,c.widgetkit.effects[this.animated].apply(this)):(this.current.hide(),this.next.show())},randomSimple:function(){var a=
["top","bottom","left","right","fade","scrollLeft","scrollRight","scroll"];this.animated=a[Math.floor(Math.random()*a.length)];c.widgetkit.effects[this.animated].apply(this)},randomFx:function(){var a=["sliceUp","sliceDown","sliceUpDown","fold","puzzle","boxes","boxesRtl"];this.animated=a[Math.floor(Math.random()*a.length)];c.widgetkit.effects[this.animated].apply(this)},top:function(){var a=this;this.current.css({"z-index":1});this.next.css({"z-index":2,display:"block",left:0,top:this.wrapper.height()*
(this.animated=="bottom"?2:-1)}).animate({top:0},{duration:a.duration,easing:a.easing,complete:function(){a.fx=null;a.current.hide()}})},bottom:function(){c.widgetkit.effects.top.apply(this)},left:function(){var a=this;this.current.css({"z-index":1});this.next.css({"z-index":2,display:"block",left:this.wrapper.width()*(this.animated=="right"?2:-1)}).animate({left:0},{duration:a.duration,easing:this.easing,complete:function(){a.fx=null;a.current.hide()}})},right:function(){c.widgetkit.effects.left.apply(this)},
fade:function(){var a=this;this.next.css({top:0,left:0,"z-index":1}).fadeIn(a.duration);this.current.css({"z-index":2}).fadeOut(this.duration,function(){a.fx=null;a.current.hide().css({opacity:1})})},scrollLeft:function(){var a=this;this.current.css({"z-index":1});this.next.css({"z-index":2,display:"block",left:this.wrapper.width()*(this.animated=="scrollRight"?1:-1)}).animate({left:0},{duration:a.duration,easing:this.easing,complete:function(){a.fx=null;a.current.hide()},step:function(c,b){a.current.css("left",
(Math.abs(b.start)-Math.abs(c))*(a.animated=="scrollRight"?-1:1))}})},scrollRight:function(){c.widgetkit.effects.scrollLeft.apply(this)},scroll:function(){var a=this;this.current.css({"z-index":1});this.next.css({"z-index":2,display:"block",left:this.wrapper.width()*(this.dir=="right"?1:-1)}).animate({left:0},{duration:a.duration,easing:this.easing,complete:function(){a.fx=null;a.current.hide()},step:function(c,b){a.current.css("left",(Math.abs(b.start)-Math.abs(c))*(a.dir=="right"?-1:1))}})},slice:function(){o(this);
var a=this,f=this.next.find("img:first"),b=this.animated=="sliceUp"?"bottom":"top";if(f.length){for(var d=Math.round(this.slicer.width()/this.options.slices),e=0;e<this.options.slices;e++){var k=e==this.options.slices-1?this.slicer.width()-d*e:d;this.animated=="sliceUpDown"&&(b=(e%2+2)%2==0?"top":"bottom");this.slicer.append(c("<div />").css(b,0).css(n({position:"absolute",left:d*e+"px",width:k+"px",height:0,background:"url("+f.attr("src")+") no-repeat -"+(d+e*d-d)+"px "+b,opacity:0,transition:"all "+
a.duration+"ms ease-in "+e*60+"ms"})))}this.slices=this.slicer.children();c.widgetkit.effects.bindTransitionEnd.apply(this,[this.slices.get(this.slices.length-1)]);this.current.css({"z-index":1});this.slicer.show();var i=this.wrapper.height();if(m.transition)this.slices.css(n({height:i,opacity:1}));else{var h=0;this.slices.each(function(b){var d=c(this);setTimeout(function(){d.animate({height:i,opacity:1},a.duration,function(){b==a.slices.length-1&&c(this).trigger("transitionend")})},h);h+=60})}}else this.next.css({"z-index":"2",
left:0,top:0}).show(),this.current.hide(),this.fx=null},sliceUp:function(){c.widgetkit.effects.slice.apply(this)},sliceDown:function(){c.widgetkit.effects.slice.apply(this)},sliceUpDown:function(){c.widgetkit.effects.slice.apply(this)},fold:function(){o(this);var a=this,f=this.next.find("img:first");if(f.length){for(var b=Math.round(this.slicer.width()/this.options.slices)+2,d=0;d<this.options.slices+1;d++){var e=d==a.options.slices?a.slicer.width()-b*d:b;this.slicer.append(c("<div />").css(n({position:"absolute",
left:b*d+"px",width:e,top:"0px",height:a.options.height,background:"url("+f.attr("src")+") no-repeat -"+(b+d*b-b)+"px 0%",opacity:0,transform:"scalex(0.0001)",transition:"all "+a.duration+"ms ease-in "+(100+d*60)+"ms"})))}this.slices=this.slicer.children();c.widgetkit.effects.bindTransitionEnd.apply(this,[this.slices.get(this.slices.length-1)]);this.current.css({"z-index":1});this.slicer.show();if(m.transition)this.slices.css(n({opacity:1,transform:"scalex(1)"}));else{var k=0;this.slices.width(0).each(function(d){var f=
d==a.options.slices-1?a.slicer.width()-b*d:b,e=c(this);setTimeout(function(){e.animate({opacity:1,width:f},a.duration,function(){d==a.slices.length-1&&c(this).trigger("transitionend")})},k+100);k+=50})}}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},puzzle:function(){o(this);var a=this,f=Math.round(this.options.slices/2),b=Math.round(this.wrapper.width()/f),d=Math.round(this.wrapper.height()/b),e=Math.round(this.wrapper.height()/d)+1,k=this.next.find("img:first");
if(k.length){for(var i=this.wrapper.width(),h=0;h<d;h++)for(var g=0;g<f;g++){var t=c("<div />").css(n({position:"absolute",left:b*g+"px",width:g==f-1?i-b*g+"px":b+"px",top:e*h+"px",height:e+"px",background:"url("+k.attr("src")+") no-repeat -"+(b+g*b-b)+"px -"+(e+h*e-e)+"px",opacity:0,transition:"all "+a.duration+"ms ease-in 0ms"}));j+=1;this.slicer.append(t)}this.slices=u(this.slicer.children());c.widgetkit.effects.bindTransitionEnd.apply(this,[this.slices.get(this.slices.length-1)]);this.current.css({"z-index":1});
this.slicer.show();this.slices.each(function(b){var d=c(this);setTimeout(function(){m.transition?d.css(n({opacity:1})):d.animate({opacity:1},a.duration,function(){b==a.slices.length-1&&c(this).trigger("transitionend")})},100+b*50)})}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},boxes:function(){o(this);var a=this,f=Math.round(this.options.slices/2),b=Math.round(this.wrapper.width()/f),d=Math.round(this.wrapper.height()/b),e=Math.round(this.wrapper.height()/
d)+1,k=0,i=this.next.find("img:first");if(i.length){for(var h=0;h<d;h++)for(var g=0;g<f;g++)this.slicer.append(c("<div />").css(n({position:"absolute",left:b*g+"px",width:0,top:e*h+"px",height:0,background:"url("+i.attr("src")+") no-repeat -"+(b+g*b-b)+"px -"+(e+h*e-e)+"px",opacity:0,transition:"all "+(100+a.duration)+"ms ease-in 0ms"})).data("base",{width:g==f-1?this.wrapper.width()-b*g:b,height:e}));this.slices=this.slicer.children();this.current.css({"z-index":1});this.slicer.show();var j=0,l=
0,p=[];p[j]=[];b=this.animated=="boxesRtl"?this.slices._reverse():this.slices;c.widgetkit.effects.bindTransitionEnd.apply(this,[b.get(b.length-1)]);b.each(function(){p[j][l]=c(this);l++;l==f&&(j++,l=0,p[j]=[])});for(g=e=0;g<f*d;g++){i=g;for(h=0;h<d;h++)i>=0&&i<f&&(function(b,d,f,e){var g=p[b][d];setTimeout(function(){m.transition?g.css({opacity:"1",width:g.data("base").width,height:g.data("base").height}):g.animate({opacity:"1",width:g.data("base").width,height:g.data("base").height},a.duration,function(){e==
a.slices.length&&c(this).trigger("transitionend")})},100+f)}(h,i,k,e,b.length),e++),i--;k+=100}}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},boxesRtl:function(){c.widgetkit.effects.boxes.apply(this)}};c.fn._reverse=[].reverse;var u=function(a){for(var c,b,d=a.length;d;c=parseInt(Math.random()*d),b=a[--d],a[d]=a[c],a[c]=b);return a},o=function(a){a.slicer=c("<li />").addClass("slices").css({top:"0px",left:"0px",position:"absolute",width:a.wrapper.width(),
height:a.element.height(),"z-index":3}).hide().appendTo(a.element)}})(jQuery);

