//
// noir.js
//
// BDO, July 2008
//

var d               = document;
var bdoAlertTitle   = "The Noir Zone";
var bdoAlertBtnText = "OK";

String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }

if (d.getElementById) { window.alert = function(txt) { bdoCustomAlert(txt); } }

if (d.images)
{
  var srch_on  = new Image();  srch_on.src  = "/images/search.gif";
  var srch_off = new Image();  srch_off.src = "/images/search_down.gif";
  var reg_on   = new Image();  reg_on.src   = "/images/register.gif";
  var reg_off  = new Image();  reg_off.src  = "/images/register_down.gif";
  var log_on   = new Image();  log_on.src   = "/images/login.gif";
  var log_off  = new Image();  log_off.src  = "/images/login_down.gif";
}

function bdoShow(n, nam)
{
  var x = document.getElementById(nam);
  if (n == 1)
  {
    if      (nam == "srchbtn") x.src = srch_on.src;
    else if (nam == "regbtn")  x.src = reg_on.src;
    else if (nam == "logbtn")  x.src = log_on.src;
  }
  else
  {
         if (nam == "srchbtn") x.src = srch_off.src;
    else if (nam == "regbtn")  x.src = reg_off.src;
    else if (nam == "logbtn")  x.src = log_off.src;
  }
}

function show_imain_item(itemnum)
{
  var d  = parent.document.getElementById('imain');              d.style.zIndex = 9;
  var s  = "/php/admin_view_item.php?inum=" + itemnum + "&the_area=imain&q=0";
  var i1 = parent.document.getElementById('introLeft');
  var i2 = parent.document.getElementById('introLeftFrame');
  var i3 = parent.document.getElementById('introRight');
  var i4 = parent.document.getElementById('introRightFrame');
  if ((typeof i1 != 'undefined') && (typeof i1 != 'null') && (i1 !== undefined) && (i1 !== null)) { i1.style.visibility="hidden"; }
  if ((typeof i2 != 'undefined') && (typeof i2 != 'null') && (i2 !== undefined) && (i2 !== null)) { i2.style.visibility="hidden"; }
  if ((typeof i3 != 'undefined') && (typeof i3 != 'null') && (i3 !== undefined) && (i3 !== null)) { i3.style.visibility="hidden"; }
  if ((typeof i4 != 'undefined') && (typeof i4 != 'null') && (i4 !== undefined) && (i4 !== null)) { i4.style.visibility="hidden"; }
  setCookie("noirzone_isIntro", 0, 1);
  d.src = s;
}

function show_imain_intro_item(itemnum, origin)
{
  var d = parent.document.getElementById('imain');              d.style.zIndex = 9;
  if (origin == 1)
  {
   var i1 = parent.document.getElementById('introLeft');        i1.style.visibility="hidden";
   var i2 = parent.document.getElementById('introLeftFrame');   i2.style.visibility="hidden";
   var i3 = parent.document.getElementById('introRight');       i3.style.visibility="hidden";
   var i4 = parent.document.getElementById('introRightFrame');  i4.style.visibility="hidden";
  }
  var s = "/php/admin_view_item.php?inum=" + itemnum + "&the_area=imain&x="  + origin + "&q=0";
  setCookie("noirzone_isIntro", 0, 1);
  d.src = s;
}

function show_big_intro_pic(num)
{
  var d = parent.document.getElementById('introRightFrame');
  var s = "/php/intro_pic_display.php?n=" + num;
  d.src = s;
}

function show_bdoitems(itemnum, quality)
{
  var d = parent.document.getElementById('imain');
  var s = "/php/admin_view_item.php?inum=" + itemnum + "&the_area=imain&q=" + quality;
  d.src = s;
}

