NXC.Paginator.Simple = new Class( {

	Extends: NXC.Paginator.Base,
	Implements: [Options, Events],

	options: {
		'onShowPage': $empty()
	},

	initialize: function( blocksCSSPath, options ) {
		this.blocks = document.getElements( blocksCSSPath );

		this.setOptions( options );
		this.parent( options );
	},

	getPagesCount: function() {
		return Math.ceil( this.blocks.length / this.itemsPerPage );
	},

	showItems: function() {
		var minBlock = ( this.currentPage - 1 ) * this.itemsPerPage;
		var maxBlock = this.currentPage * this.itemsPerPage;

		var displayItems = [];
		var tag = ( this.blocks[0] ) ? this.blocks[0].get( 'tag' ) : false;
		var displayStyle = 'block';
		if( tag == 'tr' && !Browser.Engine.trident ) {
			displayStyle = 'table-row';
		} else if ( tag == 'li' ) {
			displayStyle = 'list-item';
		}
		this.blocks.each( function( block, index ) {
			if( index >= minBlock && index < maxBlock ) {
				block.setStyle( 'display', displayStyle );
				displayItems.include( block );
			} else {
				block.setStyle( 'display', 'none' );
			}
		} );

		new Fx.Scroll( window ).toElement( this.blocks[0] );

		this.fireEvent( 'pageShow', [ displayItems ] );
	}
} );
