/* * jQuery flashScroll - v0.1 * http://tamerayd.in/jquery-flashscroll * * Written by TAMER AYDIN - http://tamerayd.in * * This work is licensed under the Creative Commons Attribution 3.0 Unported License. * To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ * or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. */(function( $ ){    var scrollRepeat;    var acceleration = 0;	var methods = {		init : function( options ) {            return this.each(function() {                var $this = $(this);                var scrollRepeat;                var settings = {                    generatebuttons : false                };                if (options) {                    $.extend(settings,options);                }                                $this.css('overflow','hidden');                $this.prepend('<div class="flashScrollWrapper">');                $('.flashScrollWrapper').css({'width':$('.flashScrollWrapper').parent().css('width')});//ie                $this.children().not('.flashScrollWrapper').clone().appendTo('.flashScrollWrapper');                $this.children().not('.flashScrollWrapper').remove();                $('.scrollUp').bind('mouseover',function () {scrollRepeat = setInterval(function(){acceleration=acceleration+40;$this.flashscroll('up');},40);});                $('.scrollDown').bind('mouseover',function () {scrollRepeat = setInterval(function(){acceleration=acceleration+40;$this.flashscroll('down');},40);});                $('.scrollUp').bind('mouseout',function () {                    clearInterval(scrollRepeat);                    acceleration=0;                    var currentTopM = parseInt($('.flashScrollWrapper').css('margin-top').substring(0,$('.flashScrollWrapper').css('margin-top').length-2));                    if (currentTopM>=0 && currentTopM<20)                        $('.flashScrollWrapper').animate({'margin-top':0},'fast');                    else                        $('.flashScrollWrapper').animate({'margin-top':currentTopM+10},'fast');                });                $('.scrollDown').bind('mouseout',function () {                    clearInterval(scrollRepeat);                    acceleration=0;                    var currentTopM = parseInt($('.flashScrollWrapper').css('margin-top').substring(0,$('.flashScrollWrapper').css('margin-top').length-2));                    var elementH = $this.height();                    var wrapperH = $('.flashScrollWrapper').height();                    if (currentTopM<=elementH-wrapperH || currentTopM<elementH-wrapperH-20)                        $('.flashScrollWrapper').animate({'margin-top':elementH-wrapperH},'fast');                    else                        $('.flashScrollWrapper').animate({'margin-top':currentTopM-10},'fast');                });            });		},        up : function () {            return this.each(function() {                methods.scroll({'element':$(this),'direction':'up'});            });        },        down : function () {            return this.each(function() {                methods.scroll({'element':$(this),'direction':'down'});            });        },        scroll : function ( properties ) {            var sElement = $(properties.element);            var sWrapper = sElement.children('.flashScrollWrapper');            var sWrapperTopM = sWrapper.css('margin-top');            var currentPos = parseInt(sWrapperTopM.substring(0,sWrapperTopM.length-2));            switch (properties.direction) {                case 'up':                    if (currentPos<0)                        sWrapper.css('margin-top',(currentPos+(5+(acceleration/100))));                    break;                default:                    if (currentPos>sElement.height()-sWrapper.height())                        sWrapper.css('margin-top',(currentPos-(5+(acceleration/100))));                    break;            }                    }	};	$.fn.flashscroll = function( method ) {		if ( methods[method] ) {			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));		} else if ( typeof method === 'object' || ! method ) {			return methods.init.apply( this, arguments );			} else {			$.error( 'Method ' +  method + ' does not exist on jquery.flashscroll!' );		}	};	})( jQuery );