function show_imain_bio(itemnum, letter, aname)
{
  var d = parent.document.getElementById('imain');
  var s = "/php/admin_view_bio.php?inum=" + itemnum + "&the_letter=" + letter + "&nm=" + aname;
  var i1 = parent.document.getElementById('introLeft');
  var i2 = parent.document.getElementById('introLeftFrame');
  var i3 = parent.document.getElementById('introRight');
  var i4 = parent.document.getElementById('introRightFrame');
  if ((typeof i1 != 'undefined') && (typeof i1 != 'null') && (i1 !== undefined) && (i1 !== null)) { i1.style.visibility="hidden"; }
  if ((typeof i2 != 'undefined') && (typeof i2 != 'null') && (i2 !== undefined) && (i2 !== null)) { i2.style.visibility="hidden"; }
  if ((typeof i3 != 'undefined') && (typeof i3 != 'null') && (i3 !== undefined) && (i3 !== null)) { i3.style.visibility="hidden"; }
  if ((typeof i4 != 'undefined') && (typeof i4 != 'null') && (i4 !== undefined) && (i4 !== null)) { i4.style.visibility="hidden"; }
  d.src = s;
}

function show_imain_intro_bio(itemnum, letter, aname)
{
  var d = parent.document.getElementById('imain');
  var s = "/php/admin_view_bio.php?inum=" + itemnum + "&the_letter=" + letter + "&nm=" + aname;
  d.src = s;
}

function show_fullsize_image(pic)
{
  var d = parent.document.getElementById('imain');
  var s = "/php/display_fullsize_pic.php?the_pic=" + pic;
  d.src = s;
}

function bdoShowLinks()
{
  var w = document.getElementById('imenu');
  var s = "/php/display_links.php";
  w.src = s;
}

function bdoShowCoversLogin()
{
  var w = document.getElementById('imain');
  if (w.style.zIndex != 9)
  {
    w.style.zIndex = 9;
    var i1 = document.getElementById('introLeft');          i1.style.visibility="hidden";
    var i2 = document.getElementById('introLeftFrame');     i2.style.visibility="hidden";
    var i3 = document.getElementById('introRight');         i3.style.visibility="hidden";
    var i4 = document.getElementById('introRightFrame');    i4.style.visibility="hidden";
  }
  var s = "/php/covers_login.php";
  w.src = s;
}

function bdoCoversLoginFocus()
{
  var x;
  x = document.getElementById('covers_username');
  if ((typeof(x) != 'undefined') && (typeof(x) != 'null') && (x !== undefined) && (x !== null))
  {
    x.focus();
  }
}

////////////////////////////////////////////////////////////////////////////////
// Set Heights                                                                //
////////////////////////////////////////////////////////////////////////////////

function bdoSetIntroIFrameHeight()
{
  var area_menu   = document.getElementById('menu');
  var area_imenu  = document.getElementById('imenu');
  var area_main   = document.getElementById('main');
  var area_imain  = document.getElementById('imain');
  var area_left   = document.getElementById('introLeft');
  var area_ileft  = document.getElementById('introLeftFrame');
  var area_right  = document.getElementById('introRight');
  var area_iright = document.getElementById('introRightFrame');
  var area_noir   = document.getElementById('noirMainId');

  var  x = document.body.offsetHeight - 43;
  var xx = document.body.offsetHeight - 63;
  if (gIsIE6) { x = x - 20;  xx = xx - 20; }

  var isIntro = getCookie("noirzone_isIntro");
  if ((typeof area_noir   != 'undefined') && (typeof area_noir   != 'null') && (area_noir   !== undefined) && (area_noir   !== null)) { area_noir.height   = x  + "px"; }
  if ((typeof area_menu   != 'undefined') && (typeof area_menu   != 'null') && (area_menu   !== undefined) && (area_menu   !== null)) { area_menu.height   = xx + "px"; }
  if ((typeof area_imenu  != 'undefined') && (typeof area_imenu  != 'null') && (area_imenu  !== undefined) && (area_imenu  !== null)) { area_imenu.height  = xx + "px"; }

  if ((typeof area_main   != 'undefined') && (typeof area_main   != 'null') && (area_main   !== undefined) && (area_main   !== null)) { area_main.height   = xx + "px"; }
  if ((typeof area_imain  != 'undefined') && (typeof area_imain  != 'null') && (area_imain  !== undefined) && (area_imain  !== null)) { area_imain.height  = xx + "px"; }

  if ((typeof area_left   != 'undefined') && (typeof area_left   != 'null') && (area_left   !== undefined) && (area_left   !== null))
  { area_left.height   = xx + "px";  if (isIntro == "1") { area_left.style.visibility   = "visible"; } else { area_left.style.visibility   = "hidden"; } }
  if ((typeof area_ileft  != 'undefined') && (typeof area_ileft  != 'null') && (area_ileft  !== undefined) && (area_ileft  !== null))
  { area_ileft.height  = xx + "px";  if (isIntro == "1") { area_ileft.style.visibility  = "visible"; } else { area_ileft.style.visibility  = "hidden"; } }
  if ((typeof area_right  != 'undefined') && (typeof area_right  != 'null') && (area_right  !== undefined) && (area_right  !== null))
  { area_right.height  = xx + "px";  if (isIntro == "1") { area_right.style.visibility  = "visible"; } else { area_right.style.visibility  = "hidden"; } }
  if ((typeof area_iright != 'undefined') && (typeof area_iright != 'null') && (area_iright !== undefined) && (area_iright !== null))
  { area_iright.height = xx + "px";  if (isIntro == "1") { area_iright.style.visibility = "visible"; } else { area_iright.style.visibility = "hidden"; } }

  var x = document.getElementById('st');
  if ((typeof x != 'undefined') && (typeof x != 'null') && (x !== undefined) && (x !== null))
  {
    x.focus();
    x.value = x.value;
  }
}

