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