/*
 boxplus lightweight window engine on mouse-over
 @author  Levente Hunyadi
 @version 1.3.2
 @remarks Copyright (C) 2009-2010 Levente Hunyadi
 @remarks Licensed under GNU/GPLv3, see http://www.gnu.org/licenses/gpl-3.0.html
 @see     http://hunyadi.info.hu/projects/boxplus
*/
if(typeof __jQuery__=="undefined")var __jQuery__=jQuery;
(function(b){function q(a,d){var e=parseInt(a.css(d));return isNaN(e)?a[d]():e}function r(a,d){a+=c.outerWidth(true)-parseInt(c.css("width"));d+=c.outerHeight(true)-parseInt(c.css("height"));var e=b("img:first",j),g=e.offset(),k=g.left-f.scrollLeft();g=g.top-f.scrollTop();var s=e.outerWidth(),t=e.outerHeight(),l=[k+s+a-f.width(),g+t+d-f.height(),a-k];e=-1;var u=Infinity,h;for(h in l)if(l[h]<u){e=h;u=l[h]}l=(f.width()-a)/2;h=(f.height()-d)/2;k=[k+s+20,l,k-a-20];g=[h,g+t+20,h];return{left:f.scrollLeft()+
k[e],top:f.scrollTop()+g[e]}}function v(a){j=b(a.currentTarget);c.css(r(m,n));c.css({width:m,height:n});p.onload=w;p.src=j.attr("href");c.removeClass("hide")}function x(){c.stop();c.addClass("hide");o.addClass("hide");i.addClass("hide")}function w(){var a=p.width,d=p.height;o.css({width:a,height:d});o.css("background-image",'url("'+j.attr("href")+'")');a=b.extend({width:a,height:d},r(a,d));c.css({width:m,height:n,left:a.left+(a.width-m)/2,top:a.top+(a.height-n)/2});c.animate(a,"fast","swing",y)}function y(){o.removeClass("hide");
var a=b("img:first",j).attr("alt"),d=j.attr("title");a&&a!=d?b(".title",i).html(a):b(".title",i).empty();b(".caption",i).html(d);if(a||d){a=c.dimensions();a.height+=i.outerHeight(true);c.animate(a,"slow","swing",z)}}function z(){i.removeClass("hide")}b.fn.safeWidth=function(){return q(this,"width")};b.fn.safeHeight=function(){return q(this,"height")};var c,m,n,o,i,f=b(window),p=new Image,j;b(function(){b("body").append('<div id="boxplus-dialog" class="hide"><div id="boxplus-viewer" class="hide"></div><div id="boxplus-caption" class="hide"><p class="title"></p><p class="caption"></p></div></div>');
c=b("#boxplus-dialog");m=c.safeWidth();n=c.safeHeight();o=b("#boxplus-viewer");i=b("#boxplus-caption")});b.fn.dimensions=function(){return{width:parseInt(this.css("width")),height:parseInt(this.css("height"))}};b.fn.boxplusHover=function(){b(this).each(function(){b(this).hover(v,x)})};b.fn.boxplusHoverGallery=function(){b("li",this).each(function(){var a=b("a:has(img)",this).eq(0);a&&a.boxplusHover()})}})(__jQuery__);