function bdoSetIFrameHeight()
{
  var area_menu   = parent.document.getElementById('menu');
  var area_imenu  = parent.document.getElementById('imenu');
  var area_main   = parent.document.getElementById('main');
  var area_imain  = parent.document.getElementById('imain');
  var area_left   = parent.document.getElementById('introLeft');
  var area_ileft  = parent.document.getElementById('introLeftFrame');
  var area_right  = parent.document.getElementById('introRight');
  var area_iright = parent.document.getElementById('introRightFrame');
  var area_noir   = parent.document.getElementById('noirMainId');

  var  x = parent.document.body.offsetHeight - 43;
  var xx = parent.document.body.offsetHeight - 63;
  if (gIsIE6) { x = x - 20;  xx = xx - 20; }

  var isIntro = getCookie("noirzone_isIntro");
  if ((typeof area_noir   != 'undefined') && (typeof area_noir   != 'null') && (area_noir   !== undefined) && (area_noir   !== null)) { area_noir.height   = x  + "px"; }
  if ((typeof area_menu   != 'undefined') && (typeof area_menu   != 'null') && (area_menu   !== undefined) && (area_menu   !== null)) { area_menu.height   = xx + "px"; }
  if ((typeof area_imenu  != 'undefined') && (typeof area_imenu  != 'null') && (area_imenu  !== undefined) && (area_imenu  !== null)) { area_imenu.height  = xx + "px"; }
  if ((typeof area_main   != 'undefined') && (typeof area_main   != 'null') && (area_main   !== undefined) && (area_main   !== null)) { area_main.height   = xx + "px"; }
  if ((typeof area_imain  != 'undefined') && (typeof area_imain  != 'null') && (area_imain  !== undefined) && (area_imain  !== null)) { area_imain.height  = xx + "px"; }

  if ((typeof area_left   != 'undefined') && (typeof area_left   != 'null') && (area_left   !== undefined) && (area_left   !== null))
  { area_left.height   = xx + "px";  if (isIntro == "1") { area_left.style.visibility   = "visible"; } else { area_left.style.visibility   = "hidden"; } }
  if ((typeof area_ileft  != 'undefined') && (typeof area_ileft  != 'null') && (area_ileft  !== undefined) && (area_ileft  !== null))
  { area_ileft.height  = xx + "px";  if (isIntro == "1") { area_ileft.style.visibility  = "visible"; } else { area_ileft.style.visibility  = "hidden"; } }
  if ((typeof area_right  != 'undefined') && (typeof area_right  != 'null') && (area_right  !== undefined) && (area_right  !== null))
  { area_right.height  = xx + "px";  if (isIntro == "1") { area_right.style.visibility  = "visible"; } else { area_right.style.visibility  = "hidden"; } }
  if ((typeof area_iright != 'undefined') && (typeof area_iright != 'null') && (area_iright !== undefined) && (area_iright !== null))
  { area_iright.height = xx + "px";  if (isIntro == "1") { area_iright.style.visibility = "visible"; } else { area_iright.style.visibility = "hidden"; } }

  var x = parent.document.getElementById('st');
  if ((typeof x != 'undefined') && (typeof x != 'null') && (x !== undefined) && (x !== null))
  {
    x.focus();
    x.value = x.value;
  }
}

