var winWidth = 700;
var winHeight = 300;

function showDetails(id)
{
	if (!$("itemtext")) { return; }
	$("itemtext").setStyle({
		left: Math.floor((document.viewport.getWidth() - winWidth) / 2) + "px",
		top: Math.floor((document.viewport.getHeight() - winHeight) / 2) + document.viewport.getScrollOffsets().top + "px"
	});
	new Ajax.Request('?id=' + id, {
		method: 'get',
		onSuccess: function(transport) {
			$("itemtextarea").update(transport.responseText);
			$("itemtextbg").show();
		}
	});
}

function hideDetails()
{
	$("itemtextbg").hide();
}

document.observe("dom:loaded", function () {
	if (!$("itemtext")) { $$('body')[0].appendChild(Builder.node("div", {id: "itemtextbg"})); }
	$("itemtextbg").hide();
	$("itemtextbg").setStyle({
		width: document.viewport.getWidth() + 'px',
		height: $$('body')[0].getHeight() + 'px'
	});
	$("itemtextbg").observe('click', function(event) {
		hideDetails();
	});
	$("itemtextbg").appendChild(Builder.node("div", {id: "itemtext"}));
	$("itemtext").appendChild(Builder.node("div", {id: "itemtextarea"}));
	$("itemtext").setStyle({
		width: winWidth + 'px',
		height: winHeight + 'px'
	});
	$("itemtextarea").setStyle({
		margin: "5px",
		padding: "10px",
		height: (winHeight - 30) + 'px'
	});
});

function list_props(obj, objname)
{
	nw = window.open('','nw','toolbar=no, scrollbars=yes');
	for (prop in obj)
	{
		nw.document.write(objname + "." + prop + " = " + obj[prop] + "<br>");
	}
}

