var BOOKS = function(){
	var _P = {
		init : function( params ) {
			_P.params = params;
			$( "#prodnav .prev" ).click(function() {
				_P.browseBooks( "prev" );
				return false;
			});
			$( "#prodnav .next" ).click(function() {
				_P.browseBooks( "next" );
				return false;
			});
			
			_P.max = _P.params.perView;
			_P.count = $("#prodnav li").length;
		
			$( ".thumb").hover(function( e ) {
			
				$("body").append("<div id='tooltip'>"+ $(this).find("img").attr("alt") +"</div>");
				$("#tooltip").css("top",(e.pageY - 20) + "px").css("left",(e.pageX + 20) + "px").fadeIn("fast");
			
			}, function( e ) {
				$("#tooltip").remove();
				
			});
			
			$(".thumb").mousemove(function(e){
				$("#tooltip").css("top",(e.pageY - 20) + "px").css("left",(e.pageX + 20) + "px");
			});	
			
			_P.browseBooks();
			
		},
		params : null,
		data : null,
		first : 0,
		max : 0,
		count : 0,
		browseBooks : function( browse ) {
			if ( browse == "prev" ) {
				if ( _P.first == _P.count && ( _P.count % _P.max > 0 ) ) {
					_P.first = _P.first - ( ( _P.count % _P.max ) + _P.max );
				} else {
					_P.first = _P.first - ( _P.max * 2 );
				}
			}
			var range = _P.first + _P.max;
			var start = 1;
			if ( range > _P.max ) {
				start = ( ( range - _P.max ) + 1 );
			}
			if ( _P.first == 0 ) {
				$( "#prodnav .prev" ).css( "visibility", "hidden" );
			} else {
				$( "#prodnav .prev" ).css( "visibility", "visible" );
			}
			if ( range < _P.count ) {
				$( "#prodnav .next" ).css( "visibility", "visible" );
			} else if ( range >= _P.count ) {
				range = _P.count;
				$( "#prodnav .next" ).css( "visibility", "hidden" );
			}
			
			$(".overclear li").each(function( i ) {
				if ( i >= _P.first && i < range ) {
					$( "#prodnav li:eq(" + i + ")" ).fadeIn( "slow" );
				} else {
					$( "#prodnav li:eq(" + i + ")" ).css( "display", "none" );
				}
			});
			
			
			_P.first = range;
			$( "#prodnav .showing" ).html([
				" <strong>",
				start,
				" - ",
				range,
				"</strong> von <strong>",
				_P.count,
				"</strong> Artikel in dieser Kategorie" ].join( "" ));
		}
	};
	return {
		init : function( params ) {
			_P.init( params );
		}
	};
}();