/***********************************************************************************************************************
 File		: Debug.js
 File Type	: Javascript (all)

 Copyright 	: xtendo technologies Kurt Schwedes, 76185 Karlsruhe, Germany
		      All rights reserved
.......................................................................................................................
 Created		: 28.04.04
 Author			: Kurt Schwedes, xtendo technologies
 Last Change	: 27.07.04
.......................................................................................................................

 For JS-debugging and tests only! Remove in production release!!!

.......................................................................................................................
 Develeped for 	: xtendo technologies Kurt Schwedes, 76185 Karlsruhe, Germany
 Contact		: kurt.schwedes@xtendo.de
 Documentation 	: ---
***********************************************************************************************************************/

function alertProperties(_obj, hideMethods)
{
	if (typeof _obj == 'object'){
		var s='';
		var a = [];
		for(var p in _obj) a.push(p);
		a = a.sort();
		var c;
		if (typeof a[0] == 'string') c = a[0].charCodeAt(0);
		else c = String(a[0]).charCodeAt(0);
		for(var i=0; i < a.length; i++){
			var p = a[i];
			if (p.charCodeAt(0) != c){
				s+='\n';
				c = p.charCodeAt(0);
			}
			if (p!='innerHTML' && p!='outerHTML' && p!='innerText' && p!='outerText')
			if (typeof _obj[p]!= 'function') s+=p+': '+_obj[p]+" | ";
			else if (!hideMethods) s+=p+': '+"[M] | ";
		}	
				
		alert(s);
	}
	else alert ('Kein Objekt! Wert:\n'+_obj);
}

function showStructure (obj, pre, lf)
{
    pre = pre || '';
    var s = '';
    if (obj && typeof obj == 'object'){
        if (obj.length != null){
            // obj is a array
            s += (lf ? '\n'+ pre : '')  + '['
            for (var i = 0; i < obj.length; i++){
                var v = obj[i];
                if (v && typeof v == 'object'){
                    v = showStructure(v, pre + '  ', true);
                    s += pre + ' ' +v;
                }
                else{
                    if (typeof v == 'function') v = '[M]';
					s += '\n' + pre + ' ' +v;
				}
            }
            s += '\n' + pre + ']'
        }
        else {
            // obj is a object
            s += '\n' + pre + '{'
            for (var p in obj){
                var v = obj[p];
                if (v && typeof v == 'object'){
                    v = showStructure(v, pre + '  ', true);
                }
				if (typeof v == 'function') v = '[M]';
                s += '\n' + pre + ' ' + p + ' => '+ v;
            }
            s +=  '\n' + pre + '}'
        }
    }
    else {
        if (typeof obj == 'function') obj = '[M]';
		s += '\n' + pre + obj;
    }
    return s;
}
