	var alertIE = (navigator.appName.indexOf("Microsoft") != -1);
	var alertDefaultSkinName = "Gray";
	var alertDefaultTitle = "Alert";
	var alertDefaultText = "Are you sure?";
	var alertDefaultTrueButtonText = "Yes";
	var alertDefaultFalseButtonText = "No";
	var oAlertBlockingLayer = null;
	var oAlertLayer = null;
	var oAlertTemporalLayer = null;
	var alertFunctionParameter = null;
	var alertScrollTimerId = null;
	var alertPreviousTopPosition=0;
	var alertPreviousLeftPosition=0;
	var alertHalfBoxHeight = 0;
	var alertHalfWinHeight = 0;
	var alertHalfBoxWidth = 0;
	var alertHalfWinWidth = 0;
	var oAlertTrueButton = null;
	var oAlertFalseButton = null;
	
	function alertHideShowElements(sTagName,sStatus)
	{
		var aElm = document.getElementsByTagName(sTagName);
		var oElm = null;
		for (i=0; i<aElm.length; i++)
		{
			oElm = aElm[i];
			oElm.style.visibility = sStatus;
		}
	}
	function alertGetScrollTop()
	{
		var iValue = 0;
		
		if (document.body.scrollTop)
		{
			iValue = document.body.scrollTop;
		}
		else
		{
			if (window.pageYOffset)
			{
				iValue = window.pageYOffset;
			}
			else
			{
				if (document.documentElement)
				{
					iValue = document.documentElement.scrollTop;
				}
			}
		}
		return iValue;
	}
	function alertGetScrollLeft()
	{
		var iValue = 0;
		
		if (document.body.scrollLeft)
		{
			iValue = document.body.scrollLeft;
		}
		else
		{
			if (window.pageXOffset)
			{
				iValue = window.pageXOffset;
			}
			else
			{
				if (document.documentElement)
				{
					iValue = document.documentElement.scrollLeft;
				}
			}
		}
		return iValue;
	}
	function alertGetWinWidth()
	{
		var iWidth = 0;
		if (window.innerWidth)
		{
			iWidth = window.innerWidth;
		}
		else
		{
			if (document.body.offsetWidth)
			{
				iWidth = document.body.offsetWidth;
			}
		}
		return iWidth;
	}
	function alertGetWinHeight()
	{
		var iHeight = 0;
		if (window.innerHeight)
		{
			iHeight = window.innerHeight;
		}
		else
		{
			if (document.body.offsetHeight)
			{
				iHeight = document.body.offsetHeight;
			}
		}
		return iHeight;
	}
	function alertGetMaxWidth()
	{
		var iWidth = alertGetWinWidth();
		if (document.width)
		{
			if (document.width > iWidth)
			{
				iWidth = document.width;
			}
		}
		if (document.body.scrollWidth)
		{
			if (document.body.scrollWidth > iWidth)
			{
				iWidth = document.body.scrollWidth;
			}
		}
		return iWidth;
	}
	function alertGetMaxHeight()
	{
		var iHeight = alertGetWinHeight();
		if (document.height)
		{
			if (document.height > iHeight)
			{
				iHeight = document.height;
			}
		}
		if (document.body.scrollHeight)
		{
			if (document.body.scrollHeight > iHeight)
			{
				iHeight = document.body.scrollHeight;
			}
		}
		return iHeight;
	}
	function alertKeepFocus(obj)
	{
		if (oAlertLayer)
		{
			if (obj == oAlertFalseButton)
			{
				if (oAlertTrueButton) oAlertTrueButton.focus();
			}
			else
			{
				if (oAlertFalseButton) oAlertFalseButton.focus();
			}
		}
	}
	function alertBlockAll()
	{
		var iWidth = alertGetMaxWidth();
		var iHeight = alertGetMaxHeight();
		if (iHeight >= alertGetWinHeight())
		{
			iWidth = iWidth - (alertIE ? 20 : 16);
		}
		if (alertIE)
		{
			if (iWidth > alertGetWinWidth() - 20)
			{
				iHeight = iHeight - 20;
			}
			else
			{
				iHeight = iHeight - 4;
			}
		}
		else
		{
			if (iWidth >= alertGetWinWidth())
			{
				iHeight = iHeight - 16;
			}
		}
		if (oAlertBlockingLayer == null)
		{
			oAlertBlockingLayer = document.createElement("Div");
		}
		oAlertBlockingLayer.style.top = "0";
		oAlertBlockingLayer.style.left = "0";
		oAlertBlockingLayer.style.width = iWidth + "px";
		oAlertBlockingLayer.style.height = iHeight + "px";
		oAlertBlockingLayer.style.zIndex = "10000";
		oAlertBlockingLayer.style.position="absolute";
		if (alertIE)
		{
			oAlertBlockingLayer.style.background="#FFFFFF";
			oAlertBlockingLayer.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
		}
		document.getElementById("divAlertDeleteContainer").appendChild(oAlertBlockingLayer);
	}
	function alertCloseAlert(bStatus)
	{
		document.getElementById("divAlertDeleteContainer").removeChild(oAlertLayer);
		document.getElementById("divAlertDeleteContainer").removeChild(oAlertBlockingLayer);
		oAlertLayer = null;
		oAlertBlockingLayer = null;
		clearTimeout(alertScrollTimerId);
		if (alertIE) alertHideShowElements("SELECT","visible");
		alertHideShowElements("OBJECT","visible");
		if (window.fnDeleteAlertReturn)
		{
			fnDeleteAlertReturn(bStatus, alertFunctionParameter);
		}
	}
	function alertGetAlertTable(sMessage,sTrueButton,sFalseButton,sTitle,sSkinName,sOnlyAlert)
	{
		var sTable = "";
		sTable += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"alertoutertable\" id=\"tblAlert\">";
		sTable += "<tr><td>";
		sTable += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"alertinnertable\">";
		sTable += "<tr><td>";
		
		sTable += "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\" class=\"alerttitletable\">";
		sTable += "<tr><td align=\"left\">";
		sTable += sTitle ? sTitle : alertDefaultTitle;
		sTable += "</td><td align=\"right\">";
		sTable += "<a href=\"javascript:alertCloseAlert(false);\"><img src=\"../Images/backend/Close-icon.gif\" border=\"0\"></a>";
		sTable += "</td></tr>";
		sTable += "</table>";
		
		sTable += "</td></tr>";
		sTable += "<tr><td align=\"center\">";
		
		sTable += "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" class=\"alertmessagetable\" width=\"100%\">";
		sTable += "<tr><td colspan=\"5\">&nbsp;</td></tr>";
		sTable += "<tr valign=\"middle\">";
		sTable += "<td align=\"left\" width=\"10\">";
		sTable += "</td><td align=\"left\" width=\"10\">";
		sTable += "<img src=\"../Images/backend/Alert-icon.gif\" border=\"0\">";;
		sTable += "</td><td width=\"1\"></td><td align=\"left\">";
		sTable += sMessage ? sMessage.replace(/\n/g,"<br>") : alertDefaultText;
		sTable += "</td><td width=\"10\"></td>";
		sTable += "</tr>";
		sTable += "<tr><td colspan=\"5\">&nbsp;</td></tr>";
		sTable += "</table>";
		
		sTable += "</td></tr>";
		sTable += "<tr><td align=\"center\">";
		
		sTable += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"alertbuttontable\" width=\"100%\">";
		sTable += "<tr height=\"27\" valign=\"middle\">";
		sTable += "<td align=\"left\">";
		sTable += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		sTable += "<tr valign=\"middle\">";
		sTable += "<td width=\"10\"></td>";
		if ( sOnlyAlert == null )
		{
			sTable += "<td align=\"left\">";
			sTable += "<a class=\"imagebuttonAlert\" href=\"javascript:alertCloseAlert(true);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertTrueButton\"><img align=\"absmiddle\" src=\"../Images/backend/yes-icon.gif\">&nbsp;&nbsp;" + (sTrueButton ? sTrueButton : alertDefaultTrueButtonText) + "</a>&nbsp;&nbsp;"
			sTable += "<td class=\"alertbuttonseparatorskin\"></td>";
			sTable += "<td class=\"alertbuttonseparatorwhite\"></td>";
			sTable += "</td><td width=\"10\"></td>";
		}
		else sTable += "<td width=\"10\"></td>";
		sTable += "<td align=\"center\">";
		if ( sOnlyAlert == null )
			sTable += "<a class=\"imagebuttonAlert\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Images/backend/no-icon.gif\">&nbsp;&nbsp;" + (sFalseButton ? sFalseButton : alertDefaultFalseButtonText) + "</a>&nbsp;&nbsp;"
		else
			sTable += "<a class=\"imagebuttonAlert\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Images/backend/ok-icon.gif\">&nbsp;&nbsp;" + (sFalseButton ? sFalseButton : sOnlyAlert) + "</a>&nbsp;&nbsp;"
			
		sTable += "</td>";
		sTable += "<td class=\"alertbuttonseparatorskin\"></td>";
		sTable += "<td class=\"alertbuttonseparatorwhite\"></td>";
		sTable += "<td width=\"10\"></td>";
		sTable += "</tr>";
		sTable += "</table>";
		sTable += "</td>";
		sTable += "</tr>";
		sTable += "</table>";
		
		sTable += "</td></tr>";
		sTable += "</table>";
		sTable += "</td></tr>";
		sTable += "</table>";
		return sTable;
	}
	function alertDrawTemporalAlert()
	{
		if (oAlertTemporalLayer == null)
		{
			oAlertTemporalLayer = document.createElement("Div");
		}
		oAlertTemporalLayer.style.zIndex="1";
		oAlertTemporalLayer.style.position="absolute";
		oAlertTemporalLayer.style.background="#FFFFFF";
		oAlertTemporalLayer.appendChild(oAlertLayer);
		oAlertTemporalLayer.style.top = "0";
		oAlertTemporalLayer.style.left = "0";
		oAlertTemporalLayer.style.width = "0";
		oAlertTemporalLayer.style.height = "0";
		oAlertTemporalLayer.style.overflow = "hidden";
		document.getElementById("divAlertDeleteContainer").appendChild(oAlertTemporalLayer);
		return document.getElementById("tblAlert");
	}
	function alertDeleteTemporalAlert()
	{
		document.getElementById("divAlertDeleteContainer").removeChild(oAlertTemporalLayer);
	}
	function alertBuildAlert(sMessage,sTrueButton,sFalseButton,sTitle,sSkinName,sFunctionParm,sOnlyAlert)
	{
		if (alertIE) alertHideShowElements("SELECT","hidden");
		alertHideShowElements("OBJECT","hidden");
		alertBlockAll();
		alertFunctionParameter = sFunctionParm;
		
		alertPreviousTopPosition = alertGetScrollTop();
		alertPreviousLeftPosition = alertGetScrollLeft();
		alertHalfWinHeight = parseInt(alertGetWinHeight() / 2);
		alertHalfWinWidth = parseInt(alertGetWinWidth() / 2);
		var iTop = alertPreviousTopPosition + alertHalfWinHeight;
		var iLeft = alertPreviousLeftPosition + alertHalfWinWidth;
		oAlertLayer = document.createElement("Div");
		oAlertLayer.style.zIndex="10001";
		oAlertLayer.style.position="absolute";
		oAlertLayer.style.background="#FFFFFF";
		oAlertLayer.innerHTML = alertGetAlertTable(sMessage,sTrueButton,sFalseButton,sTitle,sSkinName,sOnlyAlert);
		var oTblAlert = alertDrawTemporalAlert();
		alertHalfBoxHeight = parseInt(oTblAlert.offsetHeight / 2);
		alertHalfBoxWidth = parseInt(oTblAlert.offsetWidth / 2);
		oAlertLayer.style.top = iTop - alertHalfBoxHeight;
		oAlertLayer.style.left = iLeft - alertHalfBoxWidth;
		alertDeleteTemporalAlert();
		document.getElementById("divAlertDeleteContainer").appendChild(oAlertLayer);
		oAlertTrueButton = document.getElementById("btnAlertTrueButton");
		oAlertFalseButton = document.getElementById("btnAlertFalseButton");
		if (oAlertFalseButton) oAlertFalseButton.focus();
		alertScrollTimerId = setTimeout("alertCheckScroll()", 500);
	}
	function alertCheckScroll()
	{
		var iTop = alertGetScrollTop();
		if (alertPreviousTopPosition != iTop)
		{
			oAlertLayer.style.top = iTop + alertHalfWinHeight - alertHalfBoxHeight;
			alertPreviousTopPosition = iTop;
		}
		var iLeft = alertGetScrollLeft();
		if (alertPreviousLeftPosition != iLeft)
		{
			oAlertLayer.style.left = iLeft + alertHalfWinWidth - alertHalfBoxWidth;
			alertPreviousLeftPosition = iLeft;
		}
		clearTimeout(alertScrollTimerId);
		alertScrollTimerId = setTimeout("alertCheckScroll()", 500);
	}