function bdoSetCoverH()
{
  var cover_main      = document.getElementById('covermain');
  var cover_frame_top = document.getElementById('coverframetop');
  if (gIsIE6)
  {
    cover_frame_top.height = (document.body.clientHeight - 135) + "px";
  }
  else
  {
    var x = document.body.offsetHeight - 114;
    cover_frame_top.height = x  + "px";
  }
}

function bdoReg()
{
  var    x = new Object();
  return x = d.getElementById("regForm");
}

function bdoCanSearch(searchForm)
{
  var a, i, n, v, x, z;
  if (searchForm.searchfor.value != "year")
  {
    x = d.getElementById('st');
    if ((typeof x != 'undefined') && (typeof x != 'null') && (x !== undefined) && (x !== null))
    {
      v = x.value.trim();
      n = v.length;
      v = v.replace(/[\?\.\_\*\%]/g, "");
      if (v.length > 1)
      {
        a = v.split(/\s/g);
        z = 0;
        for (i = 0; i < a.length; i++)
        {
          if (a[i].length > 1) z = 1;
        }
        if (z > 0) return true;
        else
        {
          alert('Please ensure that at least one search     term contains more than one character.');
          x.value = "";
          x.focus();
          return false;
        }
      }
      else
      {
        if (v.length == 1)
        {
          if (v.length < n)
          {   alert('Single character searches with wildcards are not supported.');  x.value = "";   x.focus(); return false;}
          else
          {
            if      (searchForm.searchfor.value == "all")
            { alert('Single character searches in category              "All" are not supported.');  x.focus(); return false;}
            else if (searchForm.searchfor.value == "actor")
            { alert('Single character searches in category           "Actors" are not supported.');  x.focus(); return false;}
          }
        }
        else
        {
          x.focus();
          return false;
        }
      }
    }
    else
    {
      alert("Internal Error: NZ0121-001-A\nThe Noir Zone has encountered a serious internal error.\nPlease report this to bdo@noirzone.com");
      return false;
    }
  }
}

////////////////////////////////////////////////////////////////////////////////
// Menu Open and Close                                                        //
////////////////////////////////////////////////////////////////////////////////

var gSubActorsIdxA    = new Array();
var gSubDirectorsIdxA = new Array();
var gSubWritersIdxA   = new Array();

function bdoOC(td, c, n)
{
  var i, j, k, x, y;
  var isOK = false;

  //---------------------------------------------------------------//
  // CLOSE MENU                                                    //
  //---------------------------------------------------------------//
  if ((td.tagName == "TD") && (td.getAttribute("State") != "On"))
  {
    x = 'td' + c + 1;
    y = document.getElementById(x);
    if ((typeof(y) != 'undefined') && (typeof(y) != null) && (y !== undefined) && (y !== null))
    {
      // Check for submenu items
      if ((c == "A") || (c == "H") || (c == "W"))
      {
        var subx, suby, found;
        var snA    = new Array();
        var snIdxA = new Array();
        for (i = 1; i <= n; i++)
        {
          subx  = "td" + c + i + "_1";
          suby  = document.getElementById(subx);
          if ((typeof(suby) != 'undefined') && (typeof(suby) != null) && (suby !== undefined) && (suby !== null))
          {
            snA[i]    = new Array();
            snA[i][1] = suby;
            snIdxA[i] = 1;
            isOK      = true;
            found     = true;
            j         = 1;
            while (found)
            {
              j++;
              subx = "td" + c + i + "_" + j;
              suby = document.getElementById(subx);
              if ((typeof(suby) != 'undefined') && (typeof(suby) != null) && (suby !== undefined) && (suby !== null))
              {
                snIdxA[i] = j;
                snA[i][j] = suby;
              }
              else
              {
                found = false;
              }
            }
          }
        }

        if (isOK)
        {
          for (i = 1; i <= n; i++)
          {
            // Save number of submenu items
                 if (c == "A") { gSubActorsIdxA[i]    = snIdxA[i];  }
            else if (c == "H") { gSubDirectorsIdxA[i] = snIdxA[i];  }
            else if (c == "W") { gSubWritersIdxA[i]   = snIdxA[i];  }

            // Hide submenu items
            for (j = snIdxA[i]; j > 0; j--)
            {
              snA[i][j].parentNode.style.display = "none";
            }
          }
        }
      }

      // Save mainmenu items
      x = 'td' + c;
      var nA = new Array();
      for (i = 1; i <= n; i++)
      {
        nA[i] = document.getElementById(x + i);
      }

      // Hide mainmenu items
      for (i = n; i > 0; i--)
      {
        nA[i].parentNode.style.display = "none";
      }
      td.setAttribute("State", "On");
      //  window.event.returnValue = false;
    }
  }
  //---------------------------------------------------------------//
  // OPEN MENU                                                     //
  //---------------------------------------------------------------//
  else if ((td.tagName == "TD") && (td.getAttribute("State") == "On"))
  {
    for (i = 1; i <= n; i++)
    {
      // Re-display mainmenu item
      x = 'tr' + c;
      y = document.getElementById(x + i);
      y.style.display = "";

      // Re-display submenu item(s)
      x = 'tr' + c + i + "_";
           if (c == "A") { k = gSubActorsIdxA[i];    }
      else if (c == "H") { k = gSubDirectorsIdxA[i]; }
      else if (c == "W") { k = gSubWritersIdxA[i];   }
      for (j = 1; j <= k; j++)
      {
        y = document.getElementById(x + j);
        y.style.display = "";
      }
    }
    td.setAttribute("State", "Off");
    //  window.event.returnValue = false;
  }
  document.body.style.cursor = 'default';
}

