/*
	ColorBox v1.1.5 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
	(c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
	Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
(function(g){var u,k,e,o,c,i,y,l,w,s,p,m,j,h,r,f,q,a,v,n;function b(){g([m]).css({position:"absolute",width:g(window).width(),height:g(window).height(),top:g(window).scrollTop(),left:g(window).scrollLeft()})}function d(z){if(z.keyCode==37){g(document).unbind("keydown.colorKeys");g("a#contentPrevious").click()}else{if(z.keyCode==39){g(document).unbind("keydown.colorKeys");g("a#contentNext").click()}}}function x(){if(g("#colorboxInlineTemp").length>0){g(r).children().insertAfter("#colorboxInlineTemp")}if(w){g(w).remove()}}l=function(){x();g(m).css({cursor:"auto"}).fadeOut("fast");g(s).stop(true,false).removeData("open").fadeOut("fast",function(){g(r).remove()});g(document).unbind("keydown.colorKeys");g(window).unbind("resize scroll",b)};function t(z,A){return(typeof z=="string")?(z.match(/%/)?(A/100)*parseInt(z,10):parseInt(z,10)):z}g(function(){g("body").append(g([m=g('<div id="modalBackgroundOverlay" />')[0],s=g('<div id="colorbox" />')[0]]).hide());g(s).append(g([p=g('<div id="modalWrap" />')[0]])).css("opacity",0).show();g(p).append(g([g('<div><div id="borderTopLeft"></div><div id="borderTopCenter"></div><div id="borderTopRight"></div></div>')[0],a=g('<div id="borderMiddleLeft" />')[0],h=g('<div id="modalContent" />')[0],v=g('<div id="borderMiddleRight" />')[0],g('<div><div id="borderBottomLeft"></div><div id="borderBottomCenter"></div><div id="borderBottomRight"></div></div>')[0]]));g(h).append(g([r=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],j=g('<div id="modalLoadingOverlay" />')[0],f=g('<a id="modalClose" href="#"></a>')[0]]));g(document).bind("keydown.colorClose",function(z){if(z.keyCode==27){l()}});g(f).click(function(){l();return false});q=g("#borderTopCenter")[0];n=g("#borderBottomCenter")[0];o=g(q).height()+g(n).height()+g(h).outerHeight(true)-g(h).height();c=g(a).width()+g(v).width()+g(h).outerWidth(true)-g(h).width();e=g(r).outerHeight(true);k=g(r).outerWidth(true);g(r).empty();g(s).css({"padding-bottom":o,"padding-right":c}).hide();g("#contentPrevious, #contentNext, #modalClose").live("mouseover",function(){g(this).addClass("hover")});g("#contentPrevious, #contentNext, #modalClose").live("mouseout",function(){g(this).removeClass("hover")})});g.fn.colorbox=function(E,G){function z(K,O,M,J){var I=document.documentElement.clientHeight;var L=I/2-O/2+g(window).scrollTop();var H=document.documentElement.clientWidth/2-K/2+g(window).scrollLeft();if(O>I){L-=(O-I)}if(L<0){L=0}if(H<0){H=0}K=K-c;O=O-o;function N(P){h.style.width=q.style.width=n.style.width=P.style.width;h.style.height=a.style.height=v.style.height=P.style.height}g(s).animate({height:O,width:K,top:L,left:H},{duration:M,complete:function(){if(J){J()}N(this);if(g.browser.msie&&g.browser.version<7){b()}},step:function(){N(this)}})}var D=[];function A(){if(E.preloading!==false&&y.length>1&&y[i].href.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(.*))?$/i)){var I,H;I=i>0?y[i-1].href:y[y.length-1].href;H=i<y.length-1?y[i+1].href:y[0].href;return[g("<img />").attr("src",H),g("<img />").attr("src",I)]}return false}function B(){g(j).show();if(g(this).attr("id")=="contentPrevious"){i=i>0?i-1:y.length-1}else{i=i<y.length-1?i+1:0}F(y[i].href,y[i].title)}function C(K,J){if(g(s).data("open")!==true){return false}var M=E.transition=="none"?0:E.transitionSpeed;g(r).remove();r=g(K)[0];g(r).hide().appendTo("body").css({width:(E.fixedWidth)?E.fixedWidth-k-c:g(r).width()}).css({height:(E.fixedHeight)?E.fixedHeight-e-o:g(r).height()}).attr({id:"modalLoadedContent"}).append(J).prependTo(g(h));if(g("#modalPhoto").length>0&&E.fixedHeight){var I=(parseInt(g(r)[0].style.height,10)-parseInt(g("#modalPhoto")[0].style.height,10))/2;g("#modalPhoto").css({marginTop:(I>0?I:0)})}function H(N){z(parseInt(r.style.width,10)+k+c,parseInt(r.style.height,10)+e+o,N,function(){if(g(s).data("open")!==true){return false}g(r).show();g(j).hide();g(document).bind("keydown.colorKeys",d);if(G){G()}if(E.transition==="fade"){g(s).animate({opacity:1},M)}return true})}if(E.transition=="fade"){g(s).animate({opacity:0},M,function(){H(0)})}else{H(M)}var L=A();return true}function F(I,J){x();var H="<p id='contentTitle'>"+J+"</p>";if(y.length>1){H+="<span id='contentCurrent'> "+E.contentCurrent+"</span>";H=H.replace(/\{current\}/,i+1).replace(/\{total\}/,y.length);H+="<a id='contentPrevious' href='#'>"+E.contentPrevious+"</a><a id='contentNext' href='#'>"+E.contentNext+"</a> "}if(E.inline){w=g('<div id="colorboxInlineTemp" />').hide().insertBefore(g(I)[0]);u=g(I).clone(true);C(g(I).wrapAll("<div />").parent(),H)}else{if(E.iframe){C(g("<div><iframe name='iframe_"+new Date().getTime()+" 'frameborder=0 src ="+I+"></iframe></div>"),H)}else{if(I.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(.*))?$/i)){w=new Image();w.onload=function(){w.onload=null;C(g("<div />").css({width:this.width,height:this.height}).append(g(this).css({width:this.width,height:this.height,display:"block",margin:"auto"}).attr("id","modalPhoto")),H);if(y.length>1){g(this).css({cursor:"pointer"}).click(B)}};w.src=I}else{w=g("<div />").load(I,function(K,L){if(L=="success"){C(g(this),H)}else{C(g("<p>Request unsuccessful.</p>"))}})}}}}E=g.extend({},g.fn.colorbox.settings,E);g(this).unbind("click.colorbox").bind("click.colorbox",function(){if(E.fixedWidth){E.fixedWidth=t(E.fixedWidth,document.documentElement.clientWidth)}if(E.fixedHeight){E.fixedHeight=t(E.fixedHeight,document.documentElement.clientHeight)}if(this.rel&&"nofollow"!=this.rel){y=g("a[rel='"+this.rel+"']");i=g(y).index(this)}else{y=g(this);i=0}if(g(s).data("open")!==true){g(document).bind("keydown.colorKeys",d);g(f).html(E.modalClose);g(m).css({opacity:E.bgOpacity});g(s).data("open",true).css({opacity:1});g([s,j,m]).show();z(t(E.initialWidth,document.documentElement.clientWidth),t(E.initialHeight,document.documentElement.clientHeight),0);if(g.browser.msie&&g.browser.version<7){g(window).bind("resize scroll",b)}}F(E.href?E.href:y[i].href,E.title?E.title:y[i].title);g("a#contentPrevious, a#contentNext").die().live("click",B);if(E.overlayClose!==false){g(m).css({cursor:"pointer"}).click(function(){l()})}return false});if(E.open!==false&&g(s).data("open")!==true){g(this).triggerHandler("click.colorbox")}return this.each(function(){})};g.fn.colorbox.settings={transition:"elastic",transitionSpeed:350,initialWidth:"400",initialHeight:"400",fixedWidth:false,fixedHeight:false,inline:false,iframe:false,href:false,title:false,bgOpacity:0.85,preloading:true,contentCurrent:"image {current} of {total}",contentPrevious:"previous",contentNext:"next",modalClose:"close",open:false,overlayClose:true}})(jQuery);
