var Message="";
var MouseY;

if(document.getElementById) {
	window.alert = function(alertText) {
			customAIAAlert(alertText);
	}
}

function customAIAAlert(alertText) {
	var docHeight = document.body.offsetHeight;
	var docWidth = document.body.offsetWidth;
	var selectBoxes = document.getElementsByTagName("select");
	for(var i=0;i<selectBoxes.length;i++){
		selectBoxes[i].disabled=true;
	}	
	var FadedBackground = Builder.node("div",{id:"FadedBackground",style:"height:" + docHeight + "px; width:" + docWidth + "px;"});
	Message = alertText;
	$("outer").appendChild(FadedBackground);
	showPopupAlertWindow();


}

function showPopupAlertWindow(){
	var AlertTop = "<div id=\"alertBoxContent\"><div id=\"alertBoxTop\"></div><div id=\"alertBoxInner\">";
	var AlertBottom = "</div><div id=\"alertBoxBottom\"></div></div><div id=\"alertBoxClose\"><a href=\"Javascript:;\" onclick=\"Javascript:closeAIAAlert();\"><img src=\"/stellent/groups/aia/documents/image/alert_btn_close.gif\" width=\"49\" height=\"13\" alt=\"Close\"/></a></div>";
	var alertBox = Builder.node("div",{id:"alertBox"});
	alertBox.style.top = getWindowCenterTop()+250 + "px";
	alertBox.style.left = getWindowCenterLeft()-200 + "px";
	alertBox.innerHTML = AlertTop + Message + AlertBottom;
	$("FadedBackground").appendChild(alertBox);
}

function closeAIAAlert(){
	var selectBoxes = document.getElementsByTagName("select");
	for(var i=0;i<selectBoxes.length;i++){
		selectBoxes[i].disabled=false;
	}
	$("FadedBackground").remove();
}

function getWindowCenterLeft(){
	return document.documentElement.offsetWidth /2

}

function getWindowCenterTop() {
	var x,y;

	if (self.pageYOffset) {
		// all except Explorer
		x = self.pageXOffset;
		y = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		// Explorer 6 Strict
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	} else if (document.body) {
		// all other Explorers
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	
	return y;
}
		