(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 d,a,g=false,c=new Image,h,i=1,e=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i;var b=(f.browser.msie&&parseInt(f.browser.version.substr(0,1))<8);f.fn.fancybox=function(k){k=f.extend({},f.fn.fancybox.defaults,k);var s=this;function n(){d=this;a=k;l();return false;}function l(){if(g){return;}if(f.isFunction(a.callbackOnStart)){a.callbackOnStart();}a.itemArray=[];a.itemCurrent=0;if(k.itemArray.length>0){a.itemArray=k.itemArray;}else{var u={};if(!d.rel||d.rel==""){var u={href:d.href,title:d.title};if(f(d).children("img:first").length){u.orig=f(d).children("img:first");}a.itemArray.push(u);}else{var v=f(s).filter("a[rel="+d.rel+"]");var u={};for(var t=0;t<v.length;t++){u={href:v[t].href,title:v[t].title};if(f(v[t]).children("img:first").length){u.orig=f(v[t]).children("img:first");}a.itemArray.push(u);}while(a.itemArray[a.itemCurrent].href!=d.href){a.itemCurrent++;}}}if(a.overlayShow){if(b){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,"");u=u.substr(u.indexOf("#"));m('<div id="fancy_div">'+f(u).html()+"</div>",a.frameWidth,a.frameHeight);}else{if(t.match(e)){c=new Image;c.src=t;if(c.complete){r();}else{f.fn.fancybox.showLoading();f(c).unbind().bind("load",function(){f(".fancy_loading").hide();r();});}}else{if(t.match("iframe")||d.className.indexOf("iframe")>=0){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 u=f.fn.fancybox.getViewport();var x=Math.min(Math.min(u[0]-36,c.width)/c.width,Math.min(u[1]-60,c.height)/c.height);var v=Math.round(x*c.width);var t=Math.round(x*c.height);}else{var v=c.width;var t=c.height;}m('<img alt="" id="fancy_img" src="'+c.src+'" />',v,t);}function p(){if((a.itemArray.length-1)>a.itemCurrent){var t=a.itemArray[a.itemCurrent+1].href;if(t.match(e)){objNext=new Image();objNext.src=t;}}if(a.itemCurrent>0){var t=a.itemArray[a.itemCurrent-1].href;if(t.match(e)){objNext=new Image();objNext.src=t;}}}function m(z,u,B){g=true;var x=a.padding;if(b){f("#fancy_content")[0].style.removeExpression("height");f("#fancy_content")[0].style.removeExpression("width");}if(x>0){u+=x*2;B+=x*2;f("#fancy_content").css({"top":x+"px","right":x+"px","bottom":x+"px","left":x+"px","width":"auto","height":"auto"});if(b){f("#fancy_content")[0].style.setExpression("height","(this.parentNode.clientHeight - 20)");f("#fancy_content")[0].style.setExpression("width","(this.parentNode.clientWidth - 20)");}}else{f("#fancy_content").css({"top":0,"right":0,"bottom":0,"left":0,"width":"100%","height":"100%"});}if(f("#fancy_outer").is(":visible")&&u==f("#fancy_outer").width()&&B==f("#fancy_outer").height()){f("#fancy_content").fadeOut("fast",function(){f("#fancy_content").empty().append(f(z)).fadeIn("normal",function(){j();});});return;}var A=f.fn.fancybox.getViewport();var v="30px";var D=(B+50)>A[1]?A[3]:(A[3]+Math.round((A[1]-B-50)/2));var C={"left":v,"top":D,"width":u+"px","height":B+"px"};if(f("#fancy_outer").is(":visible")){f("#fancy_content").fadeOut("normal",function(){f("#fancy_content").empty();f("#fancy_outer").animate(C,a.zoomSpeedChange,a.easingChange,function(){f("#fancy_content").append(f(z)).fadeIn("normal",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()});if(a.zoomOpacity){C.opacity="show";}f("#fancy_outer").animate(C,a.zoomSpeedIn,a.easingIn,function(){j();});}else{f("#fancy_content").hide().empty().append(f(z)).show();f("#fancy_outer").css(C).fadeIn("normal",function(){j();});}}}function q(){if(a.itemCurrent!=0){f("#fancy_left, #fancy_left_ico").unbind().bind("click",function(t){t.stopPropagation();a.itemCurrent--;o();return false;});f("#fancy_left").show();}if(a.itemCurrent!=(a.itemArray.length-1)){f("#fancy_right, #fancy_right_ico").unbind().bind("click",function(t){t.stopPropagation();a.itemCurrent++;o();return false;});f("#fancy_right").show();}}function j(){q();p();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);}f("#fancy_overlay, #fancy_close").bind("click",f.fn.fancybox.close);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();}if(a.overlayShow&&b){f("embed, object, select",f("#fancy_content")).css("visibility","visible");}if(f.isFunction(a.callbackOnShow)){a.callbackOnShow();}g=false;}return this.unbind("click").click(n);};f.fn.fancybox.scrollBox=function(){var j=f.fn.fancybox.getViewport();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(){clearInterval(h);var j=f.fn.fancybox.getViewport();f("#fancy_loading").css({"left":((j[0]-40)/2+j[2]),"top":((j[1]-40)/2+j[3])}).show();f("#fancy_loading").bind("click",f.fn.fancybox.close);h=setInterval(f.fn.fancybox.animateLoading,66);};f.fn.fancybox.close=function(){g=true;f(c).unbind();f("#fancy_overlay, #fancy_close").unbind();if(a.hideOnContentClick){f("#fancy_wrap").unbind();}f("#fancy_close, .fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();if(a.centerOnScroll){f(window).unbind("resize scroll");}__cleanup=function(){f("#fancy_overlay, #fancy_outer").hide();if(a.centerOnScroll){f(window).unbind("resize scroll");}if(b){f("embed, object, select").css("visibility","visible");}if(f.isFunction(a.callbackOnClose)){a.callbackOnClose();}g=false;};if(f("#fancy_outer").is(":visible")!==false){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").stop(false,true).animate(l,a.zoomSpeedOut,a.easingOut,__cleanup);}else{f("#fancy_outer").stop(false,true).fadeOut("fast",__cleanup);}}else{__cleanup();}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+='<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>";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(b){f("#fancy_inner").prepend('<iframe class="fancy_bigIframe" scrolling="no" frameborder="0"></iframe>');f("#fancy_close, .fancy_bg, .fancy_title, .fancy_ico").fixPNG();}};f.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};f(document).ready(function(){f.fn.fancybox.build();});})(jQuery);