////////////////////////////////////////////////////////////////////////////////
// Custom Alert                                                               //
////////////////////////////////////////////////////////////////////////////////

function bdoRemoveCustomAlert()
{
  d.getElementsByTagName("body")[0].removeChild(d.getElementById("bdoAlertDiv"));

  var x = d.getElementById('st');
  if ((typeof x != 'undefined') && (typeof x != 'null') && (x !== undefined) && (x !== null))
  {
    x.value = "";
    x.focus();
    return true;
  }
  else
  {
    x = parent.d.getElementById('st');
    if ((typeof x != 'undefined') && (typeof x != 'null') && (x !== undefined) && (x !== null))
    {
      x.value = "";
      x.focus();
      return true;
    }
  }
}

function bdoCustomAlert(s)
{
  if (d.getElementById("bdoAlertDiv")) return;

  var x         = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
  x.id          = "bdoAlertDiv";
  x.styleheight = d.documentElement.scrollHeight + "px";

  var a = x.appendChild(d.createElement("div"));
  a.id  = "bdoAlertBox";
  if (d.all && !window.opera)
  {
    a.style.top = d.documentElement.scrollTop + "px";
  }
  a.style.left      = (d.documentElement.scrollWidth - a.offsetWidth) / 2 + "px";
  a.style.visiblity = "visible";
  a.style.display   = "block";

  var h = a.appendChild(d.createElement("h1"));
  h.appendChild(d.createTextNode(bdoAlertTitle));

  var m = a.appendChild(d.createElement("p"));
  m.appendChild(d.createTextNode(s));

  var b = a.appendChild(d.createElement("a"));
  b.id  = "bdoBtnOK";
  b.appendChild(d.createTextNode(bdoAlertBtnText));
  b.href = "#";
  b.focus();
  b.onclick = function() { bdoRemoveCustomAlert();  return false; }
}

////////////////////////////////////////////////////////////////////////////////
// Cookies                                                                    //
////////////////////////////////////////////////////////////////////////////////

function setCookie(c_name, value, expiredays)
{
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + expiredays);
  document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString()) + "; path=/";
}

