(function(window) { 

	// public
	window.get_r = function(obj) {	
		
		if (typeof(obj)!='object') { return obj; }
		var str = obj+":\n"; // write obj type	
		str += "(\n"; // write open bracket
		
		for(index in obj) { // foreach index of this object/array
			try {
				indextype = typeof(obj[index]); // get index type
				if (indextype != 'object') { // if index contains simple data type, write index and its value
					if (indextype=='function') {
						str += "  ["+indextype+"] "+index+"()\n"; 			
					}
					else if (indextype=='string') {
						str += "  ["+indextype+"] "+index+" = '"+obj[index]+"'\n"; 
					}
					else {
						str += "  ["+indextype+"] "+index+" = "+obj[index]+"\n"; 
					}
				}
				else { // if index is an object/array, write index and call this function on value
					str += "  ["+indextype+"] "+index+" = "+obj[index]+"\n"; 
				}
			}
			catch(err) {
				 str += "  [error] "+index+": {"+err+"}\n"; 			
			}
		}
		str += ")\n"; // write close bracket
		return str; // return result str
	}
	
})( window );


