(function(g){var j,u,s,r,m,p,i,q,f,t,n,a,c,o,h,l,e;g(function(){g("body").append(g([m=g('<div id="modalBackgroundOverlay" />')[0],r=g('<div id="colorbox" />')[0]]).hide());g(r).append(g([t=g('<div id="borderTopLeft" />')[0],n=g('<div id="borderTopCenter" />')[0],a=g('<div id="borderTopRight" />')[0],c=g('<div id="borderMiddleLeft" />')[0],o=g('<div id="borderMiddleRight" />')[0],h=g('<div id="borderBottomLeft" />')[0],l=g('<div id="borderBottomCenter" />')[0],e=g('<div id="borderBottomRight" />')[0],i=g('<div id="modalContent" />')[0]]));g(i).append(g([q=g('<div id="modalLoadedContent"><a id="contentPrevious" href="#"></a><a id="contentNext" href="#"></a><span id="contentCurrent"></span><br id="modalInfoBr"/><span id="contentTitle"></span><div id="preloadPrevious"></div><div id="preloadNext"></div><div id="preloadClose"></div></div>')[0],modalLoadingOverlay=g('<div id="modalLoadingOverlay" />')[0],f=g('<a id="modalClose" href="#"></a>')[0]]));g(f).click(function(){k();return false})});function b(){g([m,r]).css({position:"absolute",width:g(window).width(),height:g(window).height(),top:g(window).scrollTop(),left:g(window).scrollLeft()})}function d(v){if(v.keyCode==27){k();return false}else{if(v.keyCode==37){g("a#contentPrevious").click();return false}else{if(v.keyCode==39){g("a#contentNext").click();return false}}}}function k(){g([m,r]).fadeOut("fast",function(){g(q).empty()});if(s){g(s).remove()}g(document).unbind("keydown",d);g(window).unbind("resize scroll",b)}g.fn.colorbox=function(A){A=g.extend({},g.fn.colorbox.settings,A);function v(D,E,F,H){var G=g(window).height()/2-E/2+g(window).scrollTop();var C=g(window).width()/2-D/2+g(window).scrollLeft();if(G<g(t).height()){G=g(t).height()}if(C<g(t).width()){C=g(t).width()}g(c).animate({top:G,left:C-g(c).width(),height:E},F);g(o).animate({top:G,left:C+D,height:E},F);g(t).animate({top:G-g(t).height(),left:C-g(t).width()},F);g(n).animate({top:G-g(n).height(),left:C,width:D},F);g(a).animate({top:G-g(a).height(),left:C+D},F);g(h).animate({top:G+E,left:C-g(h).width()},F);g(l).animate({top:G+E,left:C,width:D},F);g(e).animate({top:G+E,left:C+D},F);g(i).animate({height:E,width:D,top:G,left:C},F,function(){if(H){H()}if(g.browser.msie&&g.browser.version<7){b()}})}var z=[];function w(){if(A.preloading==true&&u.length>1){var D,C;j>0?D=u[j-1].href:D=u[u.length-1].href;j<u.length-1?C=u[j+1].href:C=u[0].href;return[g(new Image()).attr("src",C),g(new Image()).attr("src",D)]}}function y(E,C){g(q).hide().html(E).append(C);if(A.contentWidth){g(q).css({width:A.contentWidth})}if(A.contentHeight){g(q).css({height:A.contentHeight})}if(A.transition=="elastic"){v(g(q).outerWidth(true),g(q).outerHeight(true),A.transitionSpeed,function(){g(q).show();g(modalLoadingOverlay).hide()})}else{g(r).fadeTo(A.transitionSpeed,0,function(){v(g(q).outerWidth(true),g(q).outerHeight(true),0);g(q).show();g(modalLoadingOverlay).hide();g(r).fadeTo(A.transitionSpeed,1,function(){})})}var D=w()}function x(){g(modalLoadingOverlay).show();if(g(this).attr("id")=="contentPrevious"){j>0?j--:j=u.length-1}else{j<u.length-1?j++:j=0}B(u[j]);return false}function B(D){var C="<br id='modalInfoBr'/><span id='contentTitle'>"+D.title+"</span>";if(u.length>1){C+="<span id='contentCurrent'> "+A.contentCurrent+"</span>";C=C.replace(/{current}/,j+1).replace(/{total}/,u.length);C+="<a id='contentPrevious' href='#'>"+A.contentPrevious+"</a> ";C+="<a id='contentNext' href='#'>"+A.contentNext+"</a> "}if(A.contentInline){y(g(A.contentInline).html(),C)}else{if(A.contentIframe){y("<iframe src ="+D.href+"></iframe>",C)}else{if(D.href.match(/.(gif|png|jpg|jpeg|bmp|tif)$/i)&&!A.contentAjax){s=g(new Image()).load(function(){y("<img src='"+D.href+"' alt=''/>",C)}).attr("src",D.href)}else{s=g("<div></div>").load(((A.contentAjax)?A.contentAjax:D.href),function(E,F){if(F=="success"){y(g(this).html(),C)}else{y("<p>Ajax request unsuccessful</p>")}})}}}}g(this).click(function(){g(q).empty().css({height:"auto",width:"auto"});g(f).html(A.modalClose);g(m).css({opacity:A.bgOpacity});g([m,r,modalLoadingOverlay]).show();g(i).css({width:A.initialWidth,height:A.initialHeight});v(g(i).width(),g(i).height(),0);if(this.rel){u=g("a[rel='"+this.rel+"']");j=g(u).index(this)}else{u=g(this);j=0}B(u[j]);g("a#contentPrevious, a#contentNext").die().live("click",x);g(document).bind("keydown",d);if(g.browser.msie&&g.browser.version<7){g(window).bind("resize scroll",b)}return false});return this.each(function(){})};g.fn.colorbox.settings={transition:"elastic",transitionSpeed:350,initialWidth:300,initialHeight:100,contentWidth:false,contentHeight:false,contentAjax:false,contentInline:false,contentIframe:false,bgOpacity:0.85,preloading:true,contentCurrent:"{current} of {total}",contentPrevious:"previous",contentNext:"next",modalClose:"close"}})(jQuery);
