function trace(msg) {
	// return false;
	if (typeof window.debug != 'undefined') {
		if (debug==0) {
			return false;
		}
	}
	$debug = $("debug");
	if (!$debug) {	
		$body = $(document.body);
		$body.insert("<div id='debug' style='position: absolute; z-index: 999; top: 0px; right: 0px; width: 15%; height: 1200px; opacity:.8; background-color: #fff; color: #000; overflow:scroll; padding:15px;'><p style='font-size: 14px; font-weight: bold; font-family: arial;'><a href='#' onclick='clearTrace();'>clear</a></p></div>");
		$debug = $("debug");
	}
	$debug.insert(msg+"<br />");
}

function enumerate(obj) {
	var output = "";
	for (var prop in obj) {
		output += prop+": "+obj[prop]+"<br />";
	}
	return output;
}

function print_r(array) {
	var output = "";
	var count=0;
	for (var el in array) {
		if (count<array.length) {
			output += el+": "+array[el]+"<br />";
		}
		count++;
	}
	return output;
}

function clearTrace() {
	$debug = $("debug");
	$debug.update("<p style='font-size: 14px; font-weight: bold; font-family: arial;'><a href='#' onclick='clearTrace();'>clear</a></p>");
	return false;
}