////////////////////////////////////////////////////////////////////////////////////////////////////
// Norman Geiersbach
// Eitido (c) 2005
// Version 1.0.0.1
////////////////////////////////////////////////////////////////////////////////////////////////////


// General utility functions
////////////////////////////////////////////////////////////////////////////////////////////////////

// gen_browser
// Detects the running web browser
  function gen_browser()
  {
    if( !document.all && document.getElementById )
      return "ns6";
    if( document.layers )
      return "ns4";
    if( document.all )
      return "ie";
  }


// gen_close
// Closes the window, where the call come from
  function gen_close()
  {
    window.close();
  }


// gen_popup
// Pop up an url in a new window
// Possible additional parameters:
//   menubars, scrollbars, location, directories, resizable, status, toolbar
  function gen_popup(url, width, height)
  {
    var wndprop;
    wndprop = "width=" + width + ",height=" + height;

    for(var i = 3; i < gen_popup.arguments.length; i++)
      wndprop += "," + gen_popup.arguments[i];

    window.open(url, 'gen_popup', wndprop);
  }


// gen_redirect
// Redirect to another page or site
  function gen_redirect(url)
  {
    self.location.href = url;
  }


// Element utility functions
////////////////////////////////////////////////////////////////////////////////////////////////////

// gen_element
// Returns the reference to an element
  function gen_element(element_id)
  {
    if( document.getElementById )
      return document.getElementById(element_id);
    if( document.all )
      return document.all[element_id];

    return false;
  }


// gen_hide
// Hides an element
  function gen_hide(element_id)
  {
    var e = gen_element(element_id);

    if( e.style )
      e.style.visibility = "hidden";
    else if( e.visibility )
      e.visibility = "hide";
  }


// gen_show
// Shows an element
  function gen_show(element)
  {
    var e = gen_element(element_id);

    if( e.style )
      e.style.visibility = "visible";
    else if( e.visibility )
      e.visibility = "show";
  }


// Form utility functions
////////////////////////////////////////////////////////////////////////////////////////////////////

// gen_form_action
// Updates the action for a form
  function gen_form_action(form_name, action_url)
  {
    document.forms[form_name].action = action_url;
  }

