// 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 == null){
      var winHTML = "<html><head><title>Debug Window</title><style type=\"text/css\">body,td,th{color: #F78408;font-size: 11px} body{background-color: #F8F8F8;}</style></head>\n";
          winHTML += "<body><textarea id='textarea' style=\"display: block; width: 100%; height: 100%; font-size: 11px; background-color: #FFFFFF; color: #FF6600; \"></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 != null){
    if(!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 != null) {
      if(!window.top.debugWindow.closed){
            window.top.debugWindow.close();
            window.top.debugWindow = null;
        }
      }
}
