/*
 * desearch.js
 */

/**
 * Copyright (c) 2005 D. E. Shaw & Co., L.P. All rights reserved.
 * 
 * This software is the confidential and proprietary information of D. E. Shaw &
 * Co., L.P. ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with D. E. Shaw & Co., L.P.
 */

/**
 * This javascript file has all the functions that will be used by the
 * search and result pages of desearch.
 *
 * @author Gopikrishnan Subramani
 * @version $Id: desearch.js,v 1.18.2.2 2005/10/30 12:13:28 subramag Exp $
 */

/**
 * Returns the url to get the results sorted on the specified column.
 */
function sortBy(lastSortColumn, column) {
	var url = "" + window.location;
	if (lastSortColumn == column) {
    	url = url.replace(/sort_by=[^&]*/, "sort_by=" + column + " ");
	}
	else {
		url = url.replace(/sort_by=[^&]*/, "sort_by=" + column);
	}
	return url;
}

/**
 * Redirects the browser to the specified page number in the result pages.
 */
function gotoPage(pageNumber) {
	var url = "" + window.location;
	url = url.replace(/(&?)pn=([^&])*(&?)/, function ($0, $1, $2, $3) {
		return $1 == "" ? $1 : $3;
	});
	url = url + "&" + "pn=" + pageNumber;
	window.location=url;
}

