/**
 * print_r for javascript (of course, using firebug works too)
 * 
 * @param theObj
 * @param string
 *            element the debug output should attach to
 * @return
 */
function print_r(theObj, parent) {
	if (theObj.constructor == Array || theObj.constructor == Object) {
		jQuery(parent).append("<div style='padding-left:25px;'>");
		for ( var p in theObj) {
			if (theObj[p].constructor == Array
					|| theObj[p].constructor == Object) {
				jQuery(parent).children('div:last').append(
						"<span style='display:block;'>> [" + p + "] => "
								+ typeof (theObj) + "</span>");
				jQuery(parent).children('div:last').children('span:last')
						.click(function() {
							jQuery(this).next('div').toggle();
						});
				print_r(theObj[p], jQuery(parent).children('div:last'));
			} else {
				jQuery(parent).children('div:last').append(
						">[" + p + "] => " + theObj[p] + "<br/>");
			}
		}
	}
}

