function closeAlert()
{
	var oBgDiv = document.getElementById("alertBoxBg");
	var oFgDiv = document.getElementById("alertBox");
	var oTextDiv = document.getElementById("alertText");

	document.body.removeChild( oBgDiv );
	document.body.removeChild( oFgDiv );
	document.body.removeChild( oTextDiv );

}


function _alert( sMessage )
{
	var	oTextDiv;
	var	oBgDiv;
	var oFgDiv;
	var	nTop, nLeft, nWidth, nHeight, nBorderWidth;
	var	sBackgroundColor, sColor, sBorderColor, sButtonColor, sButtonTextColor;
	var nButtonWidth, nButtonHeight;
	var sStyle;

	nWidth 			= 400;
	nHeight 		= 190;
	nTop			= 65;
	nLeft			= (document.body.clientWidth - nWidth) / 2;
	nBorderWidth	= 3
	
	sColor				= "#FFFFFF";
	sBorderColor		= "#CCCCCC";
	sBackgroundColor	= "#777777";
	sButtonColor		= "#CCCCCC";
	sButtonTextColor	= "#000000";
	nButtonWidth		= 50;
	nButtonHeight		= 23;

	if (!document.getElementById("alertBoxBg"))
	{

		oBgDiv = document.createElement("div");
		oFgDiv = document.createElement("div");
		oTextDiv = document.createElement("div");
		
		
		oBgDiv.id = "alertBoxBg";
		
		oBgDiv.style.position			= "absolute";
		oBgDiv.style.display			= "block";
		oBgDiv.style.color				= sBorderColor;
		oBgDiv.style.backgroundColor	= sBorderColor;
		oBgDiv.style.zIndex 			= 1000;
		oBgDiv.style.margin 			= "0px auto";
		oBgDiv.style.width 				= nWidth + "px";
		oBgDiv.style.height 			= nHeight + "px";
		oBgDiv.style.top 				= nTop + "px";
		oBgDiv.style.left				= nLeft + "px";
		
		oFgDiv.id = "alertBox";
		
		
		oFgDiv.style.position			= "absolute";
		oFgDiv.style.display			= "block";
		oFgDiv.style.color				= sColor;
		oFgDiv.style.backgroundColor	= sBackgroundColor;
		oFgDiv.style.zIndex 			= 1001;
		oFgDiv.style.margin 			= "0px auto";
		oFgDiv.style.width 				= nWidth - (2 * nBorderWidth) + "px";
		oFgDiv.style.height 			= nHeight - (2 * nBorderWidth) + "px";
		oFgDiv.style.top 				= nTop + nBorderWidth + "px";
		oFgDiv.style.left				= nLeft + nBorderWidth + "px";
	
	
		oTextDiv.id = "alertText";
		
		oTextDiv.setAttribute("align","center");
		
		oTextDiv.style.position			= "absolute";
		oTextDiv.style.display			= "block";
		oTextDiv.style.color				= sColor;
		oTextDiv.style.backgroundColor	= sBackgroundColor;
		oTextDiv.style.zIndex 			= 1002;
		oTextDiv.style.paddingTop		= "0px";
		oTextDiv.style.paddingLeft		= "0px";
		oTextDiv.style.paddingRight		= "0px";
		oTextDiv.style.margin 			= "0px auto";
		oTextDiv.style.overflow			= "auto";
		oTextDiv.style.width 			= nWidth - (2 * nBorderWidth) - 14 + "px";
		oTextDiv.style.height 			= nHeight - (2 * nBorderWidth) - 51 + "px";
		oTextDiv.style.top 				= nTop + nBorderWidth + 11 + "px";
		oTextDiv.style.left				= nLeft + nBorderWidth + 7 + "px";
	
		document.body.appendChild( oBgDiv );
		document.body.appendChild( oFgDiv );
		document.body.appendChild( oTextDiv );
	}
	else
	{
		oFgDiv = document.getElementById("alertBox")
		oTextDiv = document.getElementById("alertText")
	}		

	sStyle = "position:absolute;color:" + sButtonTextColor + ";background-color:" + sButtonColor + ";z-index:1003;";
	sStyle = sStyle + "width:" + nButtonWidth + "px;height:" + nButtonHeight + "px;";
	sStyle = sStyle + "top:" + (nHeight - nButtonHeight - 15) + "px;";
	sStyle = sStyle + "left:" + (((nWidth - nButtonWidth) / 2)) + "px;";

	oFgDiv.innerHTML 	= "<button onclick='closeAlert();' style='" + sStyle + "'>OK</button>";
	oTextDiv.innerHTML 	= sMessage;

}


function hideControl( sID )
{
	document.getElementById( "__control_" + sID ).style.display	= 'none';
}


function showControl( sID )
{
	document.getElementById( "__control_" + sID ).style.display	= 'block';
}


function isControlHidden( sID )
{

	return document.getElementById( "__control_" + sID ).style.display == 'none'
}

function hideElement( id )
	{

	if (document.getElementById)
    { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else
	{
		if (document.layers)
		{ // Netscape 4
			document.id.display = 'none';
		}
		else
		{ // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showElement( id )
{
	if (document.getElementById)
    { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else
	{
		if (document.layers) 
		{ // Netscape 4
			document.id.display = 'block';
		}
		else 
		{ // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


function onlyNumbers(e)
{
	var keynum;
	var keychar;
	var numcheck;
	var lOK;

	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}

	if (keynum == 8 || keynum == 46 || (keynum > 95 && keynum < 106))
	{
		lOK = true;
	}
	else
	{
		keychar = String.fromCharCode(keynum);
		numcheck = /\d/;
		lOK = numcheck.test( keychar );
	}


	return lOK;

}


function setElementClass( sElementID, sClassname )
	{
		var oElement;
		oElement = document.getElementById( sElementID );
        oElement.className = sClassname;
	}



function isIE()
{
	return (navigator.appName == "Microsoft Internet Explorer");
}



function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return ((( year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0)) ) ? 29 : 28 );
}

function DaysArray(n)
{
	var i;

	for (var i = 1; i <= n; i++)
	{
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11)
			{this[i] = 30}
		if (i==2)
		 	{this[i] = 29}
	} 
   	return this
}

function isShortDate(dtStr)
{
	var daysInMonth;
	var strDay;
	var strMonth;
	var strYear;
	var day;
	var month;
	var year;


	if (dtStr.length < 6)
	{
		return false;
	}

	strDay		= dtStr.substring(0,2);
	strMonth	= dtStr.substring(2,4);
	strYear		= dtStr.substring(4,6);

	month	= parseInt(strMonth,10);
	day		= parseInt(strDay,10);
	year	= parseInt(strYear,10);

	if (month == NaN || month < 1 || month > 12)
	{
		return false;
	}

	daysInMonth = DaysArray(12);

	if (day == NaN || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year) ) || day > daysInMonth[month] )
	{
		return false;
	}

	if (year == NaN)
	{
		return false;
	}

	return true;
}




