$(function(){$("body").smoothDivScroll({scrollingSpeed:6,mouseDownSpeedBooster:3,autoScroll:"onstart",autoScrollDirection:"endlessloop",autoScrollSpeed:2,visibleHotSpots:"onstart",hotSpotsVisibleTime:9,startAtElementId:"15"})});(function($){jQuery.fn.smoothDivScroll=function(m){var n={scrollingHotSpotLeft:"#slider_scroll_left",scrollingHotSpotRight:"#slider_scroll_right",scrollWrapper:"#slider_wr",scrollableArea:"#slider_box",hiddenOnStart:false,ajaxContentURL:"",countOnlyClass:"",scrollingSpeed:50,mouseDownSpeedBooster:3,autoScroll:"",autoScrollDirection:"right",autoScrollSpeed:20,pauseAutoScroll:"",visibleHotSpots:"",hotSpotsVisibleTime:5,startAtElementId:"startAtMe"};m=$.extend(n,m);return this.each(function(){var b=$(this);if(m.ajaxContentURL.length!==0){b.scrollableAreaWidth=0;b.find(m.scrollableArea).load((m.ajaxContentURL),function(){b.find(m.scrollableArea).children((m.countOnlyClass)).each(function(){b.scrollableAreaWidth=b.scrollableAreaWidth+$(this).outerWidth(true)});b.find(m.scrollableArea).css("width",(b.scrollableAreaWidth+"px"));if(m.hiddenOnStart){b.hide()}windowIsResized();setHotSpotHeightForIE()})}var c;var d;var f=b.offset().left;var g=0;d=1;var h=false;$(window).one("load",function(){if(m.ajaxContentURL.length===0){b.scrollableAreaWidth=0;b.tempStartingPosition=0;b.find(m.scrollableArea).children((m.countOnlyClass)).each(function(){if((m.startAtElementId.length!==0)&&(($(this).attr("id"))==m.startAtElementId)){b.tempStartingPosition=b.scrollableAreaWidth}b.scrollableAreaWidth=b.scrollableAreaWidth+$(this).outerWidth(true)});b.find(m.scrollableArea).css("width",b.scrollableAreaWidth+"px");if(m.hiddenOnStart){b.hide()}}b.find(m.scrollWrapper).scrollLeft(b.tempStartingPosition);if(m.autoScroll!==""){b.autoScrollInterval=setInterval(k,6)}if(m.autoScroll=="always"){hideLeftHotSpot();hideRightHotSpot()}clearInterval(b.autoScrollInterval);switch(m.visibleHotSpots){case"always":makeHotSpotBackgroundsVisible();break;case"onstart":makeHotSpotBackgroundsVisible();b.hideHotSpotBackgroundsInterval=setInterval(hideHotSpotBackgrounds,(m.hotSpotsVisibleTime*1000));break;default:break}});b.find(m.scrollingHotSpotRight,m.scrollingHotSpotLeft).one('mouseover',function(){if(m.autoScroll=="onstart"){clearInterval(b.autoScrollInterval)}});$(window).bind("resize",function(){windowIsResized()});function windowIsResized(){if(!(m.hiddenOnStart)){b.scrollableAreaWidth=0;b.find(m.scrollableArea).children((m.countOnlyClass)).each(function(){b.scrollableAreaWidth=b.scrollableAreaWidth+$(this).outerWidth(true)});b.find(m.scrollableArea).css("width",b.scrollableAreaWidth+'px')}b.find(m.scrollWrapper).scrollLeft("0");var a=$("body").innerWidth();if(m.autoScroll!=="always"){if(b.scrollableAreaWidth<a){hideLeftHotSpot();hideRightHotSpot()}else{showHideHotSpots()}}}function hideLeftHotSpot(){b.find(m.scrollingHotSpotLeft).hide()}function hideRightHotSpot(){b.find(m.scrollingHotSpotRight).hide()}function showLeftHotSpot(){b.find(m.scrollingHotSpotLeft).show();if(g<=0){g=b.find(m.scrollingHotSpotLeft).width()}}function showRightHotSpot(){b.find(m.scrollingHotSpotRight).show();if(g<=0){g=b.find(m.scrollingHotSpotRight).width()}}function setHotSpotHeightForIE(){jQuery.each(jQuery.browser,function(i,a){if(i=="msie"&&jQuery.browser.version.substr(0,1)=="6"){b.find(m.scrollingHotSpotLeft).css("height",(b.find(m.scrollableArea).innerHeight()));b.find(m.scrollingHotSpotRight).css("height",(b.find(m.scrollableArea).innerHeight()))}})}b.find(m.scrollingHotSpotRight).bind('mousemove',function(e){var x=e.pageX-(this.offsetLeft+f);c=Math.round((x/g)*m.scrollingSpeed);if(c===Infinity){c=0}});b.find(m.scrollingHotSpotRight).bind('mouseover',function(){if(m.autoScroll=="onstart"){clearInterval(b.autoScrollInterval)}b.rightScrollInterval=setInterval(j,6)});b.find(m.scrollingHotSpotRight).bind('mouseout',function(){clearInterval(b.rightScrollInterval);c=0});b.find(m.scrollingHotSpotRight).bind('',function(){d=m.mouseDownSpeedBooster});$("*").bind('mouseup',function(){d=1});var j=function(){if(c>0){b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()+(c*d))}showHideHotSpots()};if(m.pauseAutoScroll=="mousedown"&&m.autoScroll=="always"){b.find(m.scrollWrapper).bind('mousedown',function(){clearInterval(b.autoScrollInterval)});b.find(m.scrollWrapper).bind('mouseup',function(){b.autoScrollInterval=setInterval(k,6)})}else if(m.pauseAutoScroll=="mouseover"&&m.autoScroll=="always"){b.find(m.scrollWrapper).bind('mouseover',function(){clearInterval(b.autoScrollInterval)});b.find(m.scrollWrapper).bind('mouseout',function(){b.autoScrollInterval=setInterval(k,6)})}b.previousScrollLeft=0;b.pingPongDirection="right";b.swapAt;b.getNextElementWidth=true;var k=function(){if(m.autoScroll=="onstart"){showHideHotSpots()}switch(m.autoScrollDirection){case"right":b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()+m.autoScrollSpeed);break;case"left":b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()-m.autoScrollSpeed);break;case"backandforth":b.previousScrollLeft=b.find(m.scrollWrapper).scrollLeft();if(b.pingPongDirection=="right"){b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()+m.autoScrollSpeed)}else{b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()-m.autoScrollSpeed)}if(b.previousScrollLeft===b.find(m.scrollWrapper).scrollLeft()){if(b.pingPongDirection=="right"){b.pingPongDirection="left"}else{b.pingPongDirection="right"}}break;case"endlessloop":if(b.getNextElementWidth){if(m.startAtElementId!==""){b.swapAt=$("#"+m.startAtElementId).outerWidth()}else{b.swapAt=b.find(m.scrollableArea).children(":first-child").outerWidth()}b.getNextElementWidth=false}b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()+m.autoScrollSpeed);if((b.swapAt<=b.find(m.scrollWrapper).scrollLeft())){b.find(m.scrollableArea).append(b.find(m.scrollableArea).children(":first-child").clone());b.find(m.scrollWrapper).scrollLeft((b.find(m.scrollWrapper).scrollLeft()-b.find(m.scrollableArea).children(":first-child").outerWidth()));b.find(m.scrollableArea).children(":first-child").remove();b.getNextElementWidth=true}break;default:break}};b.find(m.scrollingHotSpotLeft).bind('mousemove',function(e){var x=b.find(m.scrollingHotSpotLeft).innerWidth()-(e.pageX-f);c=Math.round((x/g)*m.scrollingSpeed);if(c===Infinity){c=0}});b.find(m.scrollingHotSpotLeft).bind('mouseover',function(){if(m.autoScroll=="onstart"){clearInterval(b.autoScrollInterval)}b.leftScrollInterval=setInterval(l,6)});b.find(m.scrollingHotSpotLeft).bind('mouseout',function(){clearInterval(b.leftScrollInterval);c=0});b.find(m.scrollingHotSpotLeft).bind('',function(){d=m.mouseDownSpeedBooster});var l=function(){if(c>0){b.find(m.scrollWrapper).scrollLeft(b.find(m.scrollWrapper).scrollLeft()-(c*d))}showHideHotSpots()};function showHideHotSpots(){if(b.find(m.scrollWrapper).scrollLeft()===0){hideLeftHotSpot();showRightHotSpot()}else if((b.scrollableAreaWidth)<=(b.find(m.scrollWrapper).innerWidth()+b.find(m.scrollWrapper).scrollLeft())){hideRightHotSpot();showLeftHotSpot()}else{showRightHotSpot();showLeftHotSpot()}}function makeHotSpotBackgroundsVisible(){b.find(m.scrollingHotSpotLeft).addClass("scrollingHotSpotLeftVisible");b.find(m.scrollingHotSpotRight).addClass("scrollingHotSpotRightVisible")}function hideHotSpotBackgrounds(){clearInterval(b.hideHotSpotBackgroundsInterval);b.find(m.scrollingHotSpotLeft).fadeTo("slow",0.0,function(){b.find(m.scrollingHotSpotLeft).removeClass("scrollingHotSpotLeftVisible")});b.find(m.scrollingHotSpotRight).fadeTo("slow",0.0,function(){b.find(m.scrollingHotSpotRight).removeClass("scrollingHotSpotRightVisible")})}})}})(jQuery);