/*
Language: CS Javascript
Name: dump
Description:
	Shows the attributes and values of a javascript object in alert boxes containing limit lines each.
	Useful for debugging.
*/

function dump(obj, limit, type, like) {
	var ret = "";
	var count = 0;

	// Handle trivial cases
	if (typeof(obj) == "undefined")
		return alert("The object passed is undefined");
	if (obj == null)
		return alert("The object passed is null");
	if (typeof(obj) != "object")
		return alert(obj);

	// Loop through object attributes
	if (!limit)
		limit = 20;

	for (i in obj) {
		if ((type == null && like == null) || (type != null && typeof(obj[i]) == type) || (like != null && String(i).indexOf(like) == 0)) {
			ret += i + ": "+obj[i]+"\n";
			count++;
		}
		if (count >= limit) {
			alert(ret);
			ret = "";
			count = 0;
		} 			
	}
	return alert(ret);
}
/*
	works in IE only??

		try {
			ret += i + ": "+obj[i]+"\n";
		}
		catch (err) {
			ret + i + ": *********ERROR***********\n";
		}
*/