function Scroller(perRow, direction){ this.perRow = perRow; this.direction = direction; }
Scroller.prototype = {
	line: 0, 
	
    start: function(){
		if(this.direction == 'horizontal'){
			var boxa   = $('#scroller > ul > li').eq(0);  
	        var boxb   = $('#scroller > ul > li').eq(this.perRow);
	        var width = parseInt(boxa.css('width'))-1;
	        if(width>0){
	            boxa.css('width', width+'px');
	            $('img', boxa).css('margin-left','-'+(48-width)+'px'); 
	            boxb.css('width', (48-width)+'px');
	        } else {
	            $('img', boxa).css('margin-left','0px');
	            var newBox = boxa.clone();
	            $('#scroller > ul').append(newBox);
	            boxa.remove();
	            boxb.css('width', 48+'px');
	        }
	        setTimeout('scroller.start();', 100);
		} else if(this.direction == 'vertical'){
			var first  = $('#scroller > ul > li:first');  
	        var last   = $('#scroller > ul > li:last');
			var height = parseInt(first.css('height'))+1;
			if(height > 48){
	            var newBox = last.clone();
				newBox.css('height', 0+'px');
	            $('#scroller > ul').prepend(newBox);
				last.remove();
			} else {
				$('img', first).css('margin-top', (height-48)+'px'); 
				first.css('height', height+'px');
			}

	        setTimeout('scroller.start();', 100);
		}
    },
	
	wave: function(){
		var pattern = {start: 'NHHFNH', end: 'HNFHHN', width: 2, height: 3};var opacity = {N:1, H:0.50, F:.25};var width   = $('#scroller > ul > li:first > a').length;var height  = $('#scroller > ul > li').length;var fadeBack = $('#scroller > ul > li').eq((this.line-(pattern.height)<0?(pattern.height):this.line-(pattern.height)));
		$('a', fadeBack).fadeTo("fast", 1)
		for(var n=0; n<pattern.height; n++){var element = $('#scroller > ul > li').eq(this.line-n);if((this.line%2)==0)  curPat = pattern.start;else       			  curPat = pattern.end; var pat = curPat.substring(pattern.width*n, pattern.width*n+pattern.width);var i=0;var thisPattern = '';$('a', element).each(function(){var ch = i%pattern.width;var fd = opacity[pat.charAt(ch)];$(this).fadeTo('fast', fd);i++;});}
		this.line++; if(this.line == height-1){this.line = 0; setTimeout('scroller.wave();', 10000);} else setTimeout('scroller.wave();', 100);
	}
}
