/*
 Sliding Billboard
 Version: 1.0.7
 (c) 2011 DMXzone.com
 @build 07-09-2011 13:38:45
*/
(function(i){i.fn.swipe=function(a){var h={threshold:{x:30,y:30},swipeUp:function(){alert("swiped up")},swipeDown:function(){alert("swiped down")},swipeLeft:function(){alert("swiped left")},swipeRight:function(){alert("swiped right")}},a=i.extend(h,a);if(!this)return!1;var l=typeof Touch=="object";return this.each(function(){function a(f){l||f.preventDefault();j.x=l?f.targetTouches[0].pageX:f.pageX;j.y=l?f.targetTouches[0].pageY:f.pageY;k.x=l?f.targetTouches[0].pageX:f.pageX;k.y=l?f.targetTouches[0].pageY:
f.pageY}function v(a){a.preventDefault();k.x=l?a.targetTouches[0].pageX:a.pageX;k.y=l?a.targetTouches[0].pageY:a.pageY}function r(a){l||a.preventDefault();var i=j.x-k.x,o=j.y-k.y;Math.abs(i)<Math.abs(o)?o<-h.threshold.y?h.swipeUp(a):o>h.threshold.y&&h.swipeDown(a):i<-h.threshold.x?h.swipeLeft(a):i>h.threshold.x&&h.swipeRight(a)}function y(){}i(this);var j={x:0,y:0},k={x:0,y:0};l?(this.addEventListener("touchstart",a,!1),this.addEventListener("touchmove",v,!1),this.addEventListener("touchend",r,!1),
this.addEventListener("touchcancel",y,!1)):(i(this).bind("mousedown",a),i(this).bind("mousemove",v),i(this).bind("mouseup",r))})}})(jQuery);jQuery.fn.extend({dmxSlidingBillboard:function(i){return this.each(function(){jQuery.extend(this,new jQuery.dmxSlidingBillboard(this,i))})}});
jQuery.dmxSlidingBillboard=function(i,a){function h(a){if(typeof a==="string")switch(a){case "fast":return"200ms";case "slow":return"600ms";default:return"400ms"}else return a+"ms"}function l(b){var b=jQuery(b.target),c=b.offsetParent(),m=b.closest(a.item);b.closest("[class*=layout-]");var d=/layout-(\w+)/i.exec(b.closest("[class*=layout-]").attr("class"))[1]||a.layoutStyle,g=c.width(),i=c.height(),j=parseInt(c.css("padding-top"))||0,f,e,h;d!="fill"&&(z/A<b.width()/b.height()?(f=(parseInt(b.css("marginLeft"))||
0)+(parseInt(b.css("marginRight"))||0),e=(parseInt(b.css("borderLeftpWidth"))||0)+(parseInt(b.css("borderRightWidth"))||0),h=(parseInt(b.css("paddingLeft"))||0)+(parseInt(b.css("paddingRight"))||0),f=a.imageScaleUp?Math.min(g-f-e-h,z):Math.min(g-f-e-h,z,b.width()),e=f/b.width()*b.height()):(f=(parseInt(b.css("marginTop"))||0)+(parseInt(b.css("marginBottom"))||0),e=(parseInt(b.css("borderTopWidth"))||0)+(parseInt(b.css("borderBottomWidth"))||0),h=(parseInt(b.css("paddingTop"))||0)+(parseInt(b.css("paddingBottom"))||
0),e=a.imageScaleUp&&d!="top"?Math.min(i-f-e-h,A):Math.min(i-f-e-h,A,b.height()),f=e/b.height()*b.width()),b.width(f),b.height(e),d=="left"?b.css({position:"absolute",top:j+(i/2-b.outerHeight(!0)/2),left:c.css("padding-left"),right:"auto"}):d=="right"?b.css({position:"absolute",top:j+(i/2-b.outerHeight(!0)/2),left:"auto",right:c.css("padding-right")}):d=="top"?b.css({position:"absolute",top:j,left:g/2-b.outerWidth(!0)/2,right:"auto"}):d=="full"&&b.css({position:"absolute",top:c.innerHeight()/2-b.outerHeight(!0)/
2,left:c.innerWidth()/2-b.outerWidth(!0)/2,right:"auto"}));if(d=="left")m.find("h4,p").css({margin:0,marginLeft:b.outerWidth(!0)});else if(d=="right")m.find("h4,p").css({margin:0,marginRight:b.outerWidth(!0)});else if(d=="top")m.find("h4,p").eq(0).css({margin:0,marginTop:b.outerHeight(!0)});else if(d=="full"||a.layoutStyle=="fill")d=="fill"&&b.css({position:"absolute",top:0,left:0,right:0,bottom:0,width:m.innerWidth()+"px",height:m.innerHeight()+"px",margin:0,padding:0,border:"0px none"}),b=m.find("h4"),
f=(parseInt(b.css("marginLeft"))||0)+(parseInt(b.css("marginRight"))||0),e=(parseInt(b.css("borderLeftpWidth"))||0)+(parseInt(b.css("borderRightWidth"))||0),h=(parseInt(b.css("paddingLeft"))||0)+(parseInt(b.css("paddingRight"))||0),m.find("h4").addClass("full").css({position:"absolute",width:m.innerWidth()-f-h-e,left:0,top:0,zIndex:1}),b=m.find("p"),f=(parseInt(b.css("marginLeft"))||0)+(parseInt(b.css("marginRight"))||0),e=(parseInt(b.css("borderLeftpWidth"))||0)+(parseInt(b.css("borderRightWidth"))||
0),h=(parseInt(b.css("paddingLeft"))||0)+(parseInt(b.css("paddingRight"))||0),m.find("p").addClass("full").css({position:"absolute",width:m.innerWidth()-f-h-e,left:0,bottom:0,zIndex:1}).hide(),m.hover(function(){jQuery("p",this).slideDown("normal")},function(){jQuery("p",this).slideUp("normal")})}function p(a){typeof a=="number"&&(a=q[a-1]);return jQuery(a,i)}function v(a){e=jQuery.inArray("#"+a,q);jQuery("a.selected",B).removeClass("selected");jQuery("a[href=#"+a+"]",B).addClass("selected");y()}
function r(a){jQuery("a.selected",s).removeClass("selected");jQuery("a",s).eq(a).addClass("selected")}function y(){s.empty();if(t[e]>1)for(var a=1;a<=t[e];++a){var d=jQuery('<a href="#'+a+'"></a>').data("index",a).text(a);d.click(function(){c.moveToPage(jQuery(this).data("index"));return!1});s.append(d).append(" ")}else s.append('<a href="javascript:void();" style="visibility:hidden;">&nbsp;</a>');s.append('<div style="clear:both;"></div>');r(0)}var a=jQuery.extend({},jQuery.dmxSlidingBillboard.defaults,
a),j,k,f,w,o,d,z,A,q=[],t=[],e=0,g=0,C=!1,x=null,c=this,u=jQuery(i).css({visibility:"hidden",overflow:"hidden"}),D=jQuery(a.header,i),E=jQuery(a.footer,i),n=jQuery(a.view,i),B=jQuery(a.sectionNav,a.globalSectionNav?null:i),s=jQuery(a.pageNav,a.globalPageNav?null:i);jQuery.extend(c,{version:"1.0.3",next:function(){p(e+1);C||(a.autoNextSection&&q.length>1&&g==t[e]-1?c.nextSection():c.nextPage())},prevSection:function(){e==0?c.moveToSection(q.length):c.moveToSection(e)},nextSection:function(){e==q.length-
1?c.moveToSection(1):c.moveToSection(e+2)},moveToSection:function(b){$section=p(e+1);expr=a.item;g>0&&(expr+=":gt("+(g*d-1)+")");expr+=":lt("+d+")";$section.find(expr).each(function(){jQuery(this).data("blur")&&jQuery(this).data("blur").call(this)});$section=p(b);$section.length==1&&(a.horizontal?typeof WebKitTransitionEvent=="object"?(j.bind("webkitTransitionEnd",function(){jQuery(a.section,j).not($section).css({top:"0px"});g=0;expr=a.item;g>0&&(expr+=":gt("+(g*d-1)+")");expr+=":lt("+d+")";$section.find(expr).each(function(){jQuery(this).data("focus")&&
jQuery(this).data("focus").call(this)});$(this).unbind("webkitTransitionEnd")}),j.css({"-webkit-transition-property":"-webkit-transform","-webkit-transition-timing-function":"ease-in-out","-webkit-transition-duration":h(a.scrollDuration),"-webkit-transform":"translate3d(-"+$section.position().left+"px,0,0)"})):j.stop().animate({left:"-"+$section.position().left+"px"},a.scrollDuration,a.scrollEasing,function(){jQuery(a.section,j).not($section).css({top:"0px"});g=0;expr=a.item;g>0&&(expr+=":gt("+(g*
d-1)+")");expr+=":lt("+d+")";$section.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)})}):typeof WebKitTransitionEvent=="object"?(j.bind("webkitTransitionEnd",function(){jQuery(a.section,j).not($section).css({left:"0px"});g=0;expr=a.item;g>0&&(expr+=":gt("+(g*d-1)+")");expr+=":lt("+d+")";$section.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)});$(this).unbind("webkitTransitionEnd")}),j.css({"-webkit-transition-property":"-webkit-transform",
"-webkit-transition-timing-function":"ease-in-out","-webkit-transition-duration":h(a.scrollDuration),"-webkit-transform":"translate3d(0,-"+$section.position().top+"px,0)"})):j.stop().animate({top:"-"+$section.position().top+"px"},a.scrollDuration,a.scrollEasing,function(){jQuery(a.section,j).not($section).css({left:"0px"});g=0;expr=a.item;g>0&&(expr+=":gt("+(g*d-1)+")");expr+=":lt("+d+")";$section.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)})}),v($section.attr("id")))},
setSection:function(b){$section=p(b);this.setPage(1);$section.length==1&&(j.stop(),a.horizontal?j.css({left:"-"+$section.position().left+"px"}):j.css({top:"-"+$section.position().top+"px"}),v($section.attr("id")))},prevPage:function(){g==0?c.moveToPage(t[e]):c.moveToPage(g)},nextPage:function(){g==t[e]-1?c.moveToPage(1):c.moveToPage(g+2)},moveToPage:function(b){var c=p(e+1);expr=a.item;g>0&&(expr+=":gt("+(g*d-1)+")");expr+=":lt("+d+")";c.find(expr).each(function(){jQuery(this).data("blur")&&jQuery(this).data("blur").call(this)});
a.horizontal?typeof WebKitTransitionEvent=="object"?(c.bind("webkitTransitionEnd",function(){expr=a.item;b-1>0&&(expr+=":gt("+((b-1)*d-1)+")");expr+=":lt("+d+")";c.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)});$(this).unbind("webkitTransitionEnd")}),c.css({"-webkit-transition-property":"-webkit-transform","-webkit-transition-timing-function":"ease-in-out","-webkit-transition-duration":h(a.scrollDuration),"-webkit-transform":"translate3d(0,-"+(b-1)*
f+"px,0)"})):c.stop().animate({top:"-"+(b-1)*f+"px"},a.scrollDuration,a.scrollEasing,function(){expr=a.item;b-1>0&&(expr+=":gt("+((b-1)*d-1)+")");expr+=":lt("+d+")";c.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)})}):typeof WebKitTransitionEvent=="object"?(c.bind("webkitTransitionEnd",function(){expr=a.item;b-1>0&&(expr+=":gt("+((b-1)*d-1)+")");expr+=":lt("+d+")";c.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)});
$(this).unbind("webkitTransitionEnd")}),c.css({"-webkit-transition-property":"-webkit-transform","-webkit-transition-timing-function":"ease-in-out","-webkit-transition-duration":h(a.scrollDuration),"-webkit-transform":"translate3d(-"+(b-1)*k+"px,0,0)"})):c.stop().animate({left:"-"+(b-1)*k+"px"},a.scrollDuration,a.scrollEasing,function(){expr=a.item;b-1>0&&(expr+=":gt("+((b-1)*d-1)+")");expr+=":lt("+d+")";c.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)})});
g=b-1;r(g)},setPage:function(b){var c=p(e+1);c.stop();a.horizontal?c.css({top:"-"+(b-1)*f+"px"}):c.css({left:"-"+(b-1)*k+"px"});g=b-1;r(g)},setSectionItem:function(a){c.setPage(Math.floor((a-1)/d)+1)},play:function(b){a.scrollInterval>0&&x===null&&(x=setInterval(c.next,b?b:a.scrollInterval))},stop:function(){x!==null&&(clearInterval(x),x=null)},redraw:function(){n.css({visibility:"hidden"});k=n.width();f=u.height()-D.outerHeight(!0)-E.outerHeight(!0);n.height(f);d=a.columns*a.rows;w=k/a.columns;o=
f/a.rows;z=typeof a.imageMaxWidth=="string"?a.imageMaxWidth.indexOf("%")>0?w*(parseInt(a.imageMaxWidth)/100)||0:parseInt(a.imageMaxWidth)||0:a.imageMaxWidth;A=typeof a.imageMaxHeight=="string"?a.imageMaxHeight.indexOf("%")>0?o*(parseInt(a.imageMaxHeight)/100)||0:parseInt(a.imageMaxHeight)||0:a.imageMaxHeight;var b=jQuery(a.item,n).eq(0),c=w;c-=parseInt(b.css("paddingLeft"))|0;c-=parseInt(b.css("paddingRight"))|0;c-=parseInt(b.css("borderLeftWidth"))|0;c-=parseInt(b.css("borderRightWidth"))|0;c-=parseInt(b.css("marginLeft"))|
0;c-=parseInt(b.css("marginRight"))|0;var c=Math.floor(c),e=o;e-=parseInt(b.css("paddingTop"))|0;e-=parseInt(b.css("paddingBottom"))|0;e-=parseInt(b.css("borderTopWidth"))|0;e-=parseInt(b.css("borderBottomWidth"))|0;e-=parseInt(b.css("marginTop"))|0;e-=parseInt(b.css("marginBottom"))|0;e=Math.floor(e);jQuery(a.section,j).each(function(b){jQuery(a.item,this).css({display:"block",position:"absolute",width:c+"px",height:e+"px"}).each(function(b){a.horizontal?jQuery(this).css({top:Math.floor(Math.floor(b/
a.columns)*o)+"px",left:Math.floor(b%a.columns*w)+"px"}):jQuery(this).css({left:Math.floor(Math.floor(b/a.rows)*w)+"px",top:Math.floor(b%a.rows*o)+"px"});jQuery(this).hover(function(){jQuery(this).attr("onclick")&&jQuery(this).addClass("clickable");jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover clickable")})});t[b]=Math.ceil(jQuery(a.item,this).length/d);q[b]="#"+this.id});a.horizontal?jQuery(a.section,j).width(k).each(function(a){jQuery(this).css({position:"absolute",
left:Math.floor(a*k)+"px"})}):jQuery(a.section,j).height(f).each(function(a){jQuery(this).css({position:"absolute",top:Math.floor(a*f)+"px"})});jQuery("li>img,li>a>img",u).each(function(){$this=jQuery(this);$this.attr("width")&&$this.css("width",parseInt($this.attr("width"))).removeAttr("width");$this.attr("height")&&$this.css("height",parseInt($this.attr("height"))).removeAttr("height");if($this.width()>0&&$this.height()>0)l({target:this});else{var a=$this.attr("src");$this.attr("src","");$this.one("load",
l);$this.attr("src",a)}});n.css({visibility:"visible"})}});(function(){jQuery("a[onfocus]").each(function(){jQuery(this).parents("li").data("focus",this.onfocus).end().removeAttr("onfocus")});jQuery("a[onblur]").each(function(){jQuery(this).parents("li").data("blur",this.onblur).end().removeAttr("onblur")});n.css("position")=="static"&&n.css({position:"relative"});n.css({overflow:"hidden"});n.wrapInner(document.createElement("div"));j=n.children().eq(0);j.css({position:"absolute",left:0,top:0,"-webkit-transform":"translate3d(0,0,0)"});
j.children().css({"-webkit-transform":"translate3d(0,0,0)"});y();c.redraw();location.hash&&jQuery.inArray(location.hash,q)>-1?c.setSection(location.hash):c.setSection(a.startSection);c.setSectionItem(a.startIndex);var b=p(e+1),f=Math.floor((a.startIndex-1)/d)+1;expr=a.item;f-1>0&&(expr+=":gt("+((f-1)*d-1)+")");expr+=":lt("+f*d+")";b.find(expr).each(function(){jQuery(this).data("focus")&&jQuery(this).data("focus").call(this)});B.find("a[href^=#]").click(function(){c.moveToSection(jQuery(this).attr("href"));
return!1});var g=jQuery(a.navLeft,a.globalNav?null:i),h=jQuery(a.navRight,a.globalNav?null:i),k=jQuery(a.navUp,a.globalNav?null:i),l=jQuery(a.navDown,a.globalNav?null:i);g.hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")}).click(function(){a.horizontal?c.prevSection():c.prevPage()});h.hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")}).click(function(){a.horizontal?c.nextSection():c.nextPage()});k.hover(function(){jQuery(this).addClass("hover")},
function(){jQuery(this).removeClass("hover")}).click(function(){a.horizontal?c.prevPage():c.prevSection()});l.hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")}).click(function(){a.horizontal?c.nextPage():c.nextSection()});a.showSideNavOnMouseOver&&(g.hide(),h.hide(),k.hide(),l.hide());u.hover(function(){C=!0;a.showSideNavOnMouseOver&&(g.fadeIn(),h.fadeIn(),k.fadeIn(),l.fadeIn())},function(){C=!1;a.showSideNavOnMouseOver&&(g.fadeOut(),h.fadeOut(),k.fadeOut(),
l.fadeOut())});a.redrawOnWindowResize&&jQuery(window).resize(function(){c.redraw()});a.mousewheel&&u.mousewheel&&u.mousewheel(function(b,d){d>0?a.horizontal?c.prevPage():c.prevSection():d<0&&(a.horizontal?c.nextPage():c.nextSection());return!1});a.keyboard&&jQuery(document).keyup(function(b){switch(b.keyCode){case 37:a.horizontal?c.prevSection():c.prevPage();break;case 38:a.horizontal?c.prevPage():c.prevSection();break;case 39:a.horizontal?c.nextSection():c.nextPage();break;case 40:a.horizontal?c.nextPage():
c.nextSection()}return!1});a.gestures&&n.swipe({swipeUp:function(){a.horizontal?c.prevPage():c.prevSection();return!1},swipeDown:function(){a.horizontal?c.nextPage():c.nextSection();return!1},swipeLeft:function(){a.horizontal?c.prevSection():c.prevPage();return!1},swipeRight:function(){a.horizontal?c.nextSection():c.nextPage();return!1}});a.autoPlay&&c.play()})();u.css({visibility:"visible",overflow:"visible"})};
jQuery.dmxSlidingBillboard.defaults={header:".dmxBillboardHeader",view:".dmxBillboardView",footer:".dmxBillboardFooter",section:"ul",item:"li",sectionNav:".dmxBillboardSectionNav",globalSectionNav:!1,pageNav:".dmxBillboardPageNav",globalPageNav:!1,navLeft:".dmxBillboardLeftNav",navRight:".dmxBillboardRightNav",navUp:".dmxBillboardUpNav",navDown:".dmxBillboardDownNav",globalNav:!1,horizontal:!0,columns:2,rows:1,startSection:1,startIndex:1,scrollInterval:5E3,scrollDuration:"normal",scrollEasing:"swing",
autoPlay:!0,autoNextSection:!0,redrawOnWindowResize:!1,showSideNavOnMouseOver:!1,keyboard:!1,mousewheel:!1,gestures:!1,layoutStyle:"left",imageScaleUp:!1,imageMaxWidth:"100%",imageMaxHeight:"100%"};

