
function Alert()
{
	function Type()
	{
		this.Container = "";
		this.Header = "";
		this.Icon = null;
	}
	var divMain,divBlocker,divContainer,divHeader,imgIcon,btnOk,spnMessage;
	var clientIE6 = false,added = false;
	var errorType,warnType,confirmType;
	
	this.init = function(ie6,header,errorIconUrl,warnIconUrl,confirmIconUrl)
	{
		clientIE6 = ie6;
		if(!clientIE6)
		{
			divMain = document.createElement("DIV");
			divMain.id = "divAlertMain";
			divMain.style.position = "absolute";
			divMain.style.left = "33%";
			divMain.style.width = "34%";
			divMain.style.backgroundColor = "#fff";
			divMain.style.padding = "1px 1px 1px 1px";
			divMain.style.zIndex = 7001;
			divMain.style.display = "none";
			divContainer = document.createElement("DIV");
			divContainer.id = "divAlertContainer";
			divHeader = document.createElement("DIV");
			divHeader.id = "divAlertHeader";
			write(divHeader,header);
			divContainer.appendChild(divHeader);
			var div1 = document.createElement("DIV");
			div1.id = "divAlert1";
			div1.style.padding = "10px 20px 2px 10px";
			var tbl = document.createElement("TABLE");
			tbl.id = "tblAlert1";
			tbl.cellSpacing = tbl.cellPadding = 0;
			tbl.style.width = "100%";
			var row1 = tbl.insertRow(-1);
			var cell1 = row1.insertCell(-1);
			cell1.id = "tdAlertCell1";
			cell1.style.width = "60px";
			cell1.style.textAlign = "center";
			cell1.vAlign = "top";
			imgIcon = document.createElement("IMG");
			imgIcon.id = "imgAlertIcon";
			cell1.appendChild(imgIcon);
			var cell2 = row1.insertCell(-1);
			cell2.id = "tdAlertCell2";
			spnMessage = document.createElement("SPAN");
			spnMessage.id = "spnAlertMessage";
			spnMessage.style.color = "#667";
			cell2.appendChild(spnMessage);
			div1.appendChild(tbl);
			divContainer.appendChild(div1);
			var div2 = document.createElement("DIV");
			div2.id = "divAlert2";
			div2.style.padding = "10px 10px 10px 10px";
			div2.style.textAlign = "center";
			btnOk = document.createElement("INPUT");
			btnOk.id = "divAlert2";
			btnOk.type = "button";
			btnOk.value = "OK";
			btnOk.style.width = "80px";
			div2.appendChild(btnOk);
			divContainer.appendChild(div2);
			divMain.appendChild(divContainer);
			divBlocker = document.createElement("DIV");
			divBlocker.id = "divAlertBlocker";
			divBlocker.style.position = "fixed";
			divBlocker.style.left = "0px";
			divBlocker.style.top = "0px";
			divBlocker.style.width = "100%";
			divBlocker.style.height = "100%";
			divBlocker.style.overflow = "auto";
			divBlocker.style.backgroundColor = "#000";
			divBlocker.style.opacity = divBlocker.style.mozOpacity = 0.4;
			divBlocker.style.filter = "alpha(opacity=40)";
			divBlocker.style.zIndex = 6999;
			divBlocker.style.display = "none";
			var errorIcon = document.createElement("IMG");
			errorIcon.src = errorIconUrl;
			var warnIcon = document.createElement("IMG");
			warnIcon.src = warnIconUrl;
			var confirmIcon = document.createElement("IMG");
			confirmIcon.src = confirmIconUrl;
			errorType = new Type();
			errorType.Container = "border:solid #dc4903 1px;background-color:#fdf;";
			errorType.Header = "background-color:#dc4903;font-weight:bold;color:#fff;padding-left:10px;margin-bottom:10px;height:20px;";
			errorType.Icon = errorIcon;
			warnType = new Type();
			warnType.Container = "border:solid #f4c400 1px;background-color:#ffc;";
			warnType.Header = "background-color:#f4c400;font-weight:bold;color:#fff;padding-left:10px;margin-bottom:10px;height:20px;";
			warnType.Icon = warnIcon;
			confirmType = new Type();
			confirmType.Container = "border:solid #79a567 1px;background-color:#dceccc;";
			confirmType.Header = "background-color:#79a567;font-weight:bold;color:#fff;padding-left:10px;margin-bottom:10px;height:20px;";
			confirmType.Icon = confirmIcon;
		}
	}
	this.error = function(message)
	{
		display(errorType,message);
		this.block();
	}
	this.warn = function(message)
	{
		display(warnType,message);
		this.block();
	}
	this.confirm = function(message)
	{
		display(confirmType,message);
		this.block();
	}
	this.block = function()
	{
		if(!clientIE6)
		{
			add();
			divBlocker.style.display = "";
		}
	}
	this.unblock = function(){if(!clientIE6)divBlocker.style.display = "none";}
	
	var display = function(type,message)
	{
		if(clientIE6)
		{
			message = message.replace("<ul>","").replace("</ul>","");
			var mm = message.split("<li>");
			if(mm.length > 0)
			{
				message = "";
				for(var i in mm)message += "\n"+mm[i].replace("</li>","");
			}
			alert(message);
			return;
		}
		add();
		divContainer.style.cssText = type.Container;
		divHeader.style.cssText = type.Header;
		spnMessage.innerHTML = message;
		imgIcon.src = type.Icon.src;
		var coords = getClientCenter();
		divMain.style.top = coords.y - 60 + "px";
		divMain.style.display = "";
	}
	var add = function()
	{
		if(!added)
		{
			document.body.appendChild(divMain);
			document.body.appendChild(divBlocker);
			btnOk.onclick = function(e){divMain.style.display = divBlocker.style.display = "none";}
			added = true;
		}
	}
}