
// handle selecting a sub category
function browseSubCat() {

  var nextCat = document.getElementById("subCatSelect").value;

  if (nextCat != 0) {
    window.location.href = linkMap.categories[nextCat];
  }

}

// handle changing the search order
function changeDisplayOrder(stateType,stateVars) {

  var sortOrder = document.getElementById("sortBySelect").value;

  // expects something in the form of searchcolumn_order
  var sortInfo = sortOrder.split("_");

	var urlString = selfLink + '/?sort=' + sortInfo[0] + '&sortorder=' + sortInfo[1];

  // array can be broken into pairs of [statevar,value]
  for (var i = 0; i < stateVars.length; i++) {

    // skip attributes that are 0 or empty string
    if (stateVars[i+1] != "" && stateVars[i+1] != 0 && stateVars[i] != 'sortorder' && stateVars[i] != 'sort' && stateVars[i] != stateType) {
      urlString = urlString + "&" + stateVars[i] + "=" + urlencode(stateVars[++i]);
    } else {
      i++;
    }

  }

  window.location.href = urlString;

}

// on pagination hover
function paginateHover(element,type) {

  if (type == "on") {

    element.style.backgroundColor = "#ccccff";
    element.style.cursor = "pointer";

  } else if (type == "off") {

    element.style.backgroundColor = "#dddddd";
    element.style.cursor = "";

  }

}

