function state(id, dsply) {
  obj = document.getElementById(id);
  if (dsply=='hide') obj.style.visibility = 'hidden';
  if (dsply=='show') obj.style.visibility = 'visible';
  return;
}

function isIn(x, seq) {
// check to see if x is in seq
  l = seq.length; found = 0; i = 0;
  while ((found==0) && (i < l)) {
    if (seq[i] == x) found = 1;
    i++;
  }
  return found;
}

function printLine(str) {
// writes str to the position in the HTML file where 'printLine()' is called
// use this to write Active X content (object, embed, applet tags) as a workaround for the clicking required to activate an Active X control
  document.write(str);
}

function pageId(page_url) {
// return the id (folder) of the page in the url (without arguments or hashes or "index.html" etc.)
  var p_url = page_url;

  // test for trailing slash on url, remove it if it is present
  if (page_url.charAt(page_url.length-1)=="/") {
    p_url = page_url.substr(0, page_url.length-1);}

  var temp = p_url.split("/");
  var temp2;
  if (temp.length > 1) temp2 = temp[temp.length - 2];
  else temp2 = temp;
  temp = temp[temp.length - 1].split("#");
  temp = temp[temp.length - 1].split("?");
  temp = temp[temp.length - 1];

  // do not return "index.html" etc, return previous page id instead
  var test_for = new Array("index.html", "index_html", "index.php", "index.asp");
  if (isIn(temp, test_for)) return temp2;
  else return temp;
}

function getQuery(key_str) {
// return value of key_str variables query string of url
// Example: url = "index.html?alert=5&page=index"; if key_str = "alert" then it returns "5"
  if(window.location.search) {
    var query = window.location.search.substr(1);
    var pairs = query.split("&");
    for(var i = 0; i < pairs.length; i++) {
      var pair = pairs[i].split("=");
      if(unescape(pair[0]) == key_str) return unescape(pair[1]);
    }
  return null;
  }
}
