// Create basic "quick" functions:
ljg =
{
  browser: function()
  {
    if (document.addEventListener) { return "W3C Compliant"; }
    return "Explorer";
  },  

  // Simple foreach functionality, for arrays with numeric and string indices
  foreach: function(ra, fn, p)
  {
    if (this.isUndef(ra, "array") && this.isUndef(ra, "object")) { return; }
    for (var i in ra) 
    { 
      // Make sure that this value is not a function.
      if (!this.isUndef(ra[i], "function")) { continue; }
      fn(ra[i], i, p); 
    }
  },

  // Returns the DOM element specified by the string "el".
  get: function(el) 
  { 
    el = document.getElementById(el); 
    return ((el == null) ? false : el);
  },
  
  make: function(what, attrib)
  {
    var el = document.createElement(what);
    if (this.isUndef(attrib, "object")) { return el; }
    for (var i in attrib) { if (ljg.isUndef(attrib[i], "string")) { continue; } el.setAttribute(((i == "css") ? ((this.browser() == "Explorer") ? "className" : "class") : i), attrib[i]); }
    return el;
  },
  
  attrib: function (el, attrib)
  {
    if (this.isUndef(attrib, "object")) { return; }
    for (var i in attrib) { if (ljg.isUndef(attrib[i], "string")) { continue; } el.setAttribute(((i == "css") ? ((this.browser() == "Explorer") ? "className" : "class") : i), attrib[i]); }
    return el;
  },

  // Fixes a possibly undefined value.
  fix: function(v, f)
  {
    var tv = typeof(v);
    var tf = typeof(f);

    return ((tf == "undefined")
            ? ((tv == "undefined") ? "" : v)
            : ((tv != tf)          ? f  : v));
  },

  // Detects an undefined variable.
  isUndef: function(v, t) 
  { 
    var tv = typeof(v);
    var tt = typeof(t);

    return ((tt == "undefined") 
            ? ((tv == "undefined") ? true : false ) 
            : ((tv != t)           ? true : false )); 
  },

  // Adds an event based on browser compatability.
  //addlog: "",
  add: function(m_o)
  {
    m_o = this.fix(m_o, {});
    if (this.isUndef(m_o.el) || this.isUndef(m_o.fn) || this.isUndef(m_o.on)) { return; }
    if (typeof(m_o.el) == "string") { m_o.el = this.get(m_o.el); }

    m_o.bubble = this.fix(m_o.bubble, false);
    try {
      m_o.el.addEventListener(m_o.on, m_o.fn, m_o.bubble);
    } catch(e) {
      m_o.el.attachEvent("on" + m_o.on, m_o.fn); return;
    }
  },

  remove: function(m_o)
  {
    if (this.isUndef(m_o.el) || this.isUndef(m_o.fn) || this.isUndef(m_o.on)) { return; }
    if (typeof(m_o.el) == "string") { m_o.el = this.get(m_o.el); }
    try {
      m_o.el.removeEventListener(m_o.on, m_o.fn, false);
    } catch(e) {
      m_o.el.detachEvent(m_o.on, m_o.fn); return;
    }
  },
  
  hide: function(el)
  {
    if (this.isUndef(el, "object")) { if (this.isUndef(el, "string")) { return; } el = this.get(el); }
    el.style.visibility = 'hidden';
  },

  show: function(el)
  {
    if (this.isUndef(el, "object")) { if (this.isUndef(el, "string")) { return; } el = this.get(el); }
    el.style.visibility = 'visible';
  },

  htmlentities: function(str)
  {
    var div  = document.createElement('div');
    var text = document.createTextNode(str);
    div.appendChild(text);
    return div.innerHTML;
  },
  
  check_for_enter: function(key) { return (key == 13); },

  // Dummy function for mouse move capture
  mouse_move_function: function() {},

  // Register a mousemove response function:
  mm_use: function(fn)
  {
    if (this.isUndef(fn, "function")) { return; }
    this.mouse_move_function = fn;
  },

  // Restore the empty mousemovement response:
  mm_restore: function()
  {
    this.mouse_move_function = function() {};
  },
  

  // Sends an AJAX request. This function is POST only.
  ajax_send: function(url, parameters, responseHandler, scope)
  {
     parameters = this.fix(parameters, '');

     // Build the request.
     var ajaxRequest = ((window.XMLHttpRequest) 
                        ? new XMLHttpRequest() 
                        : ((window.ActiveXObject)
                           ? new ActiveXObject("Microsoft.XMLHTTP")
                           : false )); 

     // Create the callback
     function BindAjaxCallback() 
     {
       if (ajaxRequest.readyState == 4) 
       { if (!ljg.isUndef(responseHandler, "function")) { responseHandler(ajaxRequest, scope); } }
     }

     // send the request
     if (ajaxRequest)
     {
        parameters += "&ajaxrequest=true&nocachetimestamp=" + (new Date()).getTime();
        ajaxRequest.onreadystatechange = BindAjaxCallback;
        ajaxRequest.open("POST", url, true);
        ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        ajaxRequest.setRequestHeader('Connection', 'close');
        ajaxRequest.send(parameters);
     }
  }
}

ljg.add({ el: document, on: "mousemove", fn: function (event) { ljg.mouse_move_function(event.clientX, event.clientY); } });

document.write(unescape("%3Cscript src='/js/ljg_form.js' type='text/javascript'%3E%3C/script%3E"));
