<!------- find browser type & mouseover functions

// mouseover functions
browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion); 
if (browser_name == "Netscape" && browser_version >= 3.0) { okMouse = true; }
else if (browser_name == "Microsoft Internet Explorer" && 
  browser_version >= 3.0) { okMouse = true; }
else if (browser_version >= 4.0) { okMouse = true; }
else { okMouse = false; }

W3C = (document.getElementById) ? 1 : 0; 
IE4 = (document.all) ? 1 : 0; 
NS4 = (document.layers) ? 1 : 0; 

function preload_img(image_array,flag) { // preload images
  // image file names stored in image_array (defined above)
  // called below (or can use with BODY onLoad
  if (okMenu || okMouse) {
    for (var loop in image_array) {
      var t = eval('preload_' + flag);
      t[loop] = new Image();
      t[loop].src = image_array[loop];
    }
  }
}

function msover(img,ref) { // mouse rollover function
  // img - name of the IMG statement
  // ref - new_imgs array name 
  if (!ref) { ref = img; } 
  if (okMenu || okMouse) {
    document.images[img].src = preload_on[ref].src;
    lastimg = img;  
    lastref = base_imgs[lastimg]; 
  }
}

function msout(img,ref) { // mouse rollout function
  // img - name of the IMG statement
  // ref - new_imgs array name 
  if (!ref) { ref = img; }
  if (okMenu || okMouse) { document.images[img].src = preload_off[ref].src;}
}

function on_msover(string,img,ref) {
  if (okMouse) {
    if (!ref) { ref = img; }
    if (img) { msover(img,ref); }
    if (leader) { window.status = leader + string; }
    else { window.status = string; }
  }
}

function on_msout(img,string) {
  if (okMouse) {
    if (img) { msout(img); }
    if (string) { window.status = string; }
    else { window.status = 'Maryland Sea Grant'; }
  }
}

function not_yet(page) { // temporary for pages that do not exist
  alert('We need to create a ' + page);
}

// dhtml layer functions

function reloadIt() { document.location = document.location;}

function dhtml_check() { // browser specific items
  if (W3C) { // netscape 6 (gecko) or greater - DOM specific object variables
    layerRef = "document.getElementById('";
    layerStyle = "').style";
    layerText = "').innerHTML";
    visible = '.visibility = "visible"';
    hidden = '.visibility = "hidden"';
    zlevel = '.zindex';
    pxunits = 'px';
    okMenu = true;
  }
  else if (NS4) { // netscape 4 - DOM specific object variables
    window.onResize = reloadIt;// patch for netscape window resizing problem
    layerRef = "document.layers['";
    layerStyle = "']";
    visible = '.visibility = "show"';
    hidden = '.visibility = "hide"';
    zlevel = '.zIndex';
    pxunits = 'px';
    okMenu = true;
  }
  else if (IE4) { // msie 4 or greater - DOM specific object variables
    layerRef = "document.all['";
    layerStyle = "'].style";
    layerText = "'].innerHTML";
    visible = '.visibility = "visible"';
    hidden = '.visibility = "hidden"';
    zlevel = '.zindex';
    pxunits = 'px';
    okMenu = true;
  }
  else { okMenu = false; }
}

function dhtml_check1() {
  // set browser specific items for javascript using layers
  if (document.getElementById) { 
    // netscape 6 (gecko) or greater - DOM specific object variables
    layerRef = "document.getElementById('";
    layerStyle = "').style";
    visible = '.visibility = "visible"';
    hidden = '.visibility = "hidden"';
    zlevel = '.zindex';
    pxunits = 'px';
    okMenu = true;
  }
  else if (document.layers) { 
    // netscape 4 - DOM specific object variables
    window.onResize = reloadIt;// patch for netscape window resizing problem
    layerRef = "document.layers['";
    layerStyle = "']";
    visible = '.visibility = "show"';
    hidden = '.visibility = "hide"';
    zlevel = '.zIndex';
    pxunits = 'px';
    okMenu = true;
  }
  else if (document.all) { // msie 4 or greater - DOM specific object variables
    layerRef = "document.all['";
    layerStyle = "'].style";
    visible = '.visibility = "visible"';
    hidden = '.visibility = "hidden"';
    zlevel = '.zindex';
    pxunits = 'px';
    okMenu = true;
  }
  else { okMenu = false; }
}

n_layer = 5;  // default number of layers

dhtml_check();

function ShowText(txt_tag,txt_var) {
  ChangeText(txt_tag,eval(txt_var));
}
function ChangeText(txt_tag,txt) {
  if (W3C) { eval(layerRef + txt_tag + "')").innerHTML  = txt; }
  else if (IE4) { eval(layerRef + txt_tag + "')").innerText  = txt; }
  else if (NS4) { 
    var txt_tag2 = txt_tag + '_a';  
    document.eval(txt_tag).document.eval(txt_tag2).document.open();
    document.eval(txt_tag).document.eval(txt_tag2).document.write(txt); 
    document.eval(txt_tag).document.eval(txt_tag2).document.close();
  }
  else { alert("Don't recognize this browser"); }
}

