/*
 * FancyBox - simple jQuery plugin for fancy image zooming
 * Examples and documentation at: http://fancy.klade.lv/
 * Version: 1.2.0 (19/02/2009)
 * Copyright (c) 2009 Janis Skarnelis
 * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
 * Requires: jQuery v1.3+
*/
(function(a){a.fn.fixPNG=function(){return this.each(function(){var b=a(this).css("backgroundImage");if(b.match(/^url\(["']?(.*\.png)["']?\)$/i))b=RegExp.$1,a(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+("no-repeat"==a(this).css("backgroundRepeat")?"crop":"scale")+", src='"+b+"')"}).each(function(){var b=a(this).css("position");"absolute"!=b&&"relative"!=b&&a(this).css("position","relative")})})};var o,b,i=!1,d=new Image,
h,g=1,n=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,k=a.browser.msie&&8>parseInt(a.browser.version.substr(0,1));a.fn.fancybox=function(c){function f(){a("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();var c=b.itemArray[b.itemCurrent].href;if(c.match(/#/)){var e=window.location.href.split("#")[0],e=c.replace(e,"");l('<div id="fancy_div">'+a(e).html()+"</div>",b.frameWidth,b.frameHeight)}else c.match(n)?(d=new Image,d.src=c,d.complete?h():(a.fn.fancybox.showLoading(),a(d).unbind().bind("load",
function(){a(".fancy_loading").hide();h()}))):c.match("iframe")?l('<iframe id="fancy_frame" onload="$.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(1E3*Math.random())+'" frameborder="0" hspace="0" src="'+c+'"></iframe>',b.frameWidth,b.frameHeight):a.get(c,function(a){l('<div id="fancy_ajax">'+a+"</div>",b.frameWidth,b.frameHeight)})}function h(){if(b.imageScale)var c=a.fn.fancybox.getViewport(),e=Math.min(Math.min(c[0]-36,d.width)/d.width,Math.min(c[1]-60,d.height)/d.height),c=Math.round(e*
d.width),e=Math.round(e*d.height);else c=d.width,e=d.height;l('<img alt="" id="fancy_img" src="'+d.src+'" />',c,e);if(b.itemArray.length-1>b.itemCurrent&&(c=b.itemArray[b.itemCurrent+1].href,c.match(n)))objNext=new Image,objNext.src=c;if(0<b.itemCurrent&&(c=b.itemArray[b.itemCurrent-1].href,c.match(n)))objNext=new Image,objNext.src=c}function l(c,e,f){var d=a.fn.fancybox.getViewport(),h=e+36>d[0]?d[2]:d[2]+Math.round((d[0]-e-36)/2),d=f+50>d[1]?d[3]:d[3]+Math.round((d[1]-f-50)/2),g={left:h,top:d,width:e+
"px",height:f+"px"};if(a("#fancy_outer").is(":visible"))e==a("#fancy_content").width()&&f==a("#fancy_content").height()?a("#fancy_content").fadeOut("fast",function(){a("#fancy_content").empty().append(a(c)).fadeIn("fast",function(){m()})}):a("#fancy_content").fadeOut("fast",function(){a("#fancy_content").empty();a("#fancy_outer").animate(g,b.zoomSpeedChange,b.easingChange,function(){a("#fancy_content").append(a(c)).fadeIn("fast",function(){m()})})});else if(0<b.zoomSpeedIn&&void 0!==b.itemArray[b.itemCurrent].orig){a("#fancy_content").empty().append(a(c));
e=b.itemArray[b.itemCurrent].orig;f=a.fn.fancybox.getPosition(e);a("#fancy_outer").css({left:f.left-18+"px",top:f.top-18+"px",width:a(e).width(),height:a(e).height()});i=!0;if(b.zoomOpacity)g.opacity="show";a("#fancy_outer").animate(g,b.zoomSpeedIn,b.easingIn,function(){m()})}else a("#fancy_content").empty().append(a(c)),i=!0,a("#fancy_outer").css(g).fadeIn("normal",function(){m()})}function g(){0!=b.itemCurrent&&(a("#fancy_left, #fancy_left_ico").unbind().bind("click",function(a){a.stopPropagation();
b.itemCurrent--;f();return!1}),a("#fancy_left").show());b.itemCurrent!=b.itemArray.length-1&&(a("#fancy_right, #fancy_right_ico").unbind().bind("click",function(a){a.stopPropagation();b.itemCurrent++;f();return!1}),a("#fancy_right").show())}function m(){g();a(document).keydown(function(c){27==c.keyCode?(a.fn.fancybox.close(),a(document).unbind("keydown")):37==c.keyCode&&0!=b.itemCurrent?(b.itemCurrent--,f(),a(document).unbind("keydown")):39==c.keyCode&&b.itemCurrent!=b.itemArray.length-1&&(b.itemCurrent++,
f(),a(document).unbind("keydown"))});b.centerOnScroll?a(window).bind("resize scroll",a.fn.fancybox.scrollBox):a("div#fancy_outer").css("position","absolute");b.hideOnContentClick?a("#fancy_wrap").click(a.fn.fancybox.close):a("#fancy_wrap").unbind();a("#fancy_close").show();void 0!==b.itemArray[b.itemCurrent].title&&0<b.itemArray[b.itemCurrent].title.length&&(a("#fancy_title div").html(b.itemArray[b.itemCurrent].title),a("#fancy_title").show());b.overlayShow&&k&&a("#fancy_content").find("embed, object, select").css("visibility",
"visible");i=!1}var c=a.extend({},a.fn.fancybox.defaults,c),j=this;return this.unbind("click").click(function(){o=this;b=c;if(!i){a.isFunction(b.callbackOnStart)&&b.callbackOnStart();b.itemArray=[];b.itemCurrent=0;if(0<c.itemArray.length)b.itemArray=c.itemArray;else for(var d={},e=0;e<j.length;e++){d={href:j[e].href,title:j[e].title};if(a(j[e]).children("img:first").length)d.orig=a(j[e]).children("img:first");b.itemArray.push(d)}for(;b.itemArray[b.itemCurrent].href!=o.href;)b.itemCurrent++;b.overlayShow&&
(k&&a("embed, object, select").css("visibility","hidden"),a("#fancy_overlay").css("opacity",b.overlayOpacity).show());f()}return!1})};a.fn.fancybox.scrollBox=function(){var b=a.fn.fancybox.getViewport();a("#fancy_outer").css("left",a("#fancy_outer").width()+36>b[0]?b[2]:b[2]+Math.round((b[0]-a("#fancy_outer").width()-36)/2));a("#fancy_outer").css("top",a("#fancy_outer").height()+50>b[1]?b[3]:b[3]+Math.round((b[1]-a("#fancy_outer").height()-50)/2))};a.fn.fancybox.getNumeric=function(b,d){return parseInt(a.curCSS(b.jquery?
b[0]:b,d,!0))||0};a.fn.fancybox.getPosition=function(b){var d=b.offset();d.top+=a.fn.fancybox.getNumeric(b,"paddingTop");d.top+=a.fn.fancybox.getNumeric(b,"borderTopWidth");d.left+=a.fn.fancybox.getNumeric(b,"paddingLeft");d.left+=a.fn.fancybox.getNumeric(b,"borderLeftWidth");return d};a.fn.fancybox.showIframe=function(){a(".fancy_loading").hide();a("#fancy_frame").show()};a.fn.fancybox.getViewport=function(){return[a(window).width(),a(window).height(),a(document).scrollLeft(),a(document).scrollTop()]};
a.fn.fancybox.animateLoading=function(){a("#fancy_loading").is(":visible")?(a("#fancy_loading > div").css("top",-40*g+"px"),g=(g+1)%12):clearInterval(h)};a.fn.fancybox.showLoading=function(){clearInterval(h);var b=a.fn.fancybox.getViewport();a("#fancy_loading").css({left:(b[0]-40)/2+b[2],top:(b[1]-40)/2+b[3]}).show();a("#fancy_loading").bind("click",a.fn.fancybox.close);h=setInterval(a.fn.fancybox.animateLoading,66)};a.fn.fancybox.close=function(){a(d).unbind();a("#fancy_close, .fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();
__cleanup=function(){a("#fancy_overlay, #fancy_outer").hide();k&&a("embed, object, select").css("visibility","visible");a.isFunction(b.callbackOnClose)&&b.callbackOnClose();i=!1};if(!1!==a("#fancy_outer").is(":visible"))if(i=!0,0<b.zoomSpeedOut&&void 0!==b.itemArray[b.itemCurrent].orig){var c=b.itemArray[b.itemCurrent].orig,f=a.fn.fancybox.getPosition(c),c={left:f.left-18+"px",top:f.top-18+"px",width:a(c).width(),height:a(c).height()};if(b.zoomOpacity)c.opacity="hide";a("#fancy_outer").animate(c,
b.zoomSpeedOut,b.easingOut,__cleanup)}else a("#fancy_outer").stop().fadeOut("fast",__cleanup);else __cleanup();return!1};a.fn.fancybox.build=function(){var b;a('<div id="fancy_overlay"></div><div id="fancy_wrap"><div class="fancy_loading" id="fancy_loading"><div></div></div><div id="fancy_outer"><div id="fancy_inner"><div id="fancy_close"></div><div id="fancy_bg"><div class="fancy_bg fancy_bg_n"></div><div class="fancy_bg fancy_bg_ne"></div><div class="fancy_bg fancy_bg_e"></div><div class="fancy_bg fancy_bg_se"></div><div class="fancy_bg fancy_bg_s"></div><div class="fancy_bg fancy_bg_sw"></div><div class="fancy_bg fancy_bg_w"></div><div class="fancy_bg fancy_bg_nw"></div></div><a href="javascript:;" id="fancy_left"><span class="fancy_ico" id="fancy_left_ico"></span></a><a href="javascript:;" id="fancy_right"><span class="fancy_ico" id="fancy_right_ico"></span></a><div id="fancy_content"></div></div></div>').appendTo("body");
a('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="fancy_title" id="fancy_title_left"></td><td class="fancy_title" id="fancy_title_main"><div></div></td><td class="fancy_title" id="fancy_title_right"></td></tr></table>').appendTo("#fancy_title");k&&(a("#fancy_inner").prepend('<iframe class="fancy_bigIframe" scrolling="no" frameborder="0"></iframe>'),a("#fancy_close, .fancy_bg, .fancy_title, .fancy_ico").fixPNG());a("#fancy_overlay, #fancy_bigIframe, #fancy_loading, #fancy_close").bind("click",
a.fn.fancybox.close)};a.fn.fancybox.defaults={imageScale:!0,zoomOpacity:!1,zoomSpeedIn:0,zoomSpeedOut:0,zoomSpeedChange:300,easingIn:"swing",easingOut:"swing",easingChange:"swing",frameWidth:425,frameHeight:355,overlayShow:!0,overlayOpacity:0.3,hideOnContentClick:!0,centerOnScroll:!0,itemArray:[],callbackOnStart:null,callbackOnClose:null};a(document).ready(function(){a.fn.fancybox.build()})})(jQuery);
