
/****************************************************************
 * will fix later hopefully
 */

function selectMenuItem(name) 
{
   var curMenuRow = top.curMenuRow; 
   var row = top.menuFrame.window.document.getElementById(name);
   gmTrace(curMenuRow + ' -> ' + name + ';' + row);
   if (row == undefined) return;
      gmTrace('actually do it');
   	if (curMenuRow != undefined) {
       	curMenuRow.className = 'menuSpacer'; 
   	}
		row.className = 'menuMarker'; 
   	top.curMenuRow = row; 
}

/****************************************************************
 * debug support 
 */
function xbDebug()
{
    this.on = false;
}

xbDebug.prototype.modeOn = function (mode)
{
   this.on = mode; 
}

xbDebug.prototype.open = function ()
{
    if (this.debugwindow && !this.debugwindow.closed)
        this.close();

    this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes');

    this.debugwindow.title = 'xbDebug Window';
    this.debugwindow.document.write('<html><head><title>xbDebug Window</title></head><body><h3>Javascript Debug Window</h3></body></html>');
    this.debugwindow.focus();
}

xbDebug.prototype.close = function ()
{
    if (!this.debugwindow)
        return;

    if (!this.debugwindow.closed)
        this.debugwindow.close();
}

xbDebug.prototype.dump = function (msg)
{
    if (!this.on)
        return;

    if (!this.debugwindow || this.debugwindow.closed)
        this.open();

  
    this.debugwindow.document.write(msg + '<br>');

    return;
}

var xDEBUG = new xbDebug();

function trace(str, color) 
{
   xDEBUG.dump(str);
}

function gmTrace(str, color) 
{
   if (xDEBUG.on) GLog.write(str, color); 
}

function gmTraceHtml(str, color) 
{
   if (xDEBUG.on) GLog.writeHtml(str, color); 
}

function gmTraceUrl(str, color) 
{
   if (xDEBUG.on) GLog.writeUrl(str, color); 
}



function propsToStr(p) 
{   
    var str = "";
    var obj = "";
    var fct = "";   
    for (prop in p) {
	    if (typeof(p[prop]) == 'object') {
	    	obj += prop + " "; 
	    } else if (typeof(p[prop]) != 'function') { 
	   		str += prop + "=" + p[prop] +"\n"; 
	    } else {
	       fct += prop + " "; 
	    }
    }
    if (obj != "") {
       str += "objects: " + obj + "\n"; 
    }
    if (fct != "") {
       str += "functions: " + fct + "\n"; 
    }
    //throw new Error(str);
    
    return str;  
}


function objPropsToStr(p) 
{   
    var obj = "";
    for (prop in p) {
	    if (typeof(p[prop]) == 'object') {
	    	obj += prop + "(" + propsToStr(p[prop]) + ")" + " "; 
	    } 
    }
    return obj; 
}

/*
 * END debug support 
 ****************************************************************/
//alert("loaded index.js"); 


