/*
  Functions visible amongst all pages of the HandsOn site.
*/

GL_DOM = (document.getElementById) ? true : false;
GL_NS4 = (document.layers) ? true : false;
GL_IE = (document.all) ? true : false;
GL_IE4 = GL_IE && !GL_DOM;
GL_Mac = (navigator.appVersion.indexOf("Mac") != -1);
GL_IE4M = GL_IE4 && GL_Mac;
GL_IsMenu = (GL_DOM || GL_NS4 || (GL_IE4 && !GL_IE4M));
GL_BrowserString = GL_NS4 ? "NS4" : GL_DOM ? "DOM" : "IE4";


function new_window(the_url, win_name, win_features)
{
  var win_attributes = win_features, w_name = win_name;
  
  if (win_attributes == null)
  {
    win_attributes = "width=610,height=400,location=no,menubar=no,resizable=yes,titlebar=no," + 
                     "status=yes, scrollbars=yes,hotkeys=yes";
  }
  if (w_name == null)
    w_name = "new_win";
  newwin = window.open(the_url, win_name, win_attributes);
  newwin.focus();
  return false;
}

function string_at_index(str, idx, sep)
{
  var arr;

  arr = str.split(sep);
  return arr[idx];
}

function update_form_fields(form_obj, fields, divs)
{
  var cmd_str;

  for (var i = 0; i < fields.length; i++)
  {
    cmd_str = "form_obj." + fields[i] + ".value = document.all." + divs[i] + ".innerHTML";
    eval(cmd_str);
  }
  return true;
}
