
// ************ New Alert: with Filter/Opacity ************
	var alertIE = (navigator.appName.indexOf("Microsoft") != -1);

	if (typeof(alertDefaultSkinName) == "undefined")
		alertDefaultSkinName = "Blue";
		
	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 alertDisplayShowElements(sTagName,sStatus)
	{
		var aElm = document.getElementsByTagName(sTagName);
		var oElm = null;
		for (i=0; i<aElm.length; i++)
		{
			oElm = aElm[i];
			oElm.style.display = sStatus;
		}
	}
	
	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");			
			// Filter/Opacity
			// We assign an Id to be able to reference it and set the Filter/Opacity
			oAlertBlockingLayer.id = "divAlertBlockingLayer";
		}
		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);
		}
		
		// ******* Removing Filter/Opacity *********** //
		if ( document.getElementById( "divBodyPage") )
		{
			document.getElementById( "divBodyPage" ).style.filter = '';
			document.getElementById( "divBodyPage" ).style.opacity = "";
		}
	}
	
	function alertGetAlertTable(sMessage,sTrueButton,sFalseButton,sTitle,sSkinName,sOnlyAlert)
	{
		/* This code was modified to be able to capture the present URL and to indicate as folders contain the icons */
		var thisURL=window.location.href;
		
		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\" width='100%'>";
		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\">";
		
		if (thisURL.toLowerCase().indexOf("website")>0)
			sTable += "<a href=\"javascript:alertCloseAlert(false);\"><img src=\"../Mgmt/Icons/CloseIcon.gif\" border=\"0\"></a>";
		else
			sTable += "<a href=\"javascript:alertCloseAlert(false);\"><img src=\"../Icons/CloseIcon.gif\" border=\"0\"></a>";
		sTable += "</td></tr>";
		sTable += "</table>";
		
		sTable += "</td></tr>";
		sTable += "<tr><td align=\"right\" width='100%'>";
		
		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\">";
		if (thisURL.toLowerCase().indexOf("website")>0)
			sTable += "<img src=\"../Mgmt/Icons/AlertIcon.gif\" border=\"0\">";
		else
			sTable += "<img src=\"../Icons/AlertIcon.gif\" border=\"0\">";
		sTable += "</td><td width=\"1\"></td><td align=\"left\" width='100%'>";
		if ( alertIE )
			sTable += "<div>";
		else
			sTable += "<div style='border: solid 1px Transparent; width:100%'>";
		sTable += sMessage ? sMessage.replace(/\n/g,"<br>") : alertDefaultText;
		sTable += "</div></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\">";
			if (thisURL.toLowerCase().indexOf("website")>0)
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(true);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertTrueButton\"><img align=\"absmiddle\" src=\"../Mgmt/Icons/Aproved.gif\">&nbsp;&nbsp;" + (sTrueButton ? sTrueButton : alertDefaultTrueButtonText) + "</a>&nbsp;&nbsp;"
			else
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(true);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertTrueButton\"><img align=\"absmiddle\" src=\"../Icons/Aproved.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 )
		{
			if (thisURL.toLowerCase().indexOf("website")>0)
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Mgmt/Icons/Desaproved.gif\" border=\"0\">&nbsp;&nbsp;" + (sFalseButton ? sFalseButton : alertDefaultFalseButtonText) + "</a>&nbsp;&nbsp;";
			else
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Icons/Desaproved.gif\" border=\"0\">&nbsp;&nbsp;" + (sFalseButton ? sFalseButton : alertDefaultFalseButtonText) + "</a>&nbsp;&nbsp;";
		}
		else
		{
			if (thisURL.toLowerCase().indexOf("website")>0)
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Mgmt/Icons/Aproved.gif\" border=\"0\">&nbsp;&nbsp;" + (sFalseButton ? sFalseButton : sOnlyAlert) + "</a>&nbsp;&nbsp;";
			else
				sTable += "<a class=\"imagebutton\" href=\"javascript:alertCloseAlert(false);\" onblur=\"javascript:alertKeepFocus(this);\" id=\"btnAlertFalseButton\"><img align=\"absmiddle\" src=\"../Icons/Aproved.gif\" border=\"0\">&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 the div for Alert does not exist we create it and add it to the body
		if ( !document.getElementById( "divAlertDeleteContainer") )
		{
			var divAlert = document.createElement( "div" );
			divAlert.id = "divAlertDeleteContainer";
			document.body.appendChild( divAlert );
		}
		
		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(oAlertLayer.offsetHeight / 2);
		alertHalfBoxWidth = parseInt(oAlertLayer.offsetWidth / 2);
				
		oAlertLayer.style.top = iTop - alertHalfBoxHeight;
		oAlertLayer.style.left = iLeft - alertHalfBoxWidth;
		oAlertLayer.style.top = -1000;
		oAlertLayer.style.left = -1000;

		alertDeleteTemporalAlert();
		document.getElementById("divAlertDeleteContainer").appendChild(oAlertLayer);
		oAlertTrueButton = document.getElementById("btnAlertTrueButton");
		oAlertFalseButton = document.getElementById("btnAlertFalseButton");
		
		if (oAlertFalseButton) 
			oAlertFalseButton.focus();
			
		alertScrollTimerId = setTimeout("alertCheckScroll()", 500);
		
		alertHalfBoxHeight = parseInt(oAlertLayer.offsetHeight / 2);
		alertHalfBoxWidth = parseInt(oAlertLayer.offsetWidth / 2);
		oAlertLayer.style.top = iTop - alertHalfBoxHeight;
		oAlertLayer.style.left = iLeft - alertHalfBoxWidth;
		
		if ( parseInt(oAlertLayer.style.left) < 0 ) 
			oAlertLayer.style.left = 0;
		
		// If divBodyPage exist, then we set the Filter/Opacity for the entire page
		if ( document.getElementById( "divBodyPage") )
		{
			if ( alertIE )
			{
				document.getElementById( "divAlertBlockingLayer" ).style.background = "silver";
				document.getElementById( "divAlertBlockingLayer" ).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
				
			}
			else
			{
				document.getElementById( "divBodyPage" ).style.opacity = ".40";
			}
		}
	}
	
	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);
	}