function openPopUp(url, width, height, options)
{
	if (!options || options == '')
	{
		options = "location=no,status=no,menubar=no,scrollbars=no,resizable=no,toolbar=no";
	}
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	window.open(url, "_blank", "left=" + left + ",top=" + top + ",height=" + height + ",width=" + width + "," + options);
}

function openWindow (url)
{
	window.open(url, "_blank");
}

function CheckEmailFormat(stringToCheck)
{
	var arr = stringToCheck.match(/[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+/);
	return (arr != null && arr[0] == stringToCheck);
}

function CheckEmailFormatFromValidator(source, arguments)
{
	arguments.IsValid = CheckEmailFormat(arguments.Value);
}


function closePopUpAndOpenUrl(url)
{
	opener.parent.location.href=url;
	window.close();
}

function openPrintWindow(objectType, printWrapperId, width, height)
{

	var srcContainer = document.getElementById(printWrapperId);

	if(srcContainer)
	{
		if(!width) width = srcContainer.offsetWidth + 30;
		if(width > screen.width) w = screen.width;
		if(!height) height = srcContainer.offsetHeight + 75;
		if(height > screen.height) h = screen.height;
		if(height < 500) h = 500;
		openPopUp("/PrintContent.aspx?objtype=" + objectType + "&container=" + printWrapperId, width, height, "scrollbars=1");
	}
}

function loadPrintContent(container)
{
	var srcContainer = window.opener.document.getElementById(container);
	
	if(srcContainer)
	{
		var destContainer = document.getElementById("printContent");
		if(destContainer)
		{
			destContainer.innerHTML = srcContainer.innerHTML;
			var w = srcContainer.offsetWidth + 30;
			if(w > screen.width) w = screen.width;
			var h = srcContainer.offsetHeight + 75;
			if(h < 500) h = 500;
			if(h > screen.height) h = screen.height;
			var l = (screen.width - w) / 2;
			var t = (screen.height - h) / 2;
			window.moveTo(l, t);
			window.resizeTo(w, h);
		}
	}
}