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