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

