/*
 boxplus image slider engine
 @author  Levente Hunyadi
 @version 1.4.1
 @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){var C="boxplus-disabled",H="boxplus-hidden",I="boxplus-loading";b.fn.maxOuterWidth=function(){var a=0;this.each(function(D,l){a=Math.max(a,b(l).outerWidth(true))});return a};b.fn.maxOuterHeight=function(){var a=0;this.each(function(D,l){a=Math.max(a,b(l).outerHeight(true))});return a};b.fn.boxplusSlider=function(a){a=b.extend({rtl:false,rowCount:1,columnCount:2,orientation:"horizontal",navigation:"top",step:"page",showButtons:true,showLinks:true,showPageCounter:true,showOverlayButtons:true,
contextmenu:true,duration:800,delay:0,opacity:1},a);this.filter("ul, ol").each(function(){function D(d,h,w){for(q=0;q<d;q++)for(r=0;r<h;r++)e.eq(w?q*h+r:r*d+q).css({top:q*o}).css(s?"right":"left",r*m)}function l(d){return'<a class="boxplus-'+d+'" href="javascript:void(0)" />'}function t(d){return'<div class="boxplus-'+d+'" />'}function J(d){return d.filter(function(){return/\.(gif|jpe?g|png)$/i.test(b("img:first",this).attr("longdesc"))})}function K(d){J(d).each(function(){var h=b("img:first",this);
h.attr("data-thumb",h.attr("src")).attr("src",h.attr("longdesc")).removeAttr("longdesc")});d.removeClass(I).children().removeClass(H);L()}function L(){e.slice(c,c+i).mouseenter().mouseleave()}function M(){x("cycle")}function x(d){switch(d){case "first":c=0;break;case "prev":c=c>=y?c-y:0;break;case "next":c=c<u?c+y:u;break;case "last":c=u;break;case "cycle":c=c>=u?0:c+y}var h=Math.max(0,c-i),w=Math.min(j,c+2*i);e.slice(0,h).detach();e.slice(w).detach();var E={};if(z)E.top=-(c/p*o);else E[s?"right":
"left"]=-(c/v*m);switch(d){case "first":case "last":n.css(b.extend(E,{opacity:0}));F();n.prepend(e.slice(0,h)).append(e.slice(w));n.animate({opacity:1},G,"linear");break;default:F();n.animate(E,G,"swing",function(){n.prepend(e.slice(0,h)).append(e.slice(w))})}}function F(){P.add(Q).toggleClass(C,c<=0);R.add(S).toggleClass(C,c>=u);b(".boxplus-current",f).text(c/i+1);e.slice(Math.max(0,c-i),Math.min(j,c+2*i)).trigger("boxplus-load");L()}var v=a.rowCount,p=a.columnCount,i=v*p,G=a.duration,A=a.delay,
c=0,e=b("li:visible",this),B=e.find("img:first"),m=B.maxOuterWidth(),o=B.maxOuterHeight(),n=b(this).wrap("<div />"),f=n.parent().addClass("boxplus-slider").addClass(C);f.wrapInner('<div class="boxplus-viewport" />');e.css({width:m,height:o});m=e.maxOuterWidth();o=e.maxOuterHeight();var s=a.rtl,j=e.length,g,k,q,r,z=a.orientation=="vertical";if(z){k=p;g=Math.ceil(j/p);D(g,k,true)}else{k=Math.ceil(j/v);g=v;D(g,k)}switch(a.step){case "single":var y=z?p:v,u=j-i;break;default:y=i;u=j%i?j-j%i:j-i}n.css({width:k*
m,height:g*o,left:s?"auto":0,right:s?0:"auto"});b(".boxplus-viewport",f).css({width:p*m,height:v*o});f.css("width",p*m);g=a.showButtons;k=a.showLinks;var N=a.showPageCounter;if(g||k||N){g='<div class="boxplus-paging">'+(g?t("first")+t("prev"):"")+(k?l("first")+"&nbsp;"+l("prev")+" ":"")+(N?'<span class="boxplus-current">1</span> / '+('<span class="boxplus-total">'+Math.ceil(j/i)+"</span>"):"")+(k?" "+l("next")+"&nbsp;"+l("last"):"")+(g?t("next")+t("last"):"")+"</div>";switch(a.navigation){case "both":f.prepend(g).append(g);
break;case "top":f.prepend(g);break;default:f.append(g)}}if(a.showOverlayButtons)b(".boxplus-viewport",f).append(b(t("prev")+t("next")).addClass((z?m:o)<120?"boxplus-small":"boxplus-large").addClass(z?"boxplus-vertical":"boxplus-horizontal"));a.contextmenu||b(document).bind("contextmenu",function(d){return!B.filter(d.target).size()});var Q=b(".boxplus-first",f).click(function(){x("first")}),P=b(".boxplus-prev",f).click(function(){x("prev")}),R=b(".boxplus-next",f).click(function(){x("next")}),S=b(".boxplus-last",
f).click(function(){x("last")});e.addClass(I).children().addClass(H);K(e.not(J(e).one("boxplus-load",function(d){var h=b(d.target);d=b("img:first",h);b(new Image).load(function(){K(h)}).attr("src",d.attr("longdesc"))}).get()));F();f.removeClass(C);n.css({top:0,left:s?"auto":0,right:s?0:"auto",visibility:"visible"});if(a.opacity<1){B.css("opacity",a.opacity);B.hover(function(){b(this).stop().animate({opacity:1},"slow")},function(){b(this).stop().animate({opacity:a.opacity},"slow")})}if(A>0){A=Math.max(A,
G);var O=window.setInterval(M,A);f.mouseover(function(){window.clearInterval(O)}).mouseout(function(){O=window.setInterval(M,A)})}});return this}})(__jQuery__);

