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

