/**
 * Recrusive printing method
 * 
 * TODO: improve recursion and type recognition
 */
function printr(m, r, i)
{
	var s_return = '';
	var level = (typeof(i) == 'undefined') ? 0 : i;
	
	if (i == 2) return;
	
	if(typeof(m) == 'object')
	{
		for (var s in m) 
		{ 
			if (s != 'moParent')
			{
				s_return += "\n" + s + ' : ';
				s_return += printr(m[s], true, level + 1); 
			}
		}
	}
	else if (typeof(m) == 'function') s_return += 'function'
	else s_return += m;
	
	if (r)	return s_return;
	else 	alert(s_return);
}


/**
 * Alternative for prototypes Function.delay with option to pass scope
 * 
 * @param	int		timeout
 * @param	Object	scope
 */
Function.prototype.delayScoped = function()
{
	var __method = this, args = $A(arguments), timeout = args.shift() * 1000, o_scope = args.shift();
	return window.setTimeout(function() { return __method.apply(o_scope, args); }, timeout);
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}