/*
 boxplus carousel engine
 @author  Levente Hunyadi
 @version 1.4.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(d){function z(a,b){return a+b}function w(a,b,g){var l=0;a.each(function(e,h){l=g(l,d(h)[b](true))});return l}function A(a){function b(g){return("0"+g.toString(16)).slice(-2)}return"#"+b(Math.floor(255*a[3]))+b(a[0])+b(a[1])+b(a[2])}d.fn.maxOuterWidth=function(){return w(this,"outerWidth",Math.max)};d.fn.maxOuterHeight=function(){return w(this,"outerHeight",Math.max)};d.fn.totalOuterWidth=function(){return w(this,"outerWidth",z)};d.fn.totalOuterHeight=function(){return w(this,"outerHeight",
z)};d.fn.backColor=function(){function a(x,t){return d.map(x,function(r){return parseInt(r,t)})}var b=this.css("background-color"),g=[0,0,0],l=1;if(b=="transparent")l=0;var e=b.match(/^#[\da-f]{6}$/i);if(e){var h=e[0];g=a([h.substr(1,2),h.substr(3,2),h.substr(5,2)],16)}if(e=b.match(/^#([\da-f]{3})$/i)){h=e[0];g=h.substr(1,1);e=h.substr(2,1);h=h.substr(3,1);g=a([g+g,e+e,h+h],16)}if(e=b.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))g=a(e.slice(1),10);if(e=b.match(/^rgba\((\d+),\s*(\d+),\s*(\d+)\,\s*(\d+(?:\.\d+)?)\)$/)){g=
a(e.slice(1,-1),10);l=parseFloat(e[e.length-1])}g.push(l);return g};d.fn.effectiveBackColor=function(){var a=this;do{var b=a.backColor();a=a.parent()}while(b[3]==0);return b};d.fn.boxplusCarousel=function(a){a=d.extend({rtl:false,orientation:"horizontal",positioning:"side",edges:"sharp",navigation:"top",showButtons:true,showLinks:true,showOverlayButtons:true,contextmenu:true,duration:800,delay:0,opacity:1},a);var b=a.orientation=="vertical",g=a.windowSize?a.windowSize:b?400:"100%";this.filter("ul, ol").each(function(){function l(){m.queue().length>
0||h(1)}function e(){var c=0,o=0;if(t){var i=f.slice(0,q),s=f.eq(q);if(b)c=B/2-i.totalOuterHeight()-s.totalOuterHeight()/2;else o=C/2-i.totalOuterWidth()-s.totalOuterWidth()/2}c={top:c};c[r]=o;return c}function h(c){var o=f[c>0?"first":"last"](),i=0;i=t?b?f.eq(q).totalOuterHeight()/2+f.eq(q+c).totalOuterHeight()/2:f.eq(q).totalOuterWidth()/2+f.eq(q+c).totalOuterWidth()/2:b?o.totalOuterHeight():o.totalOuterWidth();var s=e();if(b)s.top-=c*i;else s[r]-=c*i;m.animate(s,x,"swing",function(){o.detach()[(c>
0?"append":"prepend")+"To"](m);f=d("li:visible",m);f.css("top",0).css(r,0);m.css(e())})}var x=a.duration,t=a.positioning=="center",r=n?"right":"left",m=d(this).wrap("<div />"),j=m.parent().addClass("boxplus-carousel").addClass("boxplus-disabled");j.wrapInner('<div class="boxplus-viewport" />');var f=d("li:visible",m),y=f.find("img:first").attr("src",function(c,o){var i=d(this).attr("longdesc");return/\.(gif|jpe?g|png)$/i.test(i)?i:o}),q=f.size()/2,k=f.maxOuterWidth(),p=f.maxOuterHeight(),n=a.rtl;
m.css({width:b?k:f.totalOuterWidth(),height:b?f.totalOuterHeight():p,left:n?"auto":0,right:n?0:"auto"});k=b?k:g;p=b?g:p;p=d(".boxplus-viewport",j).css({width:k,height:p});j.css({width:k});var C=p.width(),B=p.height();if(q>1&&j.width()>=C&&j.height()>=B){n=function(c){return'<a class="boxplus-'+c+'" href="javascript:void(0)" />'};k=function(c){return'<div class="boxplus-'+c+'" />'};var D=a.showButtons,E=a.showLinks;n='<div class="boxplus-paging">'+(D?k("prev"):"")+(E?n("prev")+" ":"")+(E?" "+n("next"):
"")+(D?k("next"):"")+"</div>";switch(a.navigation){case "both":j.prepend(n).append(n);break;case "top":j.prepend(n);break;default:j.append(n)}if(a.showOverlayButtons)p.append(d(k("prev")+k("next")).addClass("boxplus-large "+(b?"boxplus-vertical":"boxplus-horizontal")));if(a.edges=="blurred"){k=function(c){return'<div class="boxplus-edge boxplus-'+c+'" />'};p.append(d((t?k("start"):"")+k("end")).addClass(b?"boxplus-vertical":"boxplus-horizontal"));var u=j.effectiveBackColor(),F=[u[0],u[1],u[2],0];
d(".boxplus-edge",j).each(function(){var c=d(this);c.css("filter",function(o,i){if(i)return i.replace("#ff000000",A(u)).replace("#00000000",A(F))});c.css("background-image",function(o,i){if(i)return i.replace(/#000|#000000|rgb\(0,\s*0,\s*0\)|black/,"rgba("+u.join(",")+")").replace(/rgba\(0,\s*0,\s*0,\s*1\)|transparent/,"rgba("+F.join(",")+")")})})}m.css(e())}a.contextmenu||d(document).bind("contextmenu",function(c){return!y.filter(c.target).size()});d(".boxplus-prev",j).click(function(){if(!(m.queue().length>
0)){var c=f.last();b?c.css("top",-f.totalOuterHeight()):c.css(r,-f.totalOuterWidth());h(-1)}});d(".boxplus-next",j).click(l);j.removeClass("boxplus-disabled");m.css({visibility:"visible"});if(a.opacity<1){y.css("opacity",a.opacity);y.hover(function(){d(this).stop().animate({opacity:1},"slow")},function(){d(this).stop().animate({opacity:a.opacity},"slow")})}var v=a.delay;if(v>0){v=Math.max(v,x);var G=window.setInterval(l,v);j.mouseover(function(){window.clearInterval(G)}).mouseout(function(){G=window.setInterval(l,
v)})}});return this}})(__jQuery__);

