var id_highlighted=null;
var search_txt="";
var hit_no=0;
var win_search=top.frmDisplay;
var designCommonDir="/bookit/design/common";

function mouseOn(imageName) {
  if (document.images)
    document[imageName].src = eval(imageName + "active.src");
}

function mouseOff(imageName) {
  if (document.images)
    document[imageName].src = eval(imageName + "inactive.src");
}

function onClickAnchor(id) {
  var id_menu="id_menu_"+id;
  var id_arrow="id_arrow_"+id;
  //alert("id: "+id+" id_highlighted: "+id_highlighted);
  if (id_highlighted!=null) {
    var id_menu_highlighted="id_menu_"+id_highlighted;
    var id_arrow_highlighted="id_arrow_"+id_highlighted;
    var a_highlighted=document.getElementById(id_menu_highlighted);
    a_highlighted.className="MenuText";
    var img_highlighted=document.getElementById(id_arrow_highlighted);    
    img_highlighted.src=designCommonDir+"/images/transparent_1by1.gif";
  }
  id_highlighted=id;
  var img=document.getElementById(id_arrow);    
  img.src=designDir+"/images/arrow_black.gif";
  var a=document.getElementById(id_menu);
  a.className="MenuHighlight";
  a.focus();
}

function find_page(lbl_search_txt,txt_not_found) {
  var txt, i, found;
  if (!isEmpty(lbl_search_txt)) {
    search_txt=window.prompt(lbl_search_txt,search_txt);
    if (search_txt==null)
      search_txt="";
  }
  if (isEmpty(search_txt))
    return;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.
  if (browser_name=="Netscape") {
    // Look for match starting at the current point. If not found, rewind
    // back to the first match.
    if (!win_search.find(search_txt))
      while(win_search.find(search_txt, false, true))
        hit_no++;
    else
      hit_no++;
    // If not found in either direction, give message.
    if (hit_no == 0)
      alert(txt_not_found);
  }
  if (browser_name=="Microsoft Internet Explorer") {
    txt = win_search.document.body.createTextRange();
    // Find the nth match from the top of the page.
    for (i = 0; i <= hit_no && (found = txt.findText(search_txt)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }
    // If found, mark it and scroll it into view.
    if (found) {
      txt.moveStart("character", -1);
      txt.findText(search_txt);
      txt.select();
      txt.scrollIntoView();
      hit_no++;
    }
    // Otherwise, start over at the top of the page and find first match.
    else {
      if (hit_no > 0) {
        hit_no = 0;
        find_page(null,txt_not_found);
      }
      // Not found anywhere, give message.
      else
        alert(txt_not_found);
    }
  }
  return;
}
