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