/*
 * FancyBox - jQuery Plugin
 * simple and fancy lightbox alternative
 *
 * Copyright (c) 2009 Janis Skarnelis
 * Examples and documentation at: http://fancybox.net
 * 
 * Version: 1.2.6 (16/11/2009)
 * Requires: jQuery v1.3+
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function(e){e.fn.fixPNG=function(){return this.each(function(){var n=e(this).css("backgroundImage");if(n.match(/^url\(["']?(.*\.png)["']?\)$/i)){n=RegExp.$1;e(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+(e(this).css("backgroundRepeat")=="no-repeat"?"crop":"scale")+", src='"+n+"')"}).each(function(){var o=e(this).css("position");if(o!="absolute"&&o!="relative"){e(this).css("position","relative")}})}})};var c,a,h=false,b=new Image,i=new Image,l,m=1,d=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,j=/\.(pdf)(.*)?$/i;var k=null,g=e.browser.msie&&e.browser.version.substr(0,1)==6&&!window.XMLHttpRequest,f=g||(e.browser.msie&&e.browser.version.substr(0,1)==7);e.fn.fancybox=function(n){var r=e.extend({},e.fn.fancybox.defaults,n);var y=this;function t(){c=this;a=e.extend({},r);s();return false}function s(){if(h){return}if(e.isFunction(a.callbackOnStart)){a.callbackOnStart()}a.itemArray=[];a.itemCurrent=0;if(r.itemArray.length>0){a.itemArray=r.itemArray}else{var z={};if(!c.rel||c.rel==""){var z={href:c.href,title:c.title};if(e(c).children("img:first").length){z.orig=e(c).children("img:first")}else{z.orig=e(c)}if(z.title==""||typeof z.title=="undefined"){z.title=z.orig.attr("alt")}a.itemArray.push(z)}else{var A=e(y).filter("a[rel="+c.rel+"]");var z={};for(var o=0;o<A.length;o++){z={href:A[o].href,title:A[o].title};if(e(A[o]).children("img:first").length){z.orig=e(A[o]).children("img:first")}else{z.orig=e(A[o])}if(z.title==""||typeof z.title=="undefined"){z.title=z.orig.attr("alt")}a.itemArray.push(z)}}}while(a.itemArray[a.itemCurrent].href!=c.href){a.itemCurrent++}if(a.overlayShow){if(g){e("embed, object, select").css("visibility","hidden");e("#fancy_overlay").css("height",e(document).height())}e("#fancy_overlay").css({"background-color":a.overlayColor,opacity:a.overlayOpacity}).show()}e(window).bind("resize.fb scroll.fb",e.fn.fancybox.scrollBox);u()}function u(){e("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();var o=a.itemArray[a.itemCurrent].href;if(o.match("iframe")||c.className.indexOf("iframe")>=0){e.fn.fancybox.showLoading();q('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(Math.random()*1000)+'" frameborder="0" hspace="0" src="'+o+'"></iframe>',a.frameWidth,a.frameHeight)}else{if(o.match(/#/)){var z=window.location.href.split("#")[0];z=o.replace(z,"");z=z.substr(z.indexOf("#"));q('<div id="fancy_div">'+e(z).html()+"</div>",a.frameWidth,a.frameHeight)}else{if(o.match(d)){b=new Image;b.src=o;if(b.complete){x()}else{e.fn.fancybox.showLoading();e(b).unbind().bind("load",function(){e("#fancy_loading").hide();x()})}}else{if(o.match(j)){e.fn.fancybox.showLoading();q('<iframe id="fancy_frame" name="fancy_iframe'+Math.round(Math.random()*1000)+'" frameborder="0" hspace="0" src="'+o+'"></iframe>',a.frameWidth,a.frameHeight);e.fn.fancybox.showIframe()}else{e.fn.fancybox.showLoading();e.get(o,function(A){e("#fancy_loading").hide();q('<div id="fancy_ajax">'+A+"</div>",a.frameWidth,a.frameHeight)})}}}}}function x(){var B=b.width;var o=b.height;var D=(a.padding*2)+40;var C=(a.padding*2)+60;var z=e.fn.fancybox.getViewport();if(a.imageScale&&(B>(z[0]-D)||o>(z[1]-C))){var A=Math.min(Math.min(z[0]-D,B)/B,Math.min(z[1]-C,o)/o);B=Math.round(A*B);o=Math.round(A*o)}q('<img alt="" id="fancy_img" src="'+b.src+'" />',B,o)}function v(){if((a.itemArray.length-1)>a.itemCurrent){var o=a.itemArray[a.itemCurrent+1].href||false;if(o&&o.match(d)){objNext=new Image();objNext.src=o}}if(a.itemCurrent>0){var o=a.itemArray[a.itemCurrent-1].href||false;if(o&&o.match(d)){objNext=new Image();objNext.src=o}}}function q(D,z,F){h=true;var B=a.padding;if(f||k){e("#fancy_content")[0].style.removeExpression("height");e("#fancy_content")[0].style.removeExpression("width")}if(B>0){z+=B*2;F+=B*2;e("#fancy_content").css({top:B+"px",right:B+"px",bottom:B+"px",left:B+"px",width:"auto",height:"auto"});if(f||k){e("#fancy_content")[0].style.setExpression("height","(this.parentNode.clientHeight - "+B*2+")");e("#fancy_content")[0].style.setExpression("width","(this.parentNode.clientWidth - "+B*2+")")}}else{e("#fancy_content").css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%"})}if(e("#fancy_outer").is(":visible")&&z==e("#fancy_outer").width()&&F==e("#fancy_outer").height()){e("#fancy_content").fadeOut("fast",function(){e("#fancy_content").empty().append(e(D)).fadeIn("normal",function(){p()})});return}var E=e.fn.fancybox.getViewport();var H=(F+60)>E[1]?E[3]:(E[3]+Math.round((E[1]-F-60)*0.5));var A=(z+40)>E[0]?E[2]:(E[2]+Math.round((E[0]-z-40)*0.5));var G={left:A,top:H,width:z+"px",height:F+"px"};if(e("#fancy_outer").is(":visible")){e("#fancy_content").fadeOut("normal",function(){e("#fancy_content").empty();e("#fancy_outer").animate(G,a.zoomSpeedChange,a.easingChange,function(){e("#fancy_content").append(e(D)).fadeIn("normal",function(){p()})})})}else{if(a.zoomSpeedIn>0&&a.itemArray[a.itemCurrent].orig!==undefined){e("#fancy_content").empty().append(e(D));var C=a.itemArray[a.itemCurrent].orig;var o=e.fn.fancybox.getPosition(C);e("#fancy_outer").css({left:(o.left-20-a.padding)+"px",top:(o.top-20-a.padding)+"px",width:e(C).width()+(a.padding*2),height:e(C).height()+(a.padding*2)});if(a.zoomOpacity){G.opacity="show"}e("#fancy_outer").animate(G,a.zoomSpeedIn,a.easingIn,function(){p()})}else{e("#fancy_content").hide().empty().append(e(D)).show();e("#fancy_outer").css(G).fadeIn("normal",function(){p()})}}}function w(){if(a.itemCurrent!==0){e("#fancy_left, #fancy_left_ico").unbind().bind("click",function(o){o.stopPropagation();a.itemCurrent--;u();return false});e("#fancy_left").show()}if(a.itemCurrent!=(a.itemArray.length-1)){e("#fancy_right, #fancy_right_ico").unbind().bind("click",function(o){o.stopPropagation();a.itemCurrent++;u();return false});e("#fancy_right").show()}}function p(){if(e.browser.msie){e("#fancy_content")[0].style.removeAttribute("filter");e("#fancy_outer")[0].style.removeAttribute("filter")}w();v();e(document).bind("keydown.fb",function(z){if(z.keyCode==27&&a.enableEscapeButton){e.fn.fancybox.close()}else{if(z.keyCode==37&&a.itemCurrent!==0){e(document).unbind("keydown.fb");a.itemCurrent--;u()}else{if(z.keyCode==39&&a.itemCurrent!=(a.itemArray.length-1)){e(document).unbind("keydown.fb");a.itemCurrent++;u()}}}});if(a.hideOnContentClick){e("#fancy_content").click(e.fn.fancybox.close)}if(a.overlayShow&&a.hideOnOverlayClick){e("#fancy_overlay").bind("click",e.fn.fancybox.close)}if(a.showCloseButton){e("#fancy_close").bind("click",e.fn.fancybox.close).show()}if(typeof a.itemArray[a.itemCurrent].title!=="undefined"&&a.itemArray[a.itemCurrent].title.length>0){var o=e("#fancy_outer").position();e("#fancy_title div").text(a.itemArray[a.itemCurrent].title).html();e("#fancy_title").css({top:o.top+e("#fancy_outer").outerHeight()-32,left:o.left+((e("#fancy_outer").outerWidth()*0.5)-(e("#fancy_title").width()*0.5))}).show()}if(a.overlayShow&&g){e("embed, object, select",e("#fancy_content")).css("visibility","visible")}if(e.isFunction(a.callbackOnShow)){a.callbackOnShow(a.itemArray[a.itemCurrent])}if(e.browser.msie){e("#fancy_outer")[0].style.removeAttribute("filter");e("#fancy_content")[0].style.removeAttribute("filter")}h=false}return this.unbind("click.fb").bind("click.fb",t)};e.fn.fancybox.scrollBox=function(){var n=e.fn.fancybox.getViewport();if(a.centerOnScroll&&e("#fancy_outer").is(":visible")){var o=e("#fancy_outer").outerWidth();var p=e("#fancy_outer").outerHeight();var q={top:(p>n[1]?n[3]:n[3]+Math.round((n[1]-p)*0.5)),left:(o>n[0]?n[2]:n[2]+Math.round((n[0]-o)*0.5))};e("#fancy_outer").css(q);e("#fancy_title").css({top:q.top+p-32,left:q.left+((o*0.5)-(e("#fancy_title").width()*0.5))})}if(g&&e("#fancy_overlay").is(":visible")){e("#fancy_overlay").css({height:e(document).height()})}if(e("#fancy_loading").is(":visible")){e("#fancy_loading").css({left:((n[0]-40)*0.5+n[2]),top:((n[1]-40)*0.5+n[3])})}};e.fn.fancybox.getNumeric=function(n,o){return parseInt(e.curCSS(n.jquery?n[0]:n,o,true))||0};e.fn.fancybox.getPosition=function(n){var o=n.offset();o.top+=e.fn.fancybox.getNumeric(n,"paddingTop");o.top+=e.fn.fancybox.getNumeric(n,"borderTopWidth");o.left+=e.fn.fancybox.getNumeric(n,"paddingLeft");o.left+=e.fn.fancybox.getNumeric(n,"borderLeftWidth");return o};e.fn.fancybox.showIframe=function(){e("#fancy_loading").hide();e("#fancy_frame").show()};e.fn.fancybox.getViewport=function(){return[e(window).width(),e(window).height(),e(document).scrollLeft(),e(document).scrollTop()]};e.fn.fancybox.animateLoading=function(){if(!e("#fancy_loading").is(":visible")){clearInterval(l);return}e("#fancy_loading > div").css("top",(m*-40)+"px");m=(m+1)%12};e.fn.fancybox.showLoading=function(){clearInterval(l);var n=e.fn.fancybox.getViewport();e("#fancy_loading").css({left:((n[0]-40)*0.5+n[2]),top:((n[1]-40)*0.5+n[3])}).show();e("#fancy_loading").bind("click",e.fn.fancybox.close);l=setInterval(e.fn.fancybox.animateLoading,66)};e.fn.fancybox.close=function(){h=true;e(b).unbind();e(document).unbind("keydown.fb");e(window).unbind("resize.fb scroll.fb");e("#fancy_overlay, #fancy_content, #fancy_close").unbind();e("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();__cleanup=function(){if(e("#fancy_overlay").is(":visible")){e("#fancy_overlay").fadeOut("fast")}e("#fancy_content").empty();if(a.centerOnScroll){e(window).unbind("resize.fb scroll.fb")}if(g){e("embed, object, select").css("visibility","visible")}if(e.isFunction(a.callbackOnClose)){a.callbackOnClose()}h=false};if(e("#fancy_outer").is(":visible")!==false){if(a.zoomSpeedOut>0&&a.itemArray[a.itemCurrent].orig!==undefined){var o=a.itemArray[a.itemCurrent].orig;var n=e.fn.fancybox.getPosition(o);var p={left:(n.left-20-a.padding)+"px",top:(n.top-20-a.padding)+"px",width:e(o).width()+(a.padding*2),height:e(o).height()+(a.padding*2)};if(a.zoomOpacity){p.opacity="hide"}e("#fancy_outer").stop(false,true).animate(p,a.zoomSpeedOut,a.easingOut,__cleanup)}else{e("#fancy_outer").stop(false,true).fadeOut("fast",__cleanup)}}else{__cleanup()}return false};e.fn.fancybox.build=function(){var n="";n+='<div id="fancy_overlay"></div>';n+='<div id="fancy_loading"><div></div></div>';n+='<div id="fancy_outer">';n+='<div id="fancy_inner">';n+='<div id="fancy_close"></div>';n+='<div id="fancy_bg"><div class="fancy_bg" id="fancy_bg_n"></div><div class="fancy_bg" id="fancy_bg_ne"></div><div class="fancy_bg" id="fancy_bg_e"></div><div class="fancy_bg" id="fancy_bg_se"></div><div class="fancy_bg" id="fancy_bg_s"></div><div class="fancy_bg" id="fancy_bg_sw"></div><div class="fancy_bg" id="fancy_bg_w"></div><div class="fancy_bg" id="fancy_bg_nw"></div></div>';n+='<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>';n+='<div id="fancy_content"></div>';n+="</div>";n+="</div>";n+='<div id="fancy_title"></div>';e(n).appendTo("body");e('<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.browser.msie){e(".fancy_bg").fixPNG()}if(g){e("div#fancy_overlay").css("position","absolute");e("#fancy_loading div, #fancy_close, .fancy_title, .fancy_ico").fixPNG();e("#fancy_inner").prepend('<iframe id="fancy_bigIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');var o=e("#fancy_bigIframe")[0].contentWindow.document;o.open();o.close()}};e.fn.fancybox.defaults={padding:10,imageScale:true,zoomOpacity:true,zoomSpeedIn:0,zoomSpeedOut:0,zoomSpeedChange:300,easingIn:"swing",easingOut:"swing",easingChange:"swing",frameWidth:560,frameHeight:340,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",enableEscapeButton:true,showCloseButton:true,hideOnOverlayClick:true,hideOnContentClick:true,centerOnScroll:true,itemArray:[],callbackOnStart:null,callbackOnShow:null,callbackOnClose:null};e(document).ready(function(){k=e.browser.msie&&!e.boxModel;if(e("#fancy_outer").length<1){e.fn.fancybox.build()}})})(jQuery);