/** public ResultsHead : Performs sorting functionality by changing request parameters.
  * Also controls button states for the column headers.
  * @param URLUtility urlUtil URL utility for this request
  */
function ResultsHead(urlUtil) {
	this.urlUtil = urlUtil;
	this.sortCol = this.urlUtil.getParameter("sortCol");
	this.sortDir = this.urlUtil.getParameter("sortDir");
	this.btnMan = new BtnStateManager();
}
/** public static final map CLASSNAMES : CSS class names for button states. */
ResultsHead.CLASSNAMES = {"off": "sortHead", "over": "sortHeadOver", "on": "sortHeadOn", "disabled": "sortHeadDisabled"};
/** public void init : Initialize the ResultsHead instance on page load. */
ResultsHead.prototype.init = function() {
	this.btnMan.setClassNames(ResultsHead.CLASSNAMES);
	this.btnMan.init((this.sortCol) ? "resultsHead_" + this.sortCol : "resultsHead_year");
}
/** public void itemOut : Execute a button rollout.
  * @param String id : id of button to roll out from
  */
ResultsHead.prototype.itemOut = function(id) { this.btnMan.itemOut("resultsHead_" + id); }
/** public void itemOver : Execute a button rollover.
  * @param String id : id of button to roll over
  */
ResultsHead.prototype.itemOver = function(id) { this.btnMan.itemOver("resultsHead_" + id); }
/** public void sortBy : Sort by a new column, or reverse the sort for the existing column.
  * @param String column : column key to sort by
  */
ResultsHead.prototype.sortBy = function(column) {
	if (!column) return;
	// if sorting by same column, swap sort direction;
	// if new column, default to: year/desc or everything else/asc
	if (column == this.sortCol) this.urlUtil.setParameter("sortDir", ((this.sortDir == "asc") ? "desc" : "asc"));
	else this.urlUtil.setParameter("sortDir", ((column == "year") ? "desc" : "asc"));
	// set the new sort column
	this.urlUtil.setParameter("sortCol", column);
	document.location.href = this.urlUtil.getUrl();
}


