jQuery.fn.crossSlide=function(c,f){var a=this,e=this.width(),b=this.height();function d(j){for(var h=1;h<arguments.length;h++){j=j.replace(new RegExp("\\{"+(h-1)+"}","g"),arguments[h])}return j}function g(){arguments[0]="crossSlide: "+arguments[0];throw d.apply(null,arguments)}(function(j){var h=0;function i(l,k){k.onload=function(m){h++;f[l].width=k.width;f[l].height=k.height;if(h==f.length){j()}};k.src=f[l].src;if(l+1<f.length){i(l+1,new Image())}}i(0,new Image())})(function(){function v(z){var i=1;var p=z.replace(/^\s*|\s*$/g,"").split(/\s+/);if(p.length>3){throw new Error()}if(p[0]=="center"){if(p.length==1){p=["center","center"]}else{if(p.length==2&&p[1].match(/^[\d.]+x$/i)){p=["center","center",p[1]]}}}if(p.length==3){i=parseFloat(p[2].match(/^([\d.]+)x$/i)[1])}var A=p[0]+" "+p[1];if(A=="left top"||A=="top left"){return{xrel:0,yrel:0,zoom:i}}if(A=="left center"||A=="center left"){return{xrel:0,yrel:0.5,zoom:i}}if(A=="left bottom"||A=="bottom left"){return{xrel:0,yrel:1,zoom:i}}if(A=="center top"||A=="top center"){return{xrel:0.5,yrel:0,zoom:i}}if(A=="center center"){return{xrel:0.5,yrel:0.5,zoom:i}}if(A=="center bottom"||A=="bottom center"){return{xrel:0.5,yrel:1,zoom:i}}if(A=="right top"||A=="top right"){return{xrel:1,yrel:0,zoom:i}}if(A=="right center"||A=="center right"){return{xrel:1,yrel:0.5,zoom:i}}if(A=="right bottom"||A=="bottom right"){return{xrel:1,yrel:1,zoom:i}}return{xrel:parseInt(p[0].match(/^(\d+)%$/)[1])/100,yrel:parseInt(p[1].match(/^(\d+)%$/)[1])/100,zoom:i}}function k(z,i){switch(i){case 1:var A=0;break;case 2:var A=x/(z.time_ms+2*x);break;case 3:var A=1-x/(z.time_ms+2*x);break;case 4:var A=1;break}return{left:Math.round(z.from.left+A*(z.to.left-z.from.left)),top:Math.round(z.from.top+A*(z.to.top-z.from.top)),width:Math.round(z.from.width+A*(z.to.width-z.from.width)),height:Math.round(z.from.height+A*(z.to.height-z.from.height))}}if(!c.fade){g("missing fade parameter.")}if(c.speed&&c.sleep){g("you cannot set both speed and sleep at the same time.")}var x=Math.round(c.fade*1000);if(c.sleep){var w=Math.round(c.sleep*1000)}if(c.speed){var l=c.speed/1000,r=Math.round(x*l)}a.empty().css({overflow:"hidden",padding:0});if(!/^(absolute|relative|fixed)$/.test(a.css("position"))){a.css({position:"relative"})}if(!a.width()||!a.height()){g("container element does not have its own width and height")}if(c.shuffle){f.sort(function(){return Math.random()-0.5})}for(var o=0;o<f.length;++o){var h=f[o];if(!h.src){g("missing src parameter in picture {0}.",o+1)}if(l){switch(h.dir){case"up":h.from={xrel:0.5,yrel:0,zoom:1};h.to={xrel:0.5,yrel:1,zoom:1};var t=h.height-b-2*r;break;case"down":h.from={xrel:0.5,yrel:1,zoom:1};h.to={xrel:0.5,yrel:0,zoom:1};var t=h.height-b-2*r;break;case"left":h.from={xrel:0,yrel:0.5,zoom:1};h.to={xrel:1,yrel:0.5,zoom:1};var t=h.width-e-2*r;break;case"right":h.from={xrel:1,yrel:0.5,zoom:1};h.to={xrel:0,yrel:0.5,zoom:1};var t=h.width-e-2*r;break;default:g('missing or malformed "dir" parameter in picture {0}.',o+1)}if(t<=0){g("picture number {0} is too short for the desired fade duration.",o+1)}h.time_ms=Math.round(t/l)}else{if(!w){if(!h.from||!h.to||!h.time){g("missing either speed/sleep option, or from/to/time params in picture {0}.",o+1)}try{h.from=v(h.from)}catch(s){g('malformed "from" parameter in picture {0}.',o+1)}try{h.to=v(h.to)}catch(s){g('malformed "to" parameter in picture {0}.',o+1)}if(!h.time){g('missing "time" parameter in picture {0}.',o+1)}h.time_ms=Math.round(h.time*1000)}}if(h.from){jQuery.each([h.from,h.to],function(z,p){p.width=Math.round(h.width*p.zoom);p.height=Math.round(h.height*p.zoom);p.left=Math.round((e-p.width)*p.xrel);p.top=Math.round((b-p.height)*p.yrel)})}var u;if(h.href){u=jQuery(d('<a href="{0}"><img src="{1}"/></a>',h.href,h.src))}else{if(c.cellHeight&&c.cellWidth){u=jQuery(d('<div style="background-color:#fff;"><img src="{0}"/></div>',h.src))}else{u=jQuery(d('<img src="{0}"/>',h.src))}}if(h.onclick){u.click(h.onclick)}if(h.alt){u.find("img").attr("alt",h.alt)}u.appendTo(a)}l=undefined;if(c.cellHeight&&c.cellWidth){var j=a.find("img").css({border:0});var q=a.find("div").css({position:"absolute",visibility:"hidden",width:c.cellWidth,height:c.cellHeight,top:0,left:0,border:0});for(var o=0;o<f.length;++o){if(f[o].width>f[o].height){j.eq(o).css({width:c.cellWidth,height:Math.round(c.cellHeight*(f[o].height/f[o].width)),marginTop:Math.round((c.cellHeight-c.cellHeight*(f[o].height/f[o].width))/2)})}else{j.eq(o).css({width:Math.round(c.cellWidth/(f[o].height/f[o].width)),height:c.cellHeight,marginLeft:Math.round((c.cellWidth-c.cellWidth/(f[o].height/f[o].width))/2)})}}}else{var q=a.find("img").css({position:"absolute",visibility:"hidden",top:0,left:0,border:0})}q.eq(0).css({visibility:"visible"});if(!w){q.eq(0).css(k(f[0],2))}var y=c.loop;function m(L,p){if(L%2==0){if(w){var B=L/2,P=(B-1+f.length)%f.length,M=q.eq(B),J=q.eq(P);var I=function(){J.css("visibility","hidden");setTimeout(p,w)}}else{var E=L/2,P=(E-1+f.length)%f.length,O=q.eq(E),J=q.eq(P),C=f[E].time_ms,K=k(f[E],3);var I=function(){J.css("visibility","hidden");O.animate(K,C,"linear",p)}}}else{if(w){var A=Math.floor(L/2),D=Math.ceil(L/2)%f.length,N=q.eq(A),z=q.eq(D),Q={},H={visibility:"visible"},G={};if(D>A){H.opacity=0;G.opacity=1}else{Q.opacity=0}var I=function(){z.css(H);if(Q.opacity!=undefined){N.animate(Q,x,"linear",p)}else{z.animate(G,x,"linear",p)}}}else{var A=Math.floor(L/2),D=Math.ceil(L/2)%f.length,N=q.eq(A),z=q.eq(D),Q=k(f[A],4),H=k(f[D],1),G=k(f[D],2);if(D>A){H.opacity=0;G.opacity=1}else{Q.opacity=0}H.visibility="visible";var I=function(){N.animate(Q,x,"linear");z.css(H);z.animate(G,x,"linear",p)}}}if(c.loop&&L==f.length*2-2){var F=I;I=function(){if(--y){F()}}}if(L>0){return m(L-1,I)}else{return I}}var n=m(f.length*2-1,function(){return n()});n()});return a};
