
function load()
  {
  var criteria, index, item, month, now, params, result, rules, selector, title;

  title = document.getElementById("page");  /* Set the title */
  title.innerHTML = document.title;

  now = new Date();  /* set the fall or spring menu color for the shipping season */
  month = now.getMonth();
  if (month >= 4 && month <= 9)
    selector = "div.menu div.fall";
  else
    selector = "div.menu div.spring";
  if (document.styleSheets[0].cssRules)
    rules = document.styleSheets[0].cssRules;
  else if (document.styleSheets[0].rules)
    rules = document.styleSheets[0].rules;
  for (index = 0; index < rules.length; index++)
    {
    if (rules[index].selectorText.toLowerCase() == selector)
      rules[index].style.backgroundColor = "#FFCC66";
    }

  params = window.location.search;
  if (window.location.pathname.match(/^\/(new_)?display.aspx/i) != null)  /* display page */
    {
    result = params.match(/(prod=|text=)([^&]+)/i);  /* get the item id */
    if (result != null)
      {
      item = decodeURIComponent(result[2].replace(/\+/g, " ")).toLowerCase();  /* scroll to the item */
      document.getElementById(item).scrollIntoView(true);
      }
    }
  else
    {
    criteria = document.getElementById("SearchCriteria");
    if (criteria != null)
      {
      result = params.match(/SearchCriteria=([^&]+)/i);  /* get the search criteria */
      if (result != null)
        criteria.innerHTML = decodeURIComponent(result[1].replace(/\+/g, " "));
      }
    }
  }

function menu_hide(div)  /* hide the menu */
  {
  div.getElementsByTagName("ul")[0].className = "hide";
  }

function menu_show(div)  /* show the menu */
  {
  div.getElementsByTagName("ul")[0].className = "show";
  }

function search_check(form)  /* check the search criteria */
  {
  var inputs = form.getElementsByTagName("input");
  for (var input = 0; input < inputs.length; input++)
    {
    if (inputs[input].type == "text")  /* check the text box */
      {
      var string = inputs[input].value;
      string = string.replace(/[^\w\-\"' ]/g, " ");
      while (string.indexOf("  ") >= 0)
        string = string.replace(/\s+/g, " ");
      string = string.replace(/^\s+/, "").replace(/\s+$/, "");
      inputs[input].value = string;
      if (string.length > 0)
        return true;
      }
    else if (inputs[input].type == "checkbox")  /* check the check boxes */
      {
      if (inputs[input].checked)
        return true;
      }
    }
  var selects = form.getElementsByTagName("select");  /* check the select menus */
  for (var select = 0; select < selects.length; select++)
    {
    var options = selects[select].options;
    for (var option = 1; option < options.length; option++)
      {
      if (options[option].selected)
        return true;
      }
    }
  if (document.URL.indexOf("search.aspx") >= 0)
    alert("You haven't specified any search criteria.");
  else
    window.location = "search.aspx";
  return false;
  }

function search_revise()
  {
  if (document.URL.search("&") >= 0)
    window.history.back();
  else
    window.location = "search.aspx";
  }

