var ua = window.navigator.userAgent.toLowerCase();
var is_Mozilla	= (ua.indexOf("netscape")>=0 || ua.indexOf("firefox")>=0 );
var is_IE55		= (ua.indexOf("msie 5.5")>=0);
var is_IE		= (ua.indexOf("msie 6.0")>=0) || is_IE55;

function ValidateNumeric( e )
{
	var hr;
	if( is_IE )
		var code = e.keyCode;
	else
		var code = e.which;

	if( code == 8 || code==0 )
		hr = true;
	else if ( code < 48 || code > 57 )
		hr = false;

	return hr;
}

	
function ValidateEmpty( sObjID, sObjName )
{
	var o = window.document.getElementById(sObjID);
	if( o.value.length==0 )
	{
		window.alert( sObjName + " cannot be blank." );
		o.focus();
		return false;
	}
	return true;
}

function ValidateDate( sMMID, sDDID, sObjName, iDD, iMM, iYY )
{
	var asMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December")

	// Validate month
	if( iMM<1|| iMM>12 )
	{
		window.alert( sObjName + " must include a valid month (1 through 12)." );
		window.document.getElementById(sMMID).focus();
		return false;
	}

	// Validate day
	iMM--;
	var iMaxDay = GetDaysInMonth(iYY, iMM);
	if( iDD==0 || iDD>GetDaysInMonth(iYY, iMM) )
	{
		window.alert( sObjName + " must include a valid day for " + asMonths[iMM]+ ", " + iYY + " (1 through " + iMaxDay + ")." );
		window.document.getElementById(sDDID).focus();
		return false;
	}
	return true;
}

function GetDaysInMonth(iYear, iMonth)
{
	var dtMonth;
	var i;

	for( i=28; i<=32; ++i )
	{
		dtMonth = new Date(iYear, iMonth, i);
		if( dtMonth.getDate() == 1 )
			break;
	}
	return i - 1;
}

