﻿(function(){var a=jQuery,c=a.fn.startAnimation?"startAnimation":"animate",f="pause plugin missing.";function d(b){for(var a=1;a<arguments.length;a++)b=b.replace(new RegExp("\\{"+(a-1)+"}","g"),arguments[a]);return b}function b(){arguments[0]="CrossSlide: "+arguments[0];throw new Error(d.apply(null,arguments))}function e(d){var c=1,b=d.replace(/^\s*|\s*$/g,"").split(/\s+/);if(b.length>3)throw new Error;if(b[0]=="center")if(b.length==1)b=["center","center"];else if(b.length==2&&b[1].match(/^[\d.]+x$/i))b=["center","center",b[1]];if(b.length==3)c=parseFloat(b[2].match(/^([\d.]+)x$/i)[1]);var a=b[0]+" "+b[1];if(a=="left top"||a=="top left")return {xrel:0,yrel:0,zoom:c};if(a=="left center"||a=="center left")return {xrel:0,yrel:.5,zoom:c};if(a=="left bottom"||a=="bottom left")return {xrel:0,yrel:1,zoom:c};if(a=="center top"||a=="top center")return {xrel:.5,yrel:0,zoom:c};if(a=="center center")return {xrel:.5,yrel:.5,zoom:c};if(a=="center bottom"||a=="bottom center")return {xrel:.5,yrel:1,zoom:c};if(a=="right top"||a=="top right")return {xrel:1,yrel:0,zoom:c};if(a=="right center"||a=="center right")return {xrel:1,yrel:.5,zoom:c};if(a=="right bottom"||a=="bottom right")return {xrel:1,yrel:1,zoom:c};return {xrel:parseInt(b[0].match(/^(\d+)%$/)[1])/100,yrel:parseInt(b[1].match(/^(\d+)%$/)[1])/100,zoom:c}}a.fn.crossSlide=function(g,f,i){var h=this,k=this.width(),j=this.height();h.get(0).crossSlideArgs=[g,f,i];f=a.map(f,function(b){return a.extend({},b)});if(!i)i=function(){};(function(c){var a=0;function b(d,e){e.onload=function(){a++;f[d].width=e.width;f[d].height=e.height;if(a==f.length)c()};e.src=f[d].src;if(d+1<f.length)b(d+1,new Image)}b(0,new Image)})(function(){if(!g.fade)b("missing fade parameter.");if(g.speed&&g.sleep)b("you cannot set both speed and sleep at the same time.");var n=Math.round(g.fade*1e3);if(g.sleep)var r=Math.round(g.sleep*1e3);if(g.speed)var s=g.speed/1e3,t=Math.round(n*s);h.empty().css({overflow:"hidden",padding:0});if(!/^(absolute|relative|fixed)$/.test(h.css("position")))h.css({position:"relative"});if(!h.width()||!h.height())b("container element does not have its own width and height");if(g.shuffle)f.sort(function(){return Math.random()-.5});for(var m=0;m<f.length;++m){var l=f[m];if(!l.src)b("missing src parameter in picture {0}.",m+1);if(s){switch(l.dir){case "up":l.from={xrel:.5,yrel:0,zoom:1};l.to={xrel:.5,yrel:1,zoom:1};var w=l.height-j-2*t;break;case "down":l.from={xrel:.5,yrel:1,zoom:1};l.to={xrel:.5,yrel:0,zoom:1};var w=l.height-j-2*t;break;case "left":l.from={xrel:0,yrel:.5,zoom:1};l.to={xrel:1,yrel:.5,zoom:1};var w=l.width-k-2*t;break;case "right":l.from={xrel:1,yrel:.5,zoom:1};l.to={xrel:0,yrel:.5,zoom:1};var w=l.width-k-2*t;break;default:b("missing or malformed dir parameter in picture {0}.",m+1)}if(w<=0)b("impossible animation: either picture {0} is too small or div is too large or fade duration too long.",m+1);l.time_ms=Math.round(w/s)}else if(!r){if(!l.from||!l.to||!l.time)b("missing either speed/sleep option, or from/to/time params in picture {0}.",m+1);try{l.from=e(l.from)}catch(y){b('malformed "from" parameter in picture {0}.',m+1)}try{l.to=e(l.to)}catch(y){b('malformed "to" parameter in picture {0}.',m+1)}if(!l.time)b('missing "time" parameter in picture {0}.',m+1);l.time_ms=Math.round(l.time*1e3)}if(l.from)a.each([l.from,l.to],function(b,a){a.width=Math.round(l.width*a.zoom);a.height=Math.round(l.height*a.zoom);a.left=Math.round((k-a.width)*a.xrel);a.top=Math.round((j-a.height)*a.yrel)});var p;if(l.href)p=a(d('<a href="{0}"><img src="{1}"/></a>',l.href,l.src));else p=a(d('<img src="{0}"/>',l.src));if(l.onclick)p.click(l.onclick);if(l.alt)p.find("img").attr("alt",l.alt);if(l.href&&l.target)p.attr("target",l.target);p.appendTo(h)}delete s;function q(a,c){var b=([0,n/(a.time_ms+2*n),1-n/(a.time_ms+2*n),1])[c];return {left:Math.round(a.from.left+b*(a.to.left-a.from.left)),top:Math.round(a.from.top+b*(a.to.top-a.from.top)),width:Math.round(a.from.width+b*(a.to.width-a.from.width)),height:Math.round(a.from.height+b*(a.to.height-a.from.height))}}var o=h.find("img").css({position:"absolute",visibility:"hidden",top:0,left:0,border:0});o.eq(0).css({visibility:"visible"});if(!r)o.eq(0).css(q(f[0],1));var x=g.loop;function u(d,s){if(d%2==0)if(r)var v=d/2,z=(v-1+f.length)%f.length,D=o.eq(v),w=o.eq(z),t=function(){i(v,D);w.css("visibility","hidden");setTimeout(s,r)};else var m=d/2,z=(m-1+f.length)%f.length,y=o.eq(m),w=o.eq(z),A=f[m].time_ms,C=q(f[m],2),t=function(){i(m,y);w.css("visibility","hidden");y[c](C,A,"linear",s)};else{var h=Math.floor(d/2),e=Math.ceil(d/2)%f.length,p=o.eq(h),b=o.eq(e),l={},k={visibility:"visible"},j={};if(e>h){k.opacity=0;j.opacity=1;if(g.doubleFade)l.opacity=0}else{l.opacity=0;if(g.doubleFade){k.opacity=0;j.opacity=1}}if(!r){a.extend(l,q(f[h],3));a.extend(k,q(f[e],0));a.extend(j,q(f[e],1))}if(a.isEmptyObject(j))var t=function(){i(e,b,h,p);b.css(k);p[c](l,n,"linear",s)};else if(a.isEmptyObject(l))var t=function(){i(e,b,h,p);b.css(k);b[c](j,n,"linear",s)};else var t=function(){i(e,b,h,p);b.css(k);b[c](j,n,"linear");p[c](l,n,"linear",s)}}if(g.loop&&d==f.length*2-2){var B=t;t=function(){if(--x)B()}}if(d>0)return u(d-1,t);else return t}var v=u(f.length*2-1,function(){return v()});v()});return h};a.fn.crossSlideFreeze=function(){this.find("img").stop()};a.fn.crossSlideStop=function(){this.find("img").stop().remove()};a.fn.crossSlideRestart=function(){this.find("img").stop().remove();a.fn.crossSlide.apply(this,this.get(0).crossSlideArgs)};a.fn.crossSlidePause=function(){if(!a.fn.pause)b(f);this.find("img").pause()};a.fn.crossSlideResume=function(){if(!a.fn.pause)b(f);this.find("img").resume()}})()
