var list_entity_editor = null; // the Modal object containing the product editor

function fEdit()
{
	page_editor = new Modal
	({
		url : "page_editor.php?ID=" + activeItem,
		show : true,
		"cover color" : "#1f4e23",
		width: 900
	});
}
function fCenterEditButton()
{
	var oEdit = document.getElementById("EditButton");
	oEdit.style.left = ( document.body.clientWidth - oEdit.offsetWidth ) / 2;
	oEdit.style.top = ( document.body.clientHeight - oEdit.offsetHeight ) / 2;
}
function fBodyOnLoad()
{
	if ( document.getElementById("MenuItem" + activeItem) )
	{
		var itemStyle = document.getElementById("MenuItem" + activeItem).style;
		itemStyle.backgroundColor = "#1f4e23";
		itemStyle.color = "#ffffff";
	}
	
	if ( UP["Edit Pages"] )
		document.getElementById("EditButtonForm").style.display = "block";
	fCenterEditButton();
	
	zoomed_page = new Modal
	({
		obj : document.getElementById("Zoomed_Page"),
		"cover color" : "#1f4e23",
		width: 778
	});
	
	body_onload_callback();
}
function fBodyOnResize()
{
	fCenterEditButton();
}
function edit_list( list_id, item_id )
{
	list_entity_editor = new Modal
	({
		url : "list_editor.php?List_ID=" + list_id + "&Item_ID=" + item_id,
		show : true,
		"cover color" : "#1f4e23"
	});
}

function menuItemClick( menuItem )
{
	var id = menuItem.getAttribute("pageID");
	if ( id == activeItem )
		return;
	
	document.getElementById("PageID").value = id;
	
	var form = document.getElementById("PageLoader");
	form.action = "page.php";
	form.submit();
}
function menuItemMouseOut( menuItem )
{
	var id = menuItem.getAttribute("pageID");
	if ( id == activeItem )
		return;
	
	menuItem.style.backgroundColor = "transparent";
	menuItem.style.color = "#ffffff";
}
function menuItemMouseOver( menuItem )
{
	var id = menuItem.getAttribute("pageID");
	if ( id == activeItem )
		return;
	
	menuItem.style.backgroundColor = "#B6D7D0";
	menuItem.style.color = "#000000";
}

function open_page( page_id )
{
	var form = document.getElementById("PageLoader");
	var original_id = document.getElementById("PageID").value;
	var original_action = form.action;
	var original_target = form.target;
	
	document.getElementById("PageID").value = page_id;
	form.action = "zoomed_page.php";
	form.target = "Zoomed_Page";
	form.submit();
	
	document.getElementById("PageID").value = original_id;
	form.action = original_action;
	form.target = original_target;
	
	zoomed_page.show();
}