/* var_dump class */
function var_dump()
{

this.MAX_DEPTH = 10;

this.str_repeat = function(str, repeat) 
{
  var output = '';

  for (var i = 0; i < repeat; i++) 
  {
    output += str;
  }

  return output;
}

this.var_dump = function(obj, indent, depth) 
{
  var ws = '    ';
  var output = '';

  indent = (!indent) ? 0 : indent;
  depth = (!depth) ? 0 : depth;

  if (depth > this.MAX_DEPTH) 
  {
    return this.str_repeat(ws, indent) + '*Maximum Depth Reached*\n';
  }

  if (typeof(obj) == "object") 
  {
    output += (indent == 0) ? typeof(obj) + '\n(\n' : '';

    indent++;

    var child = '';

    for (var key in obj) 
    {
      try 
      {
        child = obj[key];
      }

      catch (e) 
      {
        child = '*Unable To Evaluate*';
      }

      output += this.str_repeat(ws, indent) + '['+key+'] => ';

      if (typeof(child) == "object") 
      {
        indent++;

        output += typeof(child) + '\n';
        output += this.str_repeat(ws, indent) + '(\n';
        output += this.var_dump(child, indent, depth+1);
        output += this.str_repeat(ws, indent) + ')\n';

        indent--;
      }
      else 
      {
        output += child + '\n';
      }
    }

    indent--;

    output += (indent == 0) ? ')\n' : '';

    return output;
  }
  else 
  {
    return this.str_repeat(ws, indent) + obj + '\n';
  }
}

}

var var_dump = new var_dump();
