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

(function(d){d.widgetkit={};d.widgetkit.effects={defaults:{slices:20,duration:500,animated:"random",easing:"swing"},show:function(){d.widgetkit.effects[this.animated]?(this.fx=!0,d.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)];d.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)];d.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(){d.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(){d.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(e,b){a.current.css("left",(Math.abs(b.start)-Math.abs(e))*(a.animated=="scrollRight"?-1:1))}})},scrollRight:function(){d.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(e,b){a.current.css("left",(Math.abs(b.start)-Math.abs(e))*(a.dir=="right"?-1:1))}})},slice:function(){k(this);var a=this,e=this.next.find("img:first"),b=this.animated=="sliceUp"?"bottom":"top",g=0;if(e.length){for(var c=Math.round(this.slicer.width()/this.options.slices),i=0;i<this.options.slices;i++){var j=
i==this.options.slices-1?this.slicer.width()-c*i:c;this.animated=="sliceUpDown"&&(b=(i%2+2)%2==0?"top":"bottom");this.slicer.append(d("<div />").css({position:"absolute",left:c*i+"px",width:j+"px",height:0,background:"url("+e.attr("src")+") no-repeat -"+(c+i*c-c)+"px "+b,opacity:0}).css(b,0))}this.slices=this.slicer.children();this.current.css({"z-index":1});this.slicer.show();var h=this.wrapper.height();this.slices.each(function(b){d(this).css3animate({height:h,opacity:1},a.duration+100,"linear",
function(){if(b==a.slices.length-1)a.fx=null,a.next.css({"z-index":"2",left:0,top:0}).show(),a.current.hide(),a.slicer.remove()},g);g+=50})}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},sliceUp:function(){d.widgetkit.effects.slice.apply(this)},sliceDown:function(){d.widgetkit.effects.slice.apply(this)},sliceUpDown:function(){d.widgetkit.effects.slice.apply(this)},fold:function(){k(this);var a=this,e=this.next.find("img:first"),b=0;if(e.length){for(var g=
Math.round(this.slicer.width()/this.options.slices),c=0;c<this.options.slices;c++)this.slicer.append(d("<div />").css({position:"absolute",left:g*c+"px",width:"0px",top:"0px",height:a.options.height,background:"url("+e.attr("src")+") no-repeat -"+(g+c*g-g)+"px 0%",opacity:0}));this.slices=this.slicer.children();this.current.css({"z-index":1});this.slicer.show();this.slices.each(function(c){var e=c==a.options.slices-1?a.slicer.width()-g*c:g;d(this).css3animate({opacity:1,width:e},a.duration,"linear",
function(){if(c==a.slices.length-1)a.fx=null,a.next.css({"z-index":"2",left:0,top:0}).show(),a.current.hide(),a.slicer.remove()},b+100);b+=50})}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},puzzle:function(){k(this);var a=this,e=Math.round(this.options.slices/2),b=Math.round(this.wrapper.width()/e),g=Math.round(this.wrapper.height()/b),c=Math.round(this.wrapper.height()/g),i=0,j=this.next.find("img:first");if(j.length){for(var h=0;h<g;h++)for(var f=0;f<
e;f++)this.slicer.append(d("<div />").css({position:"absolute",left:b*f+"px",width:f==e-1?this.wrapper.width()-b*f+"px":b+"px",top:c*h+"px",height:c+"px",background:"url("+j.attr("src")+") no-repeat -"+(b+f*b-b)+"px -"+(c+h*c-c)+"px",opacity:0}));this.slices=o(this.slicer.children());this.current.css({"z-index":1});this.slicer.show();this.slices.each(function(b){d(this).css3animate({opacity:1},a.duration,"linear",function(){if(b==a.slices.length-1)a.fx=null,a.next.css({"z-index":"2",left:0,top:0}).show(),
a.current.hide(),a.slicer.hide().remove()},i);i+=50})}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},boxes:function(){k(this);var a=this,e=Math.round(this.options.slices/2),b=Math.round(this.wrapper.width()/e),g=Math.round(this.wrapper.height()/b),c=Math.round(this.wrapper.height()/g),i=0,j=this.next.find("img:first");if(j.length){for(var h=0;h<g;h++)for(var f=0;f<e;f++)this.slicer.append(d("<div />").css({position:"absolute",left:b*f+"px",width:f==e-1?this.wrapper.width()-
b*f+"px":b+"px",top:c*h+"px",height:c+"px",background:"url("+j.attr("src")+") no-repeat -"+(b+f*b-b)+"px -"+(c+h*c-c)+"px",opacity:0}));this.slices=this.slicer.children();this.current.css({"z-index":1});this.slicer.show();var l=0,m=0,n=[];n[l]=[];b=this.animated=="boxesRtl"?this.slices._reverse():this.slices;b.each(function(){n[l][m]=d(this);m++;m==e&&(l++,m=0,n[l]=[])});for(f=c=0;f<e*g;f++){j=f;for(h=0;h<g;h++)j>=0&&j<e&&(function(b,c,e,d,g){var f=n[b][c],h=f.width(),i=f.height();f.width(0).height(0);
d==g-1?setTimeout(function(){f.css3animate({opacity:"1",width:h,height:i},a.duration,"",function(){a.fx=null;a.next.css({"z-index":"2",left:0,top:0}).show();a.current.hide();a.slicer.hide().remove()})},100+e):setTimeout(function(){f.css3animate({opacity:"1",width:h,height:i},100+a.duration)},100+e)}(h,j,i,c,b.length),c++),j--;i+=100}}else this.next.css({"z-index":"2",left:0,top:0}).show(),this.current.hide(),this.fx=null},boxesRtl:function(){d.widgetkit.effects.boxes.apply(this)}};d.fn._reverse=[].reverse;
var o=function(a){for(var e,b,d=a.length;d;e=parseInt(Math.random()*d),b=a[--d],a[d]=a[e],a[e]=b);return a},k=function(a){a.slicer=d("<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);

