(function(C){var s="colorbox",q="hover",y=true,Q=false,V,o=!C.support.opacity,S=o&&!window.XMLHttpRequest,z="cbox_open",K="cbox_load",v="cbox_complete",J="cbox_cleanup",p="cbox_closed",N="resize.cbox_resize",H,T,U,d,A,l,b,G,c,O,E,h,g,t,k,n,L,m,I,u,W,j,f,a,r,i,B,P,x,M,D={transition:"elastic",speed:350,width:Q,height:Q,innerWidth:Q,innerHeight:Q,initialWidth:"400",initialHeight:"400",maxWidth:Q,maxHeight:Q,scalePhotos:y,scrolling:y,inline:Q,html:Q,iframe:Q,photo:Q,href:Q,title:Q,rel:Q,opacity:0.9,preloading:y,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:Q,overlayClose:y,slideshow:Q,slideshowAuto:y,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:Q,onLoad:Q,onComplete:Q,onCleanup:Q,onClosed:Q};
function F(X,Y){Y=Y==="x"?O.width():O.height();
return(typeof X==="string")?Math.round((X.match(/%/)?(Y/100)*parseInt(X,10):parseInt(X,10))):X
}function w(X){X=C.isFunction(X)?X.call(r):X;
return P.photo||X.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)
}function R(){for(var X in P){if(C.isFunction(P[X])&&X.substring(0,2)!=="on"){P[X]=P[X].call(r)
}}P.rel=P.rel||r.rel;
P.href=P.href||r.href;
P.title=P.title||r.title
}function e(X){r=X;
P=C(r).data(s);
R();
if(P.rel&&P.rel!=="nofollow"){c=C(".cboxElement").filter(function(){var Y=C(this).data(s).rel||this.rel;
return(Y===P.rel)
});
B=c.index(r);
if(B<0){c=c.add(r);
B=c.length-1
}}else{c=C(r);
B=0
}if(!x){x=y;
M=y;
i=r;
i.blur();
C(document).bind("keydown.cbox_close",function(Y){if(Y.keyCode===27){Y.preventDefault();
V.close()
}}).bind("keydown.cbox_arrows",function(Y){if(c.length>1){if(Y.keyCode===37){Y.preventDefault();
I.click()
}else{if(Y.keyCode===39){Y.preventDefault();
m.click()
}}}});
if(P.overlayClose){H.css({cursor:"pointer"}).one("click",V.close)
}C.event.trigger(z);
if(P.onOpen){P.onOpen.call(r)
}H.css({opacity:P.opacity}).show();
P.w=F(P.initialWidth,"x");
P.h=F(P.initialHeight,"y");
V.position(0);
if(S){O.bind("resize.cboxie6 scroll.cboxie6",function(){H.css({width:O.width(),height:O.height(),top:O.scrollTop(),left:O.scrollLeft()})
}).trigger("scroll.cboxie6")
}}n.add(I).add(m).add(L).add(k).hide();
u.html(P.close).show();
V.slideshow();
V.load()
}V=C.fn.colorbox=function(X,Z){var Y=this;
if(!Y.length){if(Y.selector===""){Y=C("<a/>");
X.open=y
}else{return this
}}Y.each(function(){var aa=C.extend({},C(this).data(s)?C(this).data(s):D,X);
C(this).data(s,aa).addClass("cboxElement");
if(Z){C(this).data(s).onComplete=Z
}});
if(X&&X.open){e(Y)
}return this
};
V.init=function(){function X(Y){return C('<div id="cbox'+Y+'"/>')
}O=C(window);
T=C('<div id="colorbox"/>');
H=X("Overlay").hide();
U=X("Wrapper");
d=X("Content").append(E=X("LoadedContent").css({width:0,height:0}),g=X("LoadingOverlay"),t=X("LoadingGraphic"),k=X("Title"),n=X("Current"),L=X("Slideshow"),m=X("Next"),I=X("Previous"),u=X("Close"));
U.append(C("<div/>").append(X("TopLeft"),A=X("TopCenter"),X("TopRight")),C("<div/>").append(l=X("MiddleLeft"),d,b=X("MiddleRight")),C("<div/>").append(X("BottomLeft"),G=X("BottomCenter"),X("BottomRight"))).children().children().css({"float":"left"});
h=C("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");
C("body").prepend(H,T.append(U,h));
if(o){T.addClass("cboxIE");
if(S){H.css("position","absolute")
}}d.children().bind("mouseover mouseout",function(){C(this).toggleClass(q)
}).addClass(q);
W=A.height()+G.height()+d.outerHeight(y)-d.height();
j=l.width()+b.width()+d.outerWidth(y)-d.width();
f=E.outerHeight(y);
a=E.outerWidth(y);
T.css({"padding-bottom":W,"padding-right":j}).hide();
m.click(V.next);
I.click(V.prev);
u.click(V.close);
d.children().removeClass(q);
C(".cboxElement").live("click",function(Y){if(Y.button!==0&&typeof Y.button!=="undefined"){return y
}else{e(this);
return Q
}})
};
V.position=function(ac,Z){var ab,Y=O.height(),aa=Math.max(Y-P.h-f-W,0)/2+O.scrollTop(),X=Math.max(document.documentElement.clientWidth-P.w-a-j,0)/2+O.scrollLeft();
ab=(T.width()===P.w+a&&T.height()===P.h+f)?0:ac;
U[0].style.width=U[0].style.height="9999px";
function ad(ae){A[0].style.width=G[0].style.width=d[0].style.width=ae.style.width;
t[0].style.height=g[0].style.height=d[0].style.height=l[0].style.height=b[0].style.height=ae.style.height
}T.dequeue().animate({width:P.w+a,height:P.h+f,top:aa,left:X},{duration:ab,complete:function(){ad(this);
M=Q;
U[0].style.width=(P.w+a+j)+"px";
U[0].style.height=(P.h+f+W)+"px";
if(Z){Z()
}},step:function(){ad(this)
}})
};
V.resize=function(ab){if(!x){return
}var ac,aa,Y,ae,ai,X,ag,Z=P.transition==="none"?0:P.speed;
O.unbind(N);
if(!ab){ag=setTimeout(function(){var aj=E.wrapInner("<div style='overflow:auto'></div>").children();
P.h=aj.height();
E.css({height:P.h});
aj.replaceWith(aj.children());
V.position(Z)
},1);
return
}E.remove();
E=C('<div id="cboxLoadedContent"/>').html(ab);
function af(){P.w=P.w||E.width();
P.w=P.mw&&P.mw<P.w?P.mw:P.w;
return P.w
}function ad(){P.h=P.h||E.height();
P.h=P.mh&&P.mh<P.h?P.mh:P.h;
return P.h
}E.hide().appendTo(h).css({width:af(),overflow:P.scrolling?"auto":"hidden"}).css({height:ad()}).prependTo(d);
C("#cboxPhoto").css({cssFloat:"none"});
if(S){C("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"
}).css({visibility:"hidden"}).one(J,function(){this.style.visibility="inherit"
})
}function ah(aj){V.position(aj,function(){if(!x){return
}if(o){if(X){E.fadeIn(100)
}T[0].style.removeAttribute("filter")
}if(P.iframe){E.append("<iframe id='cboxIframe'"+(P.scrolling?" ":"scrolling='no'")+" name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+P.href+"' "+(o?"allowtransparency='true'":"")+" />")
}E.show();
k.show().html(P.title);
if(c.length>1){n.html(P.current.replace(/\{current\}/,B+1).replace(/\{total\}/,c.length)).show();
m.html(P.next).show();
I.html(P.previous).show();
if(P.slideshow){L.show()
}}g.hide();
t.hide();
C.event.trigger(v);
if(P.onComplete){P.onComplete.call(r)
}if(P.transition==="fade"){T.fadeTo(Z,1,function(){if(o){T[0].style.removeAttribute("filter")
}})
}O.bind(N,function(){V.position(0)
})
})
}if((P.transition==="fade"&&T.fadeTo(Z,0,function(){ah(0)
}))||ah(Z)){}if(P.preloading&&c.length>1){aa=B>0?c[B-1]:c[c.length-1];
ae=B<c.length-1?c[B+1]:c[0];
ai=C(ae).data(s).href||ae.href;
Y=C(aa).data(s).href||aa.href;
if(w(ai)){C("<img />").attr("src",ai)
}if(w(Y)){C("<img />").attr("src",Y)
}}};
V.load=function(){var Y,X,aa,Z=V.resize;
M=y;
r=c[B];
P=C(r).data(s);
R();
C.event.trigger(K);
if(P.onLoad){P.onLoad.call(r)
}P.h=P.height?F(P.height,"y")-f-W:P.innerHeight?F(P.innerHeight,"y"):Q;
P.w=P.width?F(P.width,"x")-a-j:P.innerWidth?F(P.innerWidth,"x"):Q;
P.mw=P.w;
P.mh=P.h;
if(P.maxWidth){P.mw=F(P.maxWidth,"x")-a-j;
P.mw=P.w&&P.w<P.mw?P.w:P.mw
}if(P.maxHeight){P.mh=F(P.maxHeight,"y")-f-W;
P.mh=P.h&&P.h<P.mh?P.h:P.mh
}Y=P.href;
g.show();
t.show();
if(P.inline){C('<div id="cboxInlineTemp" />').hide().insertBefore(C(Y)[0]).bind(K+" "+J,function(){C(this).replaceWith(E.children())
});
Z(C(Y))
}else{if(P.iframe){Z(" ")
}else{if(P.html){Z(P.html)
}else{if(w(Y)){X=new Image();
X.onload=function(){var ab;
X.onload=null;
X.id="cboxPhoto";
C(X).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});
if(P.scalePhotos){aa=function(){X.height-=X.height*ab;
X.width-=X.width*ab
};
if(P.mw&&X.width>P.mw){ab=(X.width-P.mw)/X.width;
aa()
}if(P.mh&&X.height>P.mh){ab=(X.height-P.mh)/X.height;
aa()
}}if(P.h){X.style.marginTop=Math.max(P.h-X.height,0)/2+"px"
}Z(X);
if(c.length>1){C(X).css({cursor:"pointer"}).click(V.next)
}if(o){X.style.msInterpolationMode="bicubic"
}};
X.src=Y
}else{C("<div />").appendTo(h).load(Y,function(ab,ac){if(ac==="success"){Z(this)
}else{Z(C("<p>Request unsuccessful.</p>"))
}})
}}}}};
V.next=function(){if(!M){B=B<c.length-1?B+1:0;
V.load()
}};
V.prev=function(){if(!M){B=B>0?B-1:c.length-1;
V.load()
}};
V.slideshow=function(){var Y,X,Z="cboxSlideshow_";
L.bind(p,function(){L.unbind();
clearTimeout(X);
T.removeClass(Z+"off "+Z+"on")
});
function aa(){L.text(P.slideshowStop).bind(v,function(){X=setTimeout(V.next,P.slideshowSpeed)
}).bind(K,function(){clearTimeout(X)
}).one("click",function(){Y();
C(this).removeClass(q)
});
T.removeClass(Z+"off").addClass(Z+"on")
}Y=function(){clearTimeout(X);
L.text(P.slideshowStart).unbind(v+" "+K).one("click",function(){aa();
X=setTimeout(V.next,P.slideshowSpeed);
C(this).removeClass(q)
});
T.removeClass(Z+"on").addClass(Z+"off")
};
if(P.slideshow&&c.length>1){if(P.slideshowAuto){aa()
}else{Y()
}}};
V.close=function(){C.event.trigger(J);
if(P.onCleanup){P.onCleanup.call(r)
}x=Q;
C(document).unbind("keydown.cbox_close keydown.cbox_arrows");
O.unbind(N+" resize.cboxie6 scroll.cboxie6");
H.css({cursor:"auto"}).fadeOut("fast");
T.stop(y,Q).fadeOut("fast",function(){C("#colorbox iframe").attr("src","about:blank");
E.remove();
T.css({opacity:1});
try{i.focus()
}catch(X){}C.event.trigger(p);
if(P.onClosed){P.onClosed.call(r)
}})
};
V.element=function(){return C(r)
};
V.settings=D;
C(V.init)
}(jQuery));