(function(a){var b;a.fn.updateTransition=function(a){b.updateTransition(a)};a.fn.updateCpAlign=function(a){b.updateCPanel(a)};a.fn.displayThumbs=function(a){b.showThumbs(a)};a.fn.displayDButtons=function(a){b.showDButtons(a)};a.fn.displayPlayButton=function(a){b.showPlayButton(a)};a.fn.displayTooltip=function(a){b.showTooltip(a)};a.fn.updateMouseoverCP=function(a){b.setMouseoverCP(a)};a.fn.updateMouseoverDesc=function(a){b.setMouseoverDesc(a)};a.fn.wtRotator=function(u){var r="TL",o="TR",n="TC",k="BL",w="BR",i="BC",h=0,f=1,e=2,c=new Array(40);c.fade=0;c["block.top"]=1;c["block.right"]=2;c["block.bottom"]=3;c["block.left"]=4;c["block.drop"]=5;c["diag.fade"]=6;c["diag.exp"]=7;c["diag.fade.exp"]=8;c["rev.diag.fade"]=9;c["rev.diag.exp"]=10;c["rev.diag.fade.exp"]=11;c["block.fade"]=12;c["block.exp"]=13;c["block.top.zz"]=14;c["block.bottom.zz"]=15;c["block.left.zz"]=16;c["block.right.zz"]=17;c["vert.tl"]=18;c["vert.tr"]=19;c["vert.bl"]=20;c["vert.br"]=21;c["fade.left"]=22;c["fade.right"]=23;c["alt.left"]=24;c["alt.right"]=25;c["blinds.left"]=26;c["blinds.right"]=27;c["horz.tl"]=28;c["horz.tr"]=29;c["horz.bl"]=30;c["horz.br"]=31;c["fade.top"]=32;c["fade.bottom"]=33;c["alt.top"]=34;c["alt.bottom"]=35;c["blinds.top"]=36;c["blinds.bottom"]=37;c.none=38;c.random=39;var g=5e3,j=800,d=100,p=800;function m(i,t,s,r,m,l){var j=t,f=s,b=r,e,k,g=null,q=function(){e=new Array(Math.ceil(j/b));for(var d="",c=0;c<e.length;c++)d+="<div class='vpiece' id='"+c+"'></div>";i.addToScreen(d);k=a("div.vpiece",i.$el);k.each(function(c){e[c]=a(this).css({left:c*b,width:b,height:f})})};this.clear=function(){clearInterval(g);k.stop().css({"z-index":2,opacity:0})};this.displayContent=function(a,b){o(a,b);p(a,b)};var o=function(d,a){if(a==c["vert.tl"]||a==c["vert.tr"])h(d,-f,0,b);else if(a==c["vert.bl"]||a==c["vert.br"])h(d,f,0,b);else if(a==c["alt.left"]||a==c["alt.right"])n(d,0);else if(a==c["blinds.left"]||a==c["blinds.right"])h(d,0,1,0);else h(d,0,0,b)},h=function(d,n,l,o){for(var i=d.src,g=(f-d.height)/2,k=(j-d.width)/2,c=0;c<e.length;c++){var h=-c*b+k;a(e[c]).css({background:m+" url('"+i+"') "+h+"px "+g+"px no-repeat",backgroundPositionX:h+"px",backgroundPositionY:g+"px",opacity:l,top:n,width:o,"z-index":3})}},n=function(d,l){for(var i=d.src,g=(f-d.height)/2,k=(j-d.width)/2,c=0;c<e.length;c++){var h=-c*b+k,n=c%2==0?-f:f;a(e[c]).css({background:m+" url('"+i+"') "+h+"px "+g+"px no-repeat",backgroundPositionX:h+"px",backgroundPositionY:g+"px",opacity:l,top:n,width:b,"z-index":3})}},p=function(k,f){var j=e.length-1;if(f==c["vert.tl"]||f==c["vert.bl"]||f==c["fade.left"]||f==c["blinds.left"]||f==c["alt.left"]){var h=0;g=setInterval(function(){a(e[h++]).animate({top:0,opacity:1,width:b},l,"",function(){a(this).attr("id")==j&&i.setComplete(k)});h==e.length&&clearInterval(g)},d)}else{var h=j;g=setInterval(function(){a(e[h--]).animate({top:0,opacity:1,width:b},l,"",function(){a(this).attr("id")==0&&i.setComplete(k)});h<0&&clearInterval(g)},d)}};q()}function l(i,t,s,r,m,l){var f=t,j=s,b=r,e,k,g=null,q=function(){e=new Array(Math.ceil(j/b));for(var d="",c=0;c<e.length;c++)d+="<div class='hpiece' id='"+c+"'></div>";i.addToScreen(d);k=a("div.hpiece",i.$el);k.each(function(c){e[c]=a(this).css({top:c*b,width:f,height:b})})};this.clear=function(){clearInterval(g);k.stop().css({"z-index":2,opacity:0})};this.displayContent=function(a,b){o(a,b);p(a,b)};var o=function(d,a){if(a==c["horz.tr"]||a==c["horz.br"])h(d,f,0,b);else if(a==c["horz.tl"]||a==c["horz.bl"])h(d,-f,0,b);else if(a==c["alt.top"]||a==c["alt.bottom"])n(d,0);else if(a==c["blinds.top"]||a==c["blinds.bottom"])h(d,0,1,0);else h(d,0,0,b)},h=function(d,k,l,o){for(var i=d.src,n=(j-d.height)/2,g=(f-d.width)/2,c=0;c<e.length;c++){var h=-c*b+n;a(e[c]).css({background:m+" url('"+i+"') "+g+"px "+h+"px no-repeat",backgroundPositionX:g+"px",backgroundPositionY:h+"px",opacity:l,left:k,height:o,"z-index":3})}},n=function(d,l){for(var i=d.src,n=(j-d.height)/2,g=(f-d.width)/2,c=0;c<e.length;c++){var h=-c*b+n,k=c%2==0?-f:f;a(e[c]).css({background:m+" url('"+i+"') "+g+"px "+h+"px no-repeat",backgroundPositionX:g+"px",backgroundPositionY:h+"px",opacity:l,left:k,height:b,"z-index":3})}},p=function(k,f){var j=e.length-1;if(f==c["horz.tl"]||f==c["horz.tr"]||f==c["fade.top"]||f==c["blinds.top"]||f==c["alt.top"]){var h=0;g=setInterval(function(){a(e[h++]).animate({left:0,opacity:1,height:b},l,"",function(){a(this).attr("id")==j&&i.setComplete(k)});h==e.length&&clearInterval(g)},d)}else{var h=j;g=setInterval(function(){a(e[h--]).animate({left:0,opacity:1,height:b},l,"",function(){a(this).attr("id")==0&&i.setComplete(k)});h<0&&clearInterval(g)},d)}};q()}function t(i,G,F,E,H,k){var h,n,b=E,w=G,v=F,e,f,q,m,s,t,r,l,g,D=function(){e=Math.ceil(v/b);f=Math.ceil(w/b);q=e*f;m=e-1+(f-1)+1;s="0-0";t="0-"+(f-1);r=e-1+"-0";l=e-1+"-"+(f-1);for(var g="",c=0;c<e;c++)for(var d=0;d<f;d++)g+="<div class='block' id='"+c+"-"+d+"'></div>";i.addToScreen(g);h=new Array(e);for(var c=0;c<e;c++){h[c]=new Array(f);for(var d=0;d<f;d++)h[c][d]=a("#"+(c+"-"+d),i.$el).css({top:c*b,left:d*b,width:b,height:b})}n=a("div.block",i.$el)};this.clear=function(){clearInterval(g);n.stop().css({"z-index":2,opacity:0})};this.displayContent=function(a,d){if(d==c["diag.fade"]){j(a,0,b,0);p(a,{opacity:1})}else if(d==c["diag.exp"]){j(a,1,0,0);p(a,{width:b,height:b})}else if(d==c["diag.fade.exp"]){j(a,0,0,0);p(a,{opacity:1,width:b,height:b})}else if(d==c["rev.diag.fade"]){j(a,0,b,0);o(a,{opacity:1})}else if(d==c["rev.diag.exp"]){j(a,1,0,0);o(a,{width:b,height:b})}else if(d==c["rev.diag.fade.exp"]){j(a,0,0,0);o(a,{opacity:1,width:b,height:b})}else if(d==c["block.fade"]){j(a,0,b,0);u(a,{opacity:1})}else if(d==c["block.exp"]){j(a,1,0,0);u(a,{width:b,height:b})}else if(d==c["block.drop"]){j(a,1,b,-(e*b));y(a)}else if(d==c["block.top.zz"]){j(a,0,b,0);C(a)}else if(d==c["block.bottom.zz"]){j(a,0,b,0);x(a)}else if(d==c["block.left.zz"]){j(a,0,b,0);B(a)}else if(d==c["block.right.zz"]){j(a,0,b,0);z(a)}else{j(a,1,0,0);A(a,d)}};var j=function(g,n,j,p){for(var o=(v-g.height)/2,m=(w-g.width)/2,l=g.src,c=0;c<e;c++)for(var d=0;d<f;d++){var k=-c*b+o,i=-d*b+m;a(h[c][d]).css({background:" url('"+l+"') "+i+"px "+k+"px no-repeat",backgroundPositionX:i+"px",backgroundPositionY:k+"px",opacity:n,top:c*b+p,left:d*b,width:j,height:j,"z-index":3})}},p=function(n,o){var c,j,b=0;g=setInterval(function(){for(var d=0;d<=b;d++){c=d;j=Math.abs(c-b);c<e&&j<f&&a(h[c][j]).animate(o,k,"",function(){a(this).attr("id")==l&&i.setComplete(n)})}if(b<m)b++;else clearInterval(g)},d)},o=function(l,n){var c,j,b=m-1;g=setInterval(function(){for(var d=b;d>=0;d--){c=d;j=Math.abs(c-b);c<e&&j<f&&a(h[c][j]).animate(n,k,"",function(){a(this).attr("id")=="0-0"&&i.setComplete(l)})}if(b>0)b--;else clearInterval(g)},d)},B=function(n){var c=true,m=f%2==0?t:l,b=0,j=0;g=setInterval(function(){a(h[b][j]).animate({opacity:1},k,"",function(){a(this).attr("id")==m&&i.setComplete(n)});a(h[b][j]).attr("id")==m&&clearInterval(g);c?b++:b--;if(b==e||b<0){c=!c;b=c?0:e-1;j++}},d)},z=function(m){var c=true,l=f%2==0?s:r,b=0,j=f-1;g=setInterval(function(){a(h[b][j]).animate({opacity:1},k,"",function(){a(this).attr("id")==l&&i.setComplete(m)});a(h[b][j]).attr("id")==l&&clearInterval(g);c?b++:b--;if(b==e||b<0){c=!c;b=c?0:e-1;j--}},d)},C=function(n){var c=true,m=e%2==0?r:l,j=0,b=0;g=setInterval(function(){a(h[j][b]).animate({opacity:1},k,"",function(){a(this).attr("id")==m&&i.setComplete(n)});a(h[j][b]).attr("id")==m&&clearInterval(g);c?b++:b--;if(b==f||b<0){c=!c;b=c?0:f-1;j++}},d)},x=function(m){var c=true,l=e%2==0?s:t,j=e-1,b=0;g=setInterval(function(){a(h[j][b]).animate({opacity:1},k,"",function(){a(this).attr("id")==l&&i.setComplete(m)});a(h[j][b]).attr("id")==l&&clearInterval(g);c?b++:b--;if(b==f||b<0){c=!c;b=c?0:f-1;j--}},d)},A=function(n,p){var o={opacity:1,width:b,height:b};if(p==c["block.left"]){var m=0;g=setInterval(function(){for(var b=0;b<e;b++)a(h[b][m]).animate(o,k,"",function(){a(this).attr("id")==l&&i.setComplete(n)});m++;m==f&&clearInterval(g)},d)}else if(p==c["block.right"]){var m=f-1;g=setInterval(function(){for(var b=0;b<e;b++)a(h[b][m]).animate(o,k,"",function(){a(this).attr("id")=="0-0"&&i.setComplete(n)});m--;m<0&&clearInterval(g)},d)}else if(p==c["block.top"]){var j=0;g=setInterval(function(){for(var b=0;b<f;b++)a(h[j][b]).animate(o,k,"",function(){a(this).attr("id")==l&&i.setComplete(n)});j++;j==e&&clearInterval(g)},d)}else{var j=e-1;g=setInterval(function(){for(var b=0;b<f;b++)a(h[j][b]).animate(o,k,"",function(){a(this).attr("id")=="0-0"&&i.setComplete(n)});j--;j<0&&clearInterval(g)},d)}},y=function(j){for(var g=0,c=0;c<e;c++)for(var d=0;d<f;d++)a(h[c][d]).delay(Math.random()*k).animate({top:c*b},k,"",function(){g++;g==q&&i.setComplete(j)})},u=function(c,d){var b=0;n.each(function(){a(this).delay(Math.random()*k).animate(d,Math.random()*k,"",function(){b++;b==q&&i.setComplete(c)})})};D()}function s(s,d){var A=d.width,v=d.height,P=d.button_margin,xb=d.transition.toLowerCase(),M=d.transition_speed>0?d.transition_speed:p,Hb=d.delay>0?d.delay:g,bb=d.auto_start,Sb=d.border,O=d.cpanel_align,cb=d.button_width,U=d.button_height,Mb=d.block_size>0?d.block_size:100,Pb=d.vert_size>0?d.vert_size:50,Ob=d.horz_size>0?d.horz_size:50,mb=d.display_thumbs,V=d.display_dbuttons,S=d.display_playbutton,vb=d.display_tooltip,Eb=d.display_numbers,W=d.cpanel_mouseover,T=d.text_mouseover,B=d.cpanel_margin,ab=0,y=0,I,R,zb,Ab,z,K,J,qb,pb,sb,ib=null,hb,u,H,jb=false,nb=false,Rb=jQuery.browser.msie?true:false,C=a(".wt-rotator",s),x=a("#main-img",s),Bb=a("#bg-img",s),Q=a("div.desc",s),L=a("div.preloader",s),b=a("div.c-panel",s),w=a("div.thumbnails",s),Y=w.find("li"),q=a("div.buttons",s),E=a(".play-btn",s),G=a(".prev-btn",s),F=a(".next-btn",s),N=a("#tooltip",s),gb,D;this.$el=s;this.init=function(){ab=Y.size();hb=C.css("background-color");C.css({width:A,height:v});Lb();Ib();Z();C.append("<div class='tmp-desc'></div>");gb=a("div.tmp-desc",s);L.css({top:(v-L.outerHeight())/2,left:(A-L.outerWidth())/2});C.hover(function(){jb=true;W&&wb();T&&X()},function(){jb=false;W&&yb();T&&ob()});qb=new m(this,A,v,Pb,hb,M);pb=new l(this,A,v,Ob,hb,M);sb=new t(this,A,v,Mb,hb,M);Jb();db(y)};this.setComplete=function(a){X();lb(a);x.attr("src",a.src);eb()};this.addToScreen=function(a){C.find(">a:first").append(a)};var Z=function(){b.show();b.css({width:q.outerWidth(true)+w.outerWidth(true)});var g=0,d=0,a=0,c=0;if(O==r){b.css({"margin-top":B,"margin-left":B,"margin-bottom":0,"margin-right":0});H=-b.outerHeight(true);u=0;b.css({top:u,left:0});w.css("float","left");q.css("float","left");z=0;K=25;J=e}else if(O==n){b.css({"margin-left":Math.floor((A-b.outerWidth())/2),"margin-top":B,"margin-bottom":0,"margin-right":0});H=-b.outerHeight(true);u=0;b.css({top:u,left:0});w.css("float","right");q.css("float","right");z=0;K=25;J=h}else if(O==o){b.css({"margin-right":B,"margin-top":B,"margin-bottom":0,"margin-left":0});H=-b.outerHeight(true);u=0;b.css({top:u,left:A-(b.outerWidth(true)-P)});w.css("float","right");q.css("float","right");z=0;K=25;J=f}else if(O==k){b.css({"margin-left":B,"margin-bottom":B,"margin-top":0,"margin-right":0});H=v;u=v-b.outerHeight(true);b.css({top:u,left:0});w.css("float","left");q.css("float","left");z=0;K=-30;J=e}else if(O==i){b.css({"margin-left":Math.floor((A-b.outerWidth())/2),"margin-bottom":B,"margin-top":0,"margin-right":0});H=v;u=v-b.outerHeight(true);b.css({top:u,left:0});w.css("float","right");q.css("float","right");z=0;K=-30;J=h}else{b.css({"margin-right":B,"margin-bottom":B,"margin-top":0,"margin-left":0});H=v;u=v-b.outerHeight(true);b.css({top:u,left:A-(b.outerWidth(true)-P)});w.css("float","right");q.css("float","right");z=0;K=-30;J=f}W&&!jb&&b.css({top:H})},Ib=function(){if(V){G.css({"margin-right":P,width:cb,height:U}).click(Qb).mouseover(rb).mouseout(tb);F.css({"margin-right":P,width:cb,height:U}).click(Cb).mouseover(rb).mouseout(tb)}else{G.hide();F.hide()}if(S){!bb&&E.css("background-image","url(assets/play.png)");E.css({"margin-right":P,width:cb,height:U}).click(Nb).mouseover(rb).mouseout(tb)}else E.hide()},Lb=function(){Y.each(function(b){Gb(a(this));a(this).css({width:cb,height:U,"line-height":U+"px","margin-right":P});Eb&&a(this).append(b+1)});if(mb)Y.click(function(){fb();y=a(this).index();db(y);return false}).mouseover(function(d){a(this).addClass("thumb-over");if(vb){var b=a(this).find(">a:first").attr("title");if(b!=""){N.html(b);if(J==f)z=-N.width();else if(J==e)z=0;else z=-N.width()/2;var c=C.offset();N.css({top:d.pageY+K-c.top,left:d.pageX+z-c.left}).delay(j).show(0)}}}).mouseout(function(){a(this).removeClass("thumb-over");N.stop().hide()}).mousemove(function(b){var a=C.offset();N.css({top:b.pageY+K-a.top,left:b.pageX+z-a.left})});else w.css({display:"none"}).width(0)},Qb=function(){fb();y=y>0?y-1:ab-1;db(y);return false},Cb=function(){fb();y=y<ab-1?y+1:0;db(y);return false},Nb=function(){bb=!bb;if(bb){a(this).css("background-image","url(assets/pause.png)");eb()}else{a(this).css("background-image","url(assets/play.png)");fb()}return false},rb=function(){a(this).addClass("button-over")},tb=function(){a(this).removeClass("button-over")},Gb=function(d){var a=d.find(">p:first"),e=a.css("left"),f=a.css("top"),c=a.css("width");c=ub(c,Q.width());var b=a.css("height");b=ub(b,0);d.data("desc",{x:e,y:f,w:c,h:b})},X=function(){if(!nb){if(T&&!jb)return;nb=true;var c=D.data("desc"),d=D.find(">p:first").html(),e=c.w,b=c.h;gb.css({width:e}).html(d);if(b<=0||b<gb.height())b=gb.height();Q.css({top:c.y,left:c.x,width:e,height:0}).html("");b!=0&&d&&d.length>0&&Q.animate({opacity:1,height:b},"slow","",function(){a(this).html(d);Rb&&this.style.removeAttribute("filter")})}},ob=function(){nb=false;if(Q.html()!="")Q.stop(true).animate({height:0,opacity:0},M);else Q.stop(true).animate({opacity:0},M)},wb=function(){b.animate({top:u,opacity:1},"slow")},yb=function(){b.stop(true).animate({top:H,opacity:0},"slow")},db=function(c){D=w.find("li:nth-child("+(c+1)+")");Y.removeClass("curr-thumb");D.addClass("curr-thumb");Ab=D.attr("tran")!=undefined?D.attr("tran"):xb;zb=Db(D.attr("delay"),Hb);var d=D.find(">a:last").attr("href"),e=D.find(">a:last").attr("target");if(d!=undefined&&d!="")C.find(">a:first")/*.css({cursor:"default"})*/.attr({href:d,target:e});else C.find(">a:first")/*.css({cursor:"default"})*/.attr({href:"#",target:"_self"});ob();if(R[c]){L.hide();kb(R[c])}else{var b=new Image;a(b).attr("src",I[c]);if(!b.complete){L.show();a(b).load(function(){L.hide();R[c]=jQuery.extend(true,{},this);kb(b)}).error(function(){alert("Error loading image")})}else{L.hide();R[c]=jQuery.extend(true,{},b);kb(b)}}},kb=function(b){qb.clear();pb.clear();sb.clear();var a=c[Ab];if(a==c.random)a=Math.floor(Math.random()*(c.length-2));if(a==c.none)Kb(b);else if(a==c.fade)Fb(b);else if(a<c["vert.tl"])sb.displayContent(b,a);else if(a<c["horz.tl"])qb.displayContent(b,a);else pb.displayContent(b,a)},Kb=function(a){lb(a);x.attr("src",a.src).show(0,function(){X();eb()})},Fb=function(a){Bb.css({top:x.css("top"),left:x.css("left"),"padding-top":x.css("padding-top"),"padding-bottom":x.css("padding-bottom"),"padding-left":x.css("padding-left"),"padding-right":x.css("padding-right")}).attr("src",x.attr("src")).show();x.hide();lb(a);x.attr("src",a.src).fadeIn(M,function(){Bb.hide();X();eb()})},Jb=function(){R=new Array(ab);I=new Array(ab);Y.each(function(b){I[b]=a(this).find(">a:first").attr("href")});var b=0,c=new Image;a(c).attr("src",I[b]);a(c).load(function(){R[b]=jQuery.extend(true,{},this);b++;b<I.length&&a(this).attr("src",I[b])}).error(function(){b++;b<I.length&&a(this).attr("src",I[b])})},lb=function(e){var b=(v-e.height)/2,a=(A-e.width)/2,g=0,f=0,d=0,c=0;if(b>0)d=b;else if(b<0)g=b;if(a>0)c=a;else if(a<0)f=a;x.css({top:g,left:f,"padding-top":d,"padding-bottom":d,"padding-left":c,"padding-right":c})},eb=function(){if(bb&&ib==null)ib=setTimeout(Cb,zb)},fb=function(){clearTimeout(ib);ib=null},Db=function(a,b){if(a!=undefined&&!isNaN(a)){a=Number(a);if(a>0)return a}return Number(b)},ub=function(a,b){if(a&&a!=undefined)if(a!="auto"){var c=a.lastIndexOf("px");if(c!=-1){a=a.slice(0,c);return a==undefined||isNaN(a)||a<=0?b:Number(a)}}return b};this.setMouseoverCP=function(a){W=a;if(W)yb();else wb()};this.setMouseoverDesc=function(a){T=a;if(T)ob();else X()};this.updateTransition=function(a){xb=a};this.showThumbs=function(a){mb=a;if(mb)w.width(240).show();else w.hide().width(0);Z()};this.showDButtons=function(a){V=a;if(V){G.show();F.show();if(S)q.width(E.outerWidth(true)+G.outerWidth(true)+F.outerWidth(true));else q.width(G.outerWidth(true)+F.outerWidth(true))}else{G.hide();F.hide();if(S)q.width(E.outerWidth(true));else q.width(0)}Z()};this.showPlayButton=function(a){S=a;if(S){E.show();if(V)q.width(E.outerWidth(true)+G.outerWidth(true)+F.outerWidth(true));else q.width(E.outerWidth(true))}else{E.hide();if(V)q.width(G.outerWidth(true)+F.outerWidth(true));else q.width(0)}Z()};this.showTooltip=function(a){vb=a};this.updateCPanel=function(a){O=a;Z()}}var q={width:800,height:300,button_width:24,button_height:24,button_margin:4,auto_start:true,delay:g,transition:"fade",transition_speed:800,block_size:100,vert_size:50,horz_size:50,cpanel_align:"BR",cpanel_margin:6,display_thumbs:true,display_dbuttons:true,display_playbutton:true,display_tooltip:true,display_numbers:true,cpanel_mouseover:false,text_mouseover:false},v=a.extend({},q,u);return this.each(function(){b=new s(a(this),v);b.init()})}})(jQuery)
