if (window.NOF_RSN_ARRAY == null) {
    window.NOF_RSN_ARRAY = new Array();
}
  
var nof_null_rsn = new RSNavigator("",0,0,0);

function GetRSN(name) {
    if (window.NOF_RSN_ARRAY[name] != null) {
        return window.NOF_RSN_ARRAY[name];
    } else {
        return nof_null_rsn;
    }
}

function RSNavigator(queryName, startRow, maxVisibleRows, recordCount) {
    this.queryName        = queryName;
    this.startRow            = startRow;
    this.maxVisibleRows = maxVisibleRows;
    this.recordCount       = recordCount;

    RSNavigator.prototype.First = function NOF_RSNavigator_First() {
        this.reload(1);
    };

    RSNavigator.prototype.Previous = function NOF_RSNavigator_Previous(){
        if (this.startRow - this.maxVisibleRows >= 1) {
            this.reload(this.startRow - this.maxVisibleRows);                    
        }
    };

    RSNavigator.prototype.Next = function NOF_RSNavigator_Next(){
        if (this.startRow + this.maxVisibleRows <= this.recordCount) {
            this.reload(this.startRow + this.maxVisibleRows);
        }
    };

    RSNavigator.prototype.Last = function NOF_RSNavigator_Last() {
        if ( this.recordCount > this.maxVisibleRows ) {
            this.reload(this.recordCount - this.maxVisibleRows + 1);
        }
    };

    RSNavigator.prototype.reload = function NOF_RSNavigator_reload(rowNumber) {
        var startRowParam = "NOF_StartRow_"+ this.queryName;
        var newRowArg = startRowParam + "=" + rowNumber;
        if (location.search != "") {
            var paramIndex = location.search.indexOf( startRowParam );
            if (paramIndex != -1) {
                eval("re = /" + startRowParam + "=\\d+/")
                location.href = location.href.replace(re, newRowArg);
            } else {
                location.href = location.href + "&" + newRowArg;
            }
        } else {
            location.href = window.location.href +  "?" + newRowArg;
        }
    };
}