/* * fancybox - jquery plugin * simple and fancy lightbox alternative * * examples and documentation at: http://fancybox.net * * copyright (c) 2008 - 2010 janis skarnelis * * version: 1.3.1 (05/03/2010) * requires: jquery v1.3+ * * dual licensed under the mit and gpl licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ (function(b){var m,u,x,g,d,i,z,a,b,p=0,e={},q=[],n=0,c={},j=[],e=null,s=new image,g=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,s=/[^\.]\.(swf)\s*$/i,h,i=1,k,l,h=false,y=b.extend(b("
")[0],{prop:0}),v=0,o=!b.support.opacity&&!window.xmlhttprequest,j=function(){u.hide();s.onerror=s.onload=null;e&&e.abort();m.empty()},p=function(){b.fancybox('

the requested content cannot be loaded.
please try again later.

',{scrolling:"no",padding:20,transitionin:"none",transitionout:"none"})}, k=function(){return[b(window).width(),b(window).height(),b(document).scrollleft(),b(document).scrolltop()]},t=function(){var a=k(),d={},f=c.margin,o=c.autoscale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.tostring().indexof("%")>-1){d.width=a[0]*parsefloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.tostring().indexof("%")>-1){d.height=a[1]*parsefloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r; w+=r;o=math.min(math.min(a[0]-t,c.width)/c.width,math.min(a[1]-w,c.height)/c.height);d.width=math.round(o*(d.width-r))+r;d.height=math.round(o*(d.height-r))+r}else{d.width=math.min(d.width,a[0]-t);d.height=math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoscale===false){d.top=math.max(a[3]+f,d.top);d.left=math.max(a[2]+f,d.left)}return d},u=function(a){if(a&&a.length)switch(c.titleposition){case "inside":return a;case "over":return''+ a+"";default:return''+a+''}return false},v=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titleposition;b("#fancybox-title").remove();v=0;if(c.titleshow!==false){a=b.isfunction(c.titleformat)?c.titleformat(a,j,n,c):u(a);if(!(!a||a==="")){b('
').css({width:d,paddingleft:c.padding, paddingright:c.padding}).html(a).appendto("body");switch(c.titleposition){case "inside":v=b("#fancybox-title").outerheight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerheight(true)*-1);break}b("#fancybox-title").appendto(d).hide()}}},w=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keycode==27&&c.enableescapebutton){a.preventdefault();b.fancybox.close()}else if(a.keycode== 37){a.preventdefault();b.fancybox.prev()}else if(a.keycode==39){a.preventdefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventdefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.shownavarrows){if(c.cyclic&&j.length>1||n!==0)a.show();if(c.cyclic&&j.length>1||n!=j.length-1)b.show()}},x=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(g)){d=new image;d.src=a}}if(n>0){a= j[n-1].href;if(typeof a!=="undefined"&&a.match(g)){d=new image;d.src=a}}},l=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeattribute("filter");g.get(0).style.removeattribute("filter")}b("#fancybox-title").show();c.hideoncontentclick&&i.one("click",b.fancybox.close);c.hideonoverlayclick&&x.one("click",b.fancybox.close);c.showclosebutton&&z.show();w();b(window).bind("resize.fb", b.fancybox.center);c.centeronscroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isfunction(c.oncomplete)&&c.oncomplete(j,n,c);h=false;x()},m=function(a){var d=math.round(k.width+(l.width-k.width)*a),f=math.round(k.height+(l.height-k.height)*a),o=math.round(k.top+(l.top-k.top)*a),t=math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=math.max(d-c.padding*2,0);f=math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+ "px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},y=function(a){var d=a.offset();d.top+=parsefloat(a.css("paddingtop"))||0;d.left+=parsefloat(a.css("paddingleft"))||0;d.top+=parsefloat(a.css("border-top-width"))||0;d.left+=parsefloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding- 20}}else{a=k();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},n=function(){u.hide();if(g.is(":visible")&&b.isfunction(c.oncleanup))if(c.oncleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrolltop=0;i.get(0).scrollleft=0;if(c.overlayshow){o&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"}); x.css({"background-color":c.overlaycolor,opacity:c.overlayopacity}).unbind().show()}l=t();v();if(g.is(":visible")){b(z.add(a).add(b)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeout(c.changefade,function(){var f=function(){i.html(m.contents()).fadein(c.changefade,l)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:math.max(l.width-c.padding* 2,1),height:math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:math.max(k.width-c.padding*2,1),height:math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changespeed,easing:c.easingchange,step:m,complete:f})}})}else{g.css("opacity",1);if(c.transitionin=="elastic"){k=q();i.css({top:c.padding,left:c.padding,width:math.max(k.width-c.padding*2,1),height:math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity= 0;y.prop=0;b(y).animate({prop:1},{duration:c.speedin,easing:c.easingin,step:m,complete:l})}else{i.css({top:c.padding,left:c.padding,width:math.max(l.width-c.padding*2,1),height:math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadein(c.transitionin=="none"?0:c.speedin,l)}}},f=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();n()},z=function(){h=true;e.width=s.width;e.height=s.height;b("").attr({id:"fancybox-img", src:s.src,alt:e.title}).appendto(m);n()},c=function(){j();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodename&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodename&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(g))f= "image";else if(d.match(s))f="swf";else if(b(a).hasclass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexof("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autodimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayshow=true;e.hideonoverlayclick=false;e.hideoncontentclick=false;e.enableescapebutton=false;e.showclosebutton=false}if(b.isfunction(e.onstart))if(e.onstart(q,p,e)===false){h=false; return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replacewith(i.children())});switch(f){case "html":m.html(e.content);f();break;case "inline":b('
').hide().insertbefore(b(a)).bind("fancybox-cleanup",function(){b(this).replacewith(i.children())}).bind("fancybox-cancel",function(){b(this).replacewith(m.children())});b(a).appendto(m);f();break;case "image":h=false;b.fancybox.showactivity(); s=new image;s.onerror=function(){p()};s.onload=function(){s.onerror=null;s.onload=null;z()};s.src=d;break;case "swf":t='';w="";b.each(e.swf,function(r,r){t+='';w+=" "+r+'="'+r+'"'});t+='";m.html(t); f();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showactivity();e=b.ajax(b.extend(e.ajax,{url:d,data:f,error:p,success:function(r){if(e.status==200){m.html(r);f()}}}));break;case "iframe":b('').appendto(m);n();break}},$=function(){if(u.is(":visible")){b("div", u).css("top",i*-40+"px");i=(i+1)%12}else clearinterval(h)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('
'),u=b('
'),x=b('
'),g=b('
'));if(!b.support.opacity){g.addclass("fancybox-ie");u.addclass("fancybox-ie")}d=b('
').append('
').appendto(g); d.append(i=b('
'),z=b(''),a=b(''),b=b(''));z.click(b.fancybox.close);u.click(b.fancybox.cancel);a.click(function(a){a.preventdefault();b.fancybox.prev()});b.click(function(a){a.preventdefault();b.fancybox.next()});if(o){x.get(0).style.setexpression("height", "document.body.scrollheight > document.body.offsetheight ? document.body.scrollheight : document.body.offsetheight + 'px'");u.get(0).style.setexpression("top","(-20 + (document.documentelement.clientheight ? document.documentelement.clientheight/2 : document.body.clientheight/2 ) + ( ignoreme = document.documentelement.scrolltop ? document.documentelement.scrolltop : document.body.scrolltop )) + 'px'");d.prepend('')}}}; b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventdefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}c();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isarray(a)){for(var f=0,o=a.length;fq.length||p<0)p=0;c()}};b.fancybox.showactivity=function(){clearinterval(h);u.show();h=setinterval($,66)};b.fancybox.hideactivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n- 1)};b.fancybox.pos=function(a){if(!h){a=parseint(a,10);if(a>-1&&j.length>a){p=a;c()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;c()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;c()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");j();e&&b.isfunction(e.oncancel)&&e.oncancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeout("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isfunction(c.onclosed)&&c.onclosed(j,n,c);j=e=[];n=p=0;c=e={};h=false} if(!(h||g.is(":hidden"))){h=true;if(c&&b.isfunction(c.oncleanup))if(c.oncleanup(j,n,c)===false){h=false;return}j();b(z.add(a).add(b)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionout=="elastic"){k=q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedout,easing:c.easingout, step:m,complete:a})}else g.fadeout(c.transitionout=="none"?0:c.speedout,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapinner("
").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replacewith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=k(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=math.max(a[3]+d,f.top);f.left=math.max(a[2]+ d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoscale:true,autodimensions:true,centeronscroll:false,ajax:{},swf:{wmode:"transparent"},hideonoverlayclick:true,hideoncontentclick:false,overlayshow:true,overlayopacity:0.3,overlaycolor:"#666",titleshow:true,titleposition:"outside",titleformat:null,transitionin:"fade",transitionout:"fade",speedin:300,speedout:300,changespeed:300,changefade:"fast", easingin:"swing",easingout:"swing",showclosebutton:true,shownavarrows:true,enableescapebutton:true,onstart:null,oncancel:null,oncomplete:null,oncleanup:null,onclosed:null};b(document).ready(function(){aa()})})(jquery);