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