

var Debug = new function () {
  var debugFlag = 0;
  var dbgWin;
  var txBx;

  var crDbgWin = function () {
    debugFlag = 1;
    var wWidth = 300;
    var wHeight = 200;
    var dadHeight = 20;

    var cmStl = {
      width:wWidth
    };

    dbgWin = document.createElement( 'div' );
    inherit( dbgWin.style, cmStl, {
	"borderWidth":"1",
		 "zIndex" : 100,
		 "borderStyle":"solid",
		 "borderColor":"#888888",
		 position:"absolute",
		 height:wHeight,
		 left:document.body.clientWidth - wWidth - 30,
		 top:document.body.clientHeight - wHeight - 30
		 //		 top: 30
		 } );
    document.body.appendChild( dbgWin );

    var ubar = document.createElement( 'div' );
    inherit( ubar.style, cmStl, {
      overflow:"auto",
		 "zIndex" : 999,
		 height:dadHeight,
		 background:"#bbbbbb",
		 fontSize:"8px"
    } );

    txBx = document.createElement( 'div' );
    inherit( txBx.style, cmStl, {
      overflow:"auto",
	  height:wHeight - dadHeight,
	  background:"#eeeeee",
	  fontSize:"15px"
    } );

    var dbgTtl = document.createTextNode("Debug Window");
    ubar.appendChild( dbgTtl );

    dbgWin.appendChild( ubar );
    dbgWin.appendChild( txBx );
    DaD.setdr( ubar, dbgWin, 1 );
  }

  this.crDbgWin = crDbgWin;


  this.debugOn = function () { debugFlag = 1; }
  this.debugOff = function () { debugFlag = 0; }


  this.msg = function ( newMsg ) {
    if ( dbgWin && debugFlag ) {
      var delim = document.createTextNode( "========" );
      txBx.appendChild( delim );
      var brEl2 = document.createElement( 'br' );
      txBx.appendChild( brEl2 );
      var dbgMsg = document.createTextNode( newMsg );
      txBx.appendChild( dbgMsg );
      var brEl = document.createElement( 'br' );
      txBx.appendChild( brEl );
    }
  }


  this.msgAlert = function ( msg ) {
    alert( msg );
  }


}





