function inspect(elem)
{
	var s = "";
	for (var i in elem)
	{
		try
		{
			var property = elem[i];
			var type = typeof property;
			if (type == "function")
				property = "function";
			else if (type == "string")
				property = "\"" + property + "\"";

			if (property.length > 100)
				property = property.substring(0, 100) + "...";
						
			s += i + ": " + property + ", ";
		}
		catch(e) { }
	}

	if (s.length >= 2)
		s = s.substring(0, s.length - 2);

	return s;
}

function diffDays(X, Y)
{
	var Dx = Date.UTC(X.getFullYear(), X.getMonth(), X.getDate());
    var Dy = Date.UTC(Y.getFullYear(), Y.getMonth(), Y.getDate());
    return (Dx - Dy) / 86400000 + 1;
}

function KeyPress()
{
	if (window.event.keyCode == 13)
		window.event.keyCode = 0;
}

function openWindow(page, name, size, focus)
{
	var arr = size.split("x");
	var width = arr[0];
	var height = arr[1];

	var win = window.open(page ,name,
		"toolbar=no, scrollbars=no, resizable=yes, width=" + width + ", height=" + height);
		
	if (focus)
		win.focus();
		
	return win;
}

