// JavaScript Document

// Show the debug window
function showDebug() {
  window.top.debugWindow = window.open("",
                  "Debug",
                  "left=0,top=0,width=750,height=550,scrollbars=yes,"
                  +"status=yes,resizable=yes");
  window.top.debugWindow.opener = self;
  window.top.debugWindow.document.open();
  if(window.top.debugWindow.textarea == null){
      var winHTML = "<html><head><title>Debug Window</title><style type=\"text/css\">body,td,th{color: #F0CD3C;font-size: 11px} body{background-color: #333333;}</style></head>\n";
          winHTML += "<body><textarea id='textarea' style=\"display: block; width: 100%; height: 100%; font-size: 11px; background-color: #000000; color: #F0CD3C \"></textarea></body></html>"
      window.top.debugWindow.document.write(winHTML);
      window.top.debugWindow.textarea = window.top.debugWindow.document.getElementById("textarea");
  }
      
}

// If the debug window exists, then write to it
function debug(text) {
  if(window.top.debugWindow.textarea != null && !window.top.debugWindow.closed){
    window.top.debugWindow.textarea.value += text + "\n";
  }
}

// If the debug window exists, then close it.
function hideDebug(){
  if (window.top.debugWindow && ! window.top.debugWindow.closed) {
    window.top.debugWindow.close();
    window.top.debugWindow = null;
  }
}