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