/*
        
VERSION: 1.0.0
FILENAME: debugsys.js
LAST MODIFICATION: 02/12/2010
DESCRIPTION: 

  Sistema de debug del avanzo_player, para controlar la ejecucion desde una
  ventana externa.

------------------------------------------------------------------------------*/

var DebugWind;

function OpenDebugWind() {
	var prop;
  var strDebugWindow;
  var strDebugControls;
  
  strDebugControls = "<BR><span>AVANZO PLAYER - DEBUG WINDOW</span><br>";
  strDebugControls+= "<input type=text size=40 id=c>";
  strDebugControls+= "<input type=button value=Go onclick=window.opener.DebugExe(c.value)>"
  strDebugControls+= "<input type=button value=Limpiar onclick='Limpiar()'>"
  strDebugControls+= "<br>";
  strDebugControls+= "<input type=button value=Resumen onclick=window.opener.DebugExe('mostrarResumen()')>"
  strDebugControls+= "<input type=button value=Parametros onclick=window.opener.DebugExe('mostrarParametros()')>"
  strDebugControls+= "<br><br>";
  
  strDebugWindow = "<script>";
  strDebugWindow+= "function Limpiar() {";
  strDebugWindow+= "       var childCount = 0;";
  strDebugWindow+= "       if (window.document.body.childElementCount === undefined) {";
  strDebugWindow+= "                             childCount = window.document.body.children.length;";
  strDebugWindow+= "                          } else {";
  strDebugWindow+= "                             childCount = window.document.body.childElementCount;";  
  strDebugWindow+= "                         }";
  strDebugWindow+= "  for (i=0; i<childCount; i++) {";
  strDebugWindow+= "      var elemento = window.document.body.children[i];";
  strDebugWindow+= "      if (elemento.tagName.toUpperCase()=='P') { ";
  strDebugWindow+= "        window.document.body.removeChild(elemento);";
  strDebugWindow+= "        i--;";
  strDebugWindow+= "      }";
  strDebugWindow+= "   }";
  strDebugWindow+= "}";
  strDebugWindow+= "</script>";
  strDebugWindow+= "<STYLE type=text/css>";
  strDebugWindow+= "* {margin: 0px 0px 0px 10px; padding: 0}";
  strDebugWindow+= "</STYLE>";
  
	if (!DebugReady) {
		prop='width=450,height=550,top=0,left=0,scrollbars=yes,resizeable=yes,resizable=yes,status=no';
		DebugWind = window.open('',"",prop);
		DebugReady=true;
		DebugWrite(strDebugControls+strDebugWindow);
	}
}

function DebugExe(txt) {
	avanzo_playerObj.SetVariable('DebugExe',txt);
}

function DebugWrite(txt) {
	if (DebugReady) DebugWind.document.write(txt)
}

function DebugMessage(txt,level) {
	if (strDEBUG>=level) DebugWrite(txt);
	if (level==1) alert(txt);
}


