//Output all object properties in an alert box.
function print_r( $object, $return, $levels ) {
	if ( typeof $return == 'undefined' ) $return = false;
	if ( typeof $levels == 'undefined' ) $levels = 0;

	if( typeof $return == 'number' ){
		$levels = $return;
		$return = false;
	}

	var str=""; //variable which will hold property values
	var r = function ( $object, $count ) {
		for( prop in $object ) {
			if( typeof $object[prop] == 'object' && $count < $levels ) {
				r( $object[prop], $count + 1 );
			}
			else {
				str += '\t'.repeat( $count )
					+ prop
					+ ' '
					+ '('+typeof $object[prop]+')'
					+ ': '
					+ $object[prop]+'\n';
			}
		}// /for()
	};// /r()

	String.prototype.repeat = function(l){
		return new Array(l+1).join(this);
	};

	r( $object, 0 );

	if ( !$return ) {
		alert( str );
	}
	else {
		return str;
	}
}// /print_r()