(function(n){n.fn.fixPNG=function(){return this.each(function(){var t=n(this).css("backgroundImage");t.match(/^url\(["']?(.*\.png)["']?\)$/i)&&(t=RegExp.$1,n(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+(n(this).css("backgroundRepeat")=="no-repeat"?"crop":"scale")+", src='"+t+"')"}).each(function(){var t=n(this).css("position");t!="absolute"&&t!="relative"&&n(this).css("position","relative")}))})};var r,t,u=!1,i=new Image,e,o=1,s=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,f=n.browser.msie&&parseInt(n.browser.version.substr(0,1))<8;n.fn.fancybox=function(e){function v(){return r=this,t=e,y(),!1}function y(){var h,i,s;if(!u){if(n.isFunction(t.callbackOnStart)&&t.callbackOnStart(),t.itemArray=[],t.itemCurrent=0,e.itemArray.length>0)t.itemArray=e.itemArray;else if(i={},r.rel&&r.rel!=""){for(h=n(a).filter("a[rel="+r.rel+"]"),i={},s=0;s<h.length;s++)i={href:h[s].href,title:h[s].title},n(h[s]).children("img:first").length&&(i.orig=n(h[s]).children("img:first")),t.itemArray.push(i);while(t.itemArray[t.itemCurrent].href!=r.href)t.itemCurrent++}else i={href:r.href,title:r.title},n(r).children("img:first").length&&(i.orig=n(r).children("img:first")),t.itemArray.push(i);t.overlayShow&&(f&&n("embed, object, select").css("visibility","hidden"),n("#fancy_overlay").css("opacity",t.overlayOpacity).show());o()}}function o(){var u,f;n("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();u=t.itemArray[t.itemCurrent].href;u.match(/#/)?(f=window.location.href.split("#")[0],f=u.replace(f,""),f=f.substr(f.indexOf("#")),h('<div id="fancy_div">'+n(f).html()+"<\/div>",t.frameWidth,t.frameHeight)):u.match(s)?(i=new Image,i.src=u,i.complete?l():(n.fn.fancybox.showLoading(),n(i).unbind().bind("load",function(){n(".fancy_loading").hide();l()}))):u.match("iframe")||r.className.indexOf("iframe")>=0?h('<iframe id="fancy_frame" scrolling="no" onload="$.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(Math.random()*1e3)+'" frameborder="0" hspace="0" src="'+u+'"><\/iframe>',t.frameWidth,t.frameHeight):n.get(u,function(n){h('<div id="fancy_ajax">'+n+"<\/div>",t.frameWidth,t.frameHeight)})}function l(){var r,u;if(t.imageScale)var f=n.fn.fancybox.getViewport(),e=Math.min(Math.min(f[0]-36,i.width)/i.width,Math.min(f[1]-60,i.height)/i.height),r=Math.round(e*i.width),u=Math.round(e*i.height);else r=i.width,u=i.height;h('<img alt="" id="fancy_img" src="'+i.src+'" />',r,u)}function p(){var n;t.itemArray.length-1>t.itemCurrent&&(n=t.itemArray[t.itemCurrent+1].href,n.match(s)&&(objNext=new Image,objNext.src=n));t.itemCurrent>0&&(n=t.itemArray[t.itemCurrent-1].href,n.match(s)&&(objNext=new Image,objNext.src=n))}function h(i,r,f){var e,h,l;if(u=!0,e=t.padding,e>0?(r+=e*2,f+=e*2,n("#fancy_content").css({top:e+"px",right:e+"px",bottom:e+"px",left:e+"px",width:"auto",height:"auto"})):n("#fancy_content").css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%"}),n("#fancy_outer").is(":visible")&&r==n("#fancy_outer").width()&&f==n("#fancy_outer").height()){n("#fancy_content").fadeOut("fast",function(){n("#fancy_content").empty().append(n(i)).fadeIn("normal",function(){c()})});return}var o=n.fn.fancybox.getViewport(),a=r+36>o[0]?o[2]:o[2]+Math.round((o[0]-r-36)/2),v=f+50>o[1]?o[3]:o[3]+Math.round((o[1]-f-50)/2),s={left:a,top:v,width:r+"px",height:f+"px"};n("#fancy_outer").is(":visible")?n("#fancy_content").fadeOut("normal",function(){n("#fancy_content").empty();n("#fancy_outer").animate(s,t.zoomSpeedChange,t.easingChange,function(){n("#fancy_content").append(n(i)).fadeIn("normal",function(){c()})})}):t.zoomSpeedIn>0&&t.itemArray[t.itemCurrent].orig!==undefined?(n("#fancy_content").empty().append(n(i)),h=t.itemArray[t.itemCurrent].orig,l=n.fn.fancybox.getPosition(h),n("#fancy_outer").css({left:l.left-18+"px",top:l.top-18+"px",width:n(h).width(),height:n(h).height()}),t.zoomOpacity&&(s.opacity="show"),n("#fancy_outer").animate(s,t.zoomSpeedIn,t.easingIn,function(){c()})):(n("#fancy_content").hide().empty().append(n(i)).show(),n("#fancy_outer").css(s).fadeIn("normal",function(){c()}))}function w(){t.itemCurrent!=0&&(n("#fancy_left, #fancy_left_ico").unbind().bind("click",function(n){return n.stopPropagation(),t.itemCurrent--,o(),!1}),n("#fancy_left").show());t.itemCurrent!=t.itemArray.length-1&&(n("#fancy_right, #fancy_right_ico").unbind().bind("click",function(n){return n.stopPropagation(),t.itemCurrent++,o(),!1}),n("#fancy_right").show())}function c(){w();p();n(document).keydown(function(i){i.keyCode==27?(n.fn.fancybox.close(),n(document).unbind("keydown")):i.keyCode==37&&t.itemCurrent!=0?(t.itemCurrent--,o(),n(document).unbind("keydown")):i.keyCode==39&&t.itemCurrent!=t.itemArray.length-1&&(t.itemCurrent++,o(),n(document).unbind("keydown"))});t.centerOnScroll?n(window).bind("resize scroll",n.fn.fancybox.scrollBox):n("div#fancy_outer").css("position","absolute");t.showCloseButton&&n("#fancy_close").bind("click",n.fn.fancybox.close).show();t.hideOnContentClick&&n("#fancy_wrap").click(n.fn.fancybox.close);n("#fancy_overlay, #fancy_close").bind("click",n.fn.fancybox.close);t.itemArray[t.itemCurrent].title!==undefined&&t.itemArray[t.itemCurrent].title.length>0&&n("#fancy_title div").html(t.itemArray[t.itemCurrent].title);t.overlayShow&&f&&n("embed, object, select",n("#fancy_content")).css("visibility","visible");n.isFunction(t.callbackOnShow)&&t.callbackOnShow();u=!1}e=n.extend({},n.fn.fancybox.defaults,e);var a=this;return this.unbind("click").click(v)};n.fn.fancybox.scrollBox=function(){var t=n.fn.fancybox.getViewport();n("#fancy_outer").css("left",n("#fancy_outer").width()+36>t[0]?t[2]:t[2]+Math.round((t[0]-n("#fancy_outer").width()-36)/2));n("#fancy_outer").css("top",n("#fancy_outer").height()+50>t[1]?t[3]:t[3]+Math.round((t[1]-n("#fancy_outer").height()-50)/2))};n.fn.fancybox.getNumeric=function(t,i){return parseInt(n.curCSS(t.jquery?t[0]:t,i,!0))||0};n.fn.fancybox.getPosition=function(t){var i=t.offset();return i.top+=n.fn.fancybox.getNumeric(t,"paddingTop"),i.top+=n.fn.fancybox.getNumeric(t,"borderTopWidth"),i.left+=n.fn.fancybox.getNumeric(t,"paddingLeft"),i.left+=n.fn.fancybox.getNumeric(t,"borderLeftWidth"),i};n.fn.fancybox.showIframe=function(){n(".fancy_loading").hide();n("#fancy_frame").show()};n.fn.fancybox.getViewport=function(){return[n(window).width(),n(window).height(),n(document).scrollLeft(),n(document).scrollTop()]};n.fn.fancybox.animateLoading=function(){if(!n("#fancy_loading").is(":visible")){clearInterval(e);return}n("#fancy_loading > div").css("top",o*-40+"px");o=(o+1)%12};n.fn.fancybox.showLoading=function(){clearInterval(e);var t=n.fn.fancybox.getViewport();n("#fancy_loading").css({left:(t[0]-40)/2+t[2],top:(t[1]-40)/2+t[3]}).show();n("#fancy_loading").bind("click",n.fn.fancybox.close);e=setInterval(n.fn.fancybox.animateLoading,66)};n.fn.fancybox.close=function(){if(u=!0,n(i).unbind(),n("#fancy_overlay, #fancy_close").unbind(),t.hideOnContentClick&&n("#fancy_wrap").unbind(),n("#fancy_close, .fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide(),t.centerOnScroll&&n(window).unbind("resize scroll"),__cleanup=function(){n("#fancy_overlay, #fancy_outer").hide();t.centerOnScroll&&n(window).unbind("resize scroll");f&&n("embed, object, select").css("visibility","visible");n.isFunction(t.callbackOnClose)&&t.callbackOnClose();u=!1},n("#fancy_outer").is(":visible")!==!1)if(t.zoomSpeedOut>0&&t.itemArray[t.itemCurrent].orig!==undefined){var r=t.itemArray[t.itemCurrent].orig,e=n.fn.fancybox.getPosition(r),o={left:e.left-18+"px",top:e.top-18+"px",width:n(r).width(),height:n(r).height()};t.zoomOpacity&&(o.opacity="hide");n("#fancy_outer").stop(!1,!0).animate(o,t.zoomSpeedOut,t.easingOut,__cleanup)}else n("#fancy_outer").stop(!1,!0).fadeOut("fast",__cleanup);else __cleanup();return!1};n.fn.fancybox.build=function(){var t="";t+='<div id="fancy_overlay"><\/div>';t+='<div id="fancy_wrap">';t+='<div class="fancy_loading" id="fancy_loading"><div><\/div><\/div>';t+='<div id="fancy_outer">';t+='<div id="fancy_inner">';t+='<div id="fancy_close"><\/div>';t+='<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>';t+='<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>';t+='<div id="fancy_content"><\/div>';t+='<div id="fancy_title"><\/div>';t+="<\/div>";t+="<\/div>";t+="<\/div>";n(t).appendTo("body");n('<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");f&&(n("#fancy_inner").prepend('<iframe class="fancy_bigIframe" scrolling="no" frameborder="0"><\/iframe>'),n("#fancy_close, .fancy_bg, .fancy_title, .fancy_ico").fixPNG())};n.fn.fancybox.defaults={padding:10,imageScale:!0,zoomOpacity:!1,zoomSpeedIn:0,zoomSpeedOut:0,zoomSpeedChange:300,easingIn:"swing",easingOut:"swing",easingChange:"swing",frameWidth:425,frameHeight:355,overlayShow:!0,overlayOpacity:.3,hideOnContentClick:!0,centerOnScroll:!0,itemArray:[],callbackOnStart:null,callbackOnShow:null,callbackOnClose:null,showCloseButton:!0};n(document).ready(function(){n.fn.fancybox.build()})})(jQuery)