function set_layer_location(n_layer,pxleft,pxtop,pxleft_all,pxtop_all,pxleft_layers,pxtop_layers) { 
  if (!okMenu) { return; } 
  // set for document.getElementById (Safari) and adjust for others
  if (!pxleft) { pxleft = 25; }
  if (!pxtop) { pxtop = 105; }
  if (!n_layer) { n_layer = 1; } 
  if (document.getElementById) { 
    if (navigator.userAgent.lastIndexOf('Safari') < 0) { 
      // later versions of MSIE (5.2+) is like Safari
      if (navigator.userAgent.lastIndexOf('MSIE') == -1) { 
        // if Netscape 7 is not exactly like Safari
        pxleft += 0;
      }
    }
  }
  else if (document.all) {
    if (navigator.userAgent.lastIndexOf('Opera') != -1) { 
      // Opera not exactly like MSIE 
      pxleft_all -= 2; pxtop_all += 1;
    }
    if (pxleft_all) { pxleft += pxleft_all; }
    if (pxtop_all) { pxtop += pxtop_all; }
  }
  else if (document.layers) { 
    if (pxleft_layers) { pxleft += pxleft_layers; }
    if (pxtop_layers) { pxtop += pxtop_layers; }
  }
  var this_layer = "m" + n_layer;
  var thisObj = layerRef + this_layer + layerStyle; 
  eval(thisObj).left = pxleft + pxunits;
  eval(thisObj).top  = pxtop + pxunits;
}

function show_layer(layerid,num_layer,layer_prefix) {
  if (!layer_prefix) { layer_prefix = "m"; }
  if (num_layer) { n_layer = num_layer; }
  for (i=1; i<=n_layer; i++) {
    var this_layer = layer_prefix + i;
    if (i==layerid) {
      eval(layerRef + this_layer + layerStyle + visible);
    }
    else {
      eval(layerRef + this_layer + layerStyle + hidden);
    }
  } 
}

function hide_layer(layerid,num_layer,layer_prefix) {
  if (!layer_prefix) { layer_prefix = "m"; }
  if (num_layer) { n_layer = num_layer; }
  for (i=1; i<=n_layer; i++) {
    var this_layer = layer_prefix + i;
    if (layerid == 'all') { 
      eval(layerRef + this_layer + layerStyle + hidden);
    }
    else if (i==layerid) { 
      eval(layerRef + this_layer + layerStyle + visible);
    }
    else { 
      eval(layerRef + this_layer + layerStyle + hidden);
    }
  }
}

// other funcions

//function goto_url(form,what) {
//  var myindex=form[what].selectedIndex; // where to go from select
//  var str = "toolbar=yes,scrollbars=yes,location=yes";
//  window.open(form[what].options[myindex].value,"_parent",str);
//}

function promo(date,msg,height,width) {
  // date - last day (month day, year) to display promo
  // msg - html file with promo
  // height = height of pop-window
  // width = width of pop-window
  var winopt, today, end_date;
  if (!msg) { return; }
  if (!date) { remaining = 1; }
  else { 
    today = new Date();
    end_date = new Date(date); // month day, year
    milliseconds = (24 * 60 * 60 * 1000);
    remaining = ((end_date.getTime() - today.getTime()) / milliseconds); 
  }

  if (remaining >= 0) {  // pop-up window
    if (!height) { height = 400; }
    if (!width) { width = 400; }  
    // note: toolbar = yes to allow printing of pop-up window
    winopt = "toolbar=no,location=no,directories=no,";
    winopt += "menubar=no,resizable=no,";
    winopt += "scrollbars=yes,width=" + width + ",height=" + height;
    newWin=window.open(msg,"msg",winopt);
    return;
  }
  else { return; }
}

function status_line(string) { // status line message with mouseover
  if (okMouse) {
     if (leader) { window.status = leader + string; }
     else { window.status = string; }
  }
}

function noCR(thisEvent) {
  var key = window.event ? thisEvent.keyCode : thisEvent.which;
  var keychar = String.fromCharCode(key);
  var reg = /\r/; // key = 13 
  // reg.test is true if \r and false otherwise 
  // return the opposite of the reg.test value (true --> false, false --> true)
  return !reg.test(keychar);
}

function nav_on(what,where) {
  if (!where) { where = "top"; }
  what.className = where + "_nav_on";
}
function nav_off(what,where) {
  if (!where) { where = "top"; }
  what.className = where + "_nav";
}

preload_off = new Array ();
preload_on = new Array ();
preload_img(base_imgs,'off'); 
preload_img(new_imgs,'on'); 


//close off comment to hide this script from old browsers----------->

