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