/*	
	JS_Paging.js v 2.0 - Custom Paging Script	
	Author:  Nitin Menon
	Date:	 5/31/2007 	
*/

var paging = {
	$: function(){
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++){
			var element = arguments[i];
			if (typeof element == 'string') element = document.getElementById(element);
			if (arguments.length == 1) return element;
			elements.push(element);
		}
		return elements;	
	},
	DefaultPage: function( b, c, d, e ){
		var u = unescape( window.document.location );
		var a = 1;
		if ( u.indexOf("#") > -1) {
			var _u = u.length;
			var _p = u.indexOf('#');
			a = u.slice( _p + 1, _p + ( _u - _p ) );
		}
		this.ShowPage( a, b, c, d, e );	
	},
	ShowPage: function( a, b, c, d, e ){
		var f = "Page" + a;
		for( x = 1; x <= d; x++ ){
			var gd = this.$( "Page" + x );
			var gp = this.$( "pNum_" + x );
			if ( "Page" + x == f ){
				gd.className = "pageDivUnhide";
				gp.className = "currentPage";
				this.ChangeDisplayText( a, b, c, d, e );
			}else{
				gd.className = "pageDivHide";
				gp.className = "pLink";
			}
		}
		this.ShowPagingLinks( a, b, c, d, e );	
	},
	ChangeDisplayText: function( a, b, c, d, e ){
		var dt = this.$( "dspTxt" );
		if(dt){
			var n1 = ( ( b * a ) - b ) + 1;
			var n2 = b * a;
			if( n2 >= e ) var n2 = e; 
			dt.innerHTML = "Displaying " + n1 + " - " + n2;
		}
	},
	ShowPagingLinks: function( a, b, c, d, e ){
		var f = c - 1;
		for(LPg = 1; LPg <= d; LPg = LPg + c){
			var fp = LPg;
			var lp = LPg + f;
			if( lp >= d ) lp = d;
			if( a >= fp && a <= lp ){
				for( p = 1; p <= d; p++ ){
					var pl = this.$( "pNum_" + p );
					if( p >= fp && p <= lp ){
						if( p == a ){
							pl.className = "currentPage";
						}else{
							pl.className = "pLink";
						}
					}else{
						pl.className = "pLinkHide";
					}
				}
			   break;	
			}
		}
		this.PreviousNext( a, b, c, d, e, fp, lp );
	},
	PreviousNext: function( a, b, c, d, e, fp, lp ){
		var p = this.$( "PrevPg" );
		var n = this.$( "NextPg" );
		if( a <= c ){
			p.className = "disable";
			p.onclick = "";
			if( d <= c ){
				n.className = "disable";
				n.onclick = "";
			}else{
				n.className = "pLink";
				n.onclick = function(){
					paging.ShowPage( lp + 1, b, c, d, e );
				};
			}
		}else if( a > ( d - c ) && a <= d ){
			p.className = "pLink";
			p.onclick = function(){
				paging.ShowPage( fp - 1, b, c, d, e );
			};
			if( ( a >= fp && a<=lp ) && lp < d ){
				n.className = "pLink";
				n.onclick = function(){
					paging.ShowPage( lp + 1, b, c, d, e );
				};
			}else{
				n.className = "disable";
				n.onclick = "";
			}	
		}else{
			p.className = "pLink";
			p.onclick = function(){
				paging.ShowPage( fp - 1, b, c, d, e );
			};
			n.className = "pLink";
			n.onclick = function(){
				paging.ShowPage( lp + 1, b, c, d, e );
			};
		}
	}
}