var defaultWidth  = 500;
var defaultHeight = 350;
var defaultTop    = 0;
var defaultLeft   = 0;
var defaultParameters = "menubar=no,toolbar=no,location=no,statusbar=no";

function popupId(id)
{
	popupUrl(id, "about:blank");
}

function popupUrl(id, url)
{
	popupSize(id, url, defaultWidth, defaultHeight);
}

function popupSize(id, url, width, height)
{
	popupPosition(id, url, width, height, defaultTop, defaultLeft);
}

function popupCenter(id, url, width, height)
{
	popupPosition(id, url, width, height, (screenWidth() / 2) - (width / 2), (screenHeight() / 2) - (height / 2));
}

function popupPosition(id, url, width, height, top, left)
{
	popupExtended(id, url, width, height, top, left, defaultParameters);
}

/**
 * @param id         = id of the object, usable for functions that points at the popup in another time
 * @param url        = url where to point using this popup
 * @param width      = width of the window
 * @param height     = height of the window
 * @param top        = position from top
 * @param left       = position from left
 * @param parameters = additional parameters to pass
 */
function popupExtended(id, url, width, height, top, left, parameters)
{
	var finalParameters = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height;

	if (parameters.length > 0)
	finalParameters = finalParameters + "," + parameters;

	return window.open(url, id, finalParameters);
}