function getCookie(c_name)
{
  if (document.cookie.length > 0)
  {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1)
    {
      c_start = c_start + c_name.length + 1;
      c_end   = document.cookie.indexOf(";", c_start);
      if (c_end == -1)
      { c_end = document.cookie.length; }
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  else
  { return ""; }
}

////////////////////////////////////////////////////////////////////////////////
// Browser detect                                                             //
////////////////////////////////////////////////////////////////////////////////

var BrowserDetect = {
  init: function () {
      this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
      this.version = this.searchVersion(navigator.userAgent)
            || this.searchVersion(navigator.appVersion)
            || "an unknown version";
      this.OS = this.searchString(this.dataOS) || "an unknown OS";
  },
    searchString: function (data) {
      for (var i = 0; i < data.length; i++)     {
        var dataString           = data[i].string;
        var dataProp             = data[i].prop;
        this.versionSearchString = data[i].versionSearch || data[i].identity;
        if (dataString) {
          if (dataString.indexOf(data[i].subString) != -1)
            return data[i].identity;
        }
        else if (dataProp)
          return data[i].identity;
      }
  },
    searchVersion: function (dataString) {
      var index = dataString.indexOf(this.versionSearchString);
      if (index == -1) return;
      return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
  },
    dataBrowser: [
      { string: navigator.userAgent,
        subString: "OmniWeb",
        versionSearch: "OmniWeb/",
        identity: "OmniWeb"
      },
      {
        string: navigator.vendor,
        subString: "Apple",
        identity: "Safari"
      },
      {
        prop: window.opera,
        identity: "Opera"
      },
      {
        string: navigator.vendor,
        subString: "iCab",
        identity: "iCab"
      },
      {
        string: navigator.vendor,
        subString: "KDE",
        identity: "Konqueror"
      },
      {
        string: navigator.userAgent,
        subString: "Firefox",
        identity: "Firefox"
      },
      {
        string: navigator.vendor,
        subString: "Camino",
        identity: "Camino"
      },
      { // for newer Netscapes (6+)
        string: navigator.userAgent,
        subString: "Netscape",
        identity: "Netscape"
      },
      {
        string: navigator.userAgent,
        subString: "MSIE",
        identity: "Explorer",
        versionSearch: "MSIE"
      },
      {
        string: navigator.userAgent,
        subString: "Gecko",
        identity: "Mozilla",
        versionSearch: "rv"
      },
      { // for older Netscapes (4-)
        string: navigator.userAgent,
        subString: "Mozilla",
        identity: "Netscape",
        versionSearch: "Mozilla"
      }
  ],
    dataOS : [
      {
        string: navigator.platform,
        subString: "Win",
        identity: "Windows"
      },
      {
        string: navigator.platform,
        subString: "Mac",
        identity: "Mac"
      },
      {
        string: navigator.platform,
        subString: "Linux",
        identity: "Linux"
      }
  ]

};

BrowserDetect.init();

var gIsIE6 = false;
var gIsIE7 = false;
var gIsIE8 = false;
var gIsFF  = false;
var gIsMAC = false;

     if (BrowserDetect.browser == "Explorer") {
     if (BrowserDetect.version == 6)          { gIsIE6 = true; }
else if (BrowserDetect.version == 7)          { gIsIE7 = true; }
else if (BrowserDetect.version == 8)          { gIsIE8 = true; }}
else if (BrowserDetect.browser == "Firefox")  { gIsFF  = true; }
else if (BrowserDetect.browser == "Safari")   { gIsMAC = true; }


////////////////////////////////////////////////////////////////////////////////
// Deprecated                                                                 //
////////////////////////////////////////////////////////////////////////////////

function bdoGetPos(x)
{
  var xLeft = xTop = 0;
  if (x.offsetParent)
  {
    xLeft = x.offsetLeft;
    xTop  = x.offsetTop;
    while (x = x.offsetParent)
    {
      xLeft += x.offsetLeft;
      xTop  += x.offsetTop;
    }
  }
  return [xLeft, xTop];
}

function show_search_criteria(fltr, str, dec, yr)
{
  var x;
  x = parent.document.getElementById('sf');
  x.value = fltr;

  if (str != "year")
  {
    x = parent.document.getElementById('st');
    x.value = str;
  }
  else
  {
    x = parent.document.getElementById('sd');
    x.value = dec;
    x = parent.document.getElementById('sy');
    x.value = yr;
  }
}

function show_search_heading(num, str)
{
  var w = "matches";
  var d = parent.document.getElementById('menuheading_id');
  if (num == 1) { w = "match"; }
  var s = "<span style='float:left;'>Found " + num + " " + w + " for '" + str + "'.</span>";
  d.innerHTML = s;
}
