<?php require_once('main_js.php'); ?>
/**
* Trace
*
* @author    Glen
* @copyright 2006 flickaway.com
* @version   $Id: trace.js 2045 2009-05-12 06:57:05Z glen $
*/


function Trace(trace_id)
{
  ;;; if (!window.console || !console.firebug) {
  ;;;   var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
  ;;;   window.console = {};
  ;;;   for (var i = 0; i < names.length; ++i) { window.console[names[i]] = function(){} }
  ;;; }

  this.embedded = 0;
  this.trace_on = 1;
  ;;; this.store    = 0;
  ;;; this.stored   = "";

  ;;; this.trace_object = document.getElementById(trace_id);

  ;;; if (!this.trace_object) {
  ;;;  this.store = 1;
  ;;;  this.trace_id = trace_id;
  ;;;  if (!window.console || !console.firebug) {
  ;;;    g_events.add("window", "ondomload", this.flush_trace_store, this);
  ;;;  }
  ;;; } else {
  ;;;  this.clear();
  ;;; }
}

p = Trace.prototype;

Trace.prototype.embed = function()
{
  ;;; this.embedded = 1;
  ;;; document.write('<div id="' + this.trace_id + '"></div>');
}

Trace.prototype.enable = function()
{
  ;;; this.trace_on = 1;
}


Trace.prototype.disable = function()
{
  ;;; this.trace_on = 0;
}


Trace.prototype.clear = function()
{
  ;;; if (!window.console || !console.firebug) {
  ;;;  this.trace_object.innerHTML = "<input type='button' onclick='g_trace.clear()' value='clear'><br>";
  ;;; }
}

Trace.prototype.log = function(msg)
{
  ;;; if (!window.console || !console.firebug) {
  ;;;   if (this.trace_on == 1) {
  ;;;     if (this.store == 1) {
  ;;;       this.stored += "pre: " + msg + "<br>";
  ;;;       return;
  ;;;        }
  ;;;      }
  ;;;   this.trace_object.innerHTML += msg + "<br>";
  ;;; } else {
  ;;;   console.log(msg);
  ;;; }
}


Trace.prototype.flush_trace_store = function()
{
  ;;; if ((this.trace_object = document.getElementById(this.trace_id)) == null) {
  ;;;  alert("replaceme still isn't defined");
  ;;;  return;
  ;;; }

  //alert("trace_id is " + this.trace_id + "  trace_object is " + this.trace_object);

  ;;; this.clear();
  ;;; this.store = 0;
  ;;; this.trace_object.innerHTML += this.stored;
  ;;; this.stored = "";
}


g_trace = new Trace("replaceme");
//g_trace.log("first message");
