// Copyright - DuneSoft, 2002, All Rights Reserved
function getWindowFeatures (pxHeight, pxWidth)
{
	var strFeatures = "height=" + pxHeight + ", width=" + pxWidth;
	var windowTop = (self.screen.height/2) - (pxHeight/2);
	var windowLeft = (self.screen.width/2) - (pxWidth/2);
	if (windowTop > 0)
		strFeatures += ", top=" + parseInt(windowTop);
	else
		strFeatures += ", top=0";
	if (windowLeft > 0)
		strFeatures += ", left=" + parseInt(windowLeft);
	else
		strFeatures += ", left=0";
	return strFeatures;
}
function getWindowCenterTop(pxHeight)
{
	var windowTop = (self.screen.height / 2) - (pxHeight / 2);
	if (windowTop > 0)
		return parseInt(windowTop);
	return 0;
}
function getWindowCenterLeft(pxWidth)
{
	var windowLeft = (self.screen.width / 2) - (pxWidth / 2);
	alert(window.top.screen.width / 2);
	if (windowLeft > 0)
		return parseInt(windowLeft);
	return 0;
}
function popupWindow(url, name, pxHeight, pxWidth)
{
	window.open(url, name, getWindowFeatures(pxHeight, pxWidth), true).focus();
}
function popupWindow(url, name, pxHeight, pxWidth, features)
{
	window.open(url, name, getWindowFeatures(pxHeight, pxWidth) + ", " + features, true).focus();
}
function popupItem(argument, type)
{
	switch (type)
	{
		case "Contact":
			popupWindow("/Manager/Resources/Common/ContactPopup.aspx?" + argument, "ContactInformation", 450, 410);
			break;
		case "Session":
			popupWindow("/Manager/Administration/SessionPopup.aspx?" + argument, "SessionInformation", 470, 730);
			break;
		case "Help":
			popupWindow("/Manager/Help/HelpWindow.aspx?" + argument, "HelpWindow", 500, 760, "resizable, scrollbars");
			break;
		case "EditHelp":
			popupWindow("/Manager/Help/EditHelpWindow.aspx?" + argument, "EditHelpWindow", 650, 800, "resizable, scrollbars");
			break;
		case "RenameColumn":
			popupWindow("/Manager/Reports/Common/RenameColumn.aspx?" + argument, "RenameColumn", 220, 470);
			break;
	}
}
function popupNewEvent()
{
	popupWindow("/Manager/Schedule/Events/SelectEventType.aspx", "SelectEventType", 220, 270);
}

function popupSelectEvent()
{
	popupWindow("/Manager/Schedule/Tickets/SelectEvent.aspx", "SelectEvent", 200, 520);
}

function popupSelectedItem(list, type)
{
	if (list.selectedIndex < 0)
		alert("Please select an item from the list and try again.");
	else
		popupItem(list.options[list.selectedIndex].value, type);
}
function popupCalendar(e)
{
	if (e.getAttribute("DateTime") != null)
		popupWindow("/Manager/Calendar.aspx?ControlID=" + e.getAttribute("ID") + "&DateTime=" + e.getAttribute("DateTime"), "Calendar", 340, 310);
	else
		popupWindow("/Manager/Calendar.aspx?ControlID=" + e.getAttribute("ID"), "Calendar", 340, 310);
}
function updateCalendarOwner(date)
{
	__CalendarOwner.text = date;
}
function updateCalendarOwner(date, time)
{
	__CalendarOwner.text = date + " " + time;
}
function Download(file)
{
	popupWindow("/Manager/Reports/Common/DownloadReport.aspx?Target=" + file, "DownloadFile", 500, 700, "resizable, scrollbars, menubar");
}
function DownloadFile(file)
{
	popupWindow(file, "DownloadFile", 500, 700, "resizable, scrollbars, menubar");
}
function popupMessageBox(obj)
{
	if (obj != null)
	{
		var width = obj.style.width;
		var height = obj.style.height;
		if (width.length > 0 && height.length > 0)
		{
			width = Number(width.substr(0, width.indexOf("px")));
			obj.style.left = ((GetWindowWidth() / 2) - (width / 2)) + "px";
			height = Number(height.substr(0, height.indexOf("px")));
			if (GetWindowHeight() > height)
				obj.style.top = ((GetWindowHeight() / 2) - (height / 2)) + "px";
			else
				obj.style.top = "0px";
			obj.style.visibility = "visible";
		}
	}
}

