function trim(str)
{
	var strlen = str.length;
	for (var i=strlen-1; i>=0; i--)
	{
		 if ((str.substring(i,i+1) <= " "))
		 { 
		 	str = str.substring(0,i); 
		 }
		 else {
		 	break;
		 }
	}
	return str;
}

function isBlank(objname, obj)
{
	
	if (trim(obj.value) == "")
	{
		return "- " + objname + "\n";		
	}
	else
	{
		return "";
	}
}

function isCheckedForRadio(objname, obj)
{
	flag = false;
	
	if (obj.length > 1)
	{
		for (i=0; i<obj.length; i++)
			if (obj[i].checked)
				flag = true;
	}
	else
	{
		if (obj.checked)
			flag = true;
	}		
	
	if (!flag)
	{
		return "- " + objname + "\n";
	}
	else
	{
		return "";
	}
}

function isSelected(objname, obj)
{
	if (obj.options[obj.selectedIndex].value == "")
	{
		return "- " + objname + "\n";
	}
	else
	{
		return "";
	}
}

function chkEmail(objname, obj)
{
	var pos1, pos2;
	var theLen = obj.value.length;

	pos1 = obj.value.indexOf("@");
	pos2 = obj.value.indexOf(".");

	if ((pos1 > 0) && (pos2 > 0))
	{
		if (pos2 < theLen - 1)
		{
			return "";
		}
	}
	return "- " + objname + "\n";
}

function chkLength(msg, obj, max, min) {
	if (obj.value.length >= min || obj.value.length <= max) {
		return "";
	}
	return "- " + msg + "\n";
}	

function chkMatch(msg, obj1, obj2) {
	if (trim(obj1.value) == trim(obj2.value)) {
		return "";
	}
	return "- " + msg + "\n";
}

function chkdate(objname, YY, MM, DD) 
{
	MM = MM - 1
	var theDate = new Date(YY, MM, DD)
	// return value of function getYear() is different from IE and Netscape
	// IE will return 4 digits (e.g., 1999, 2000 .... )
	// the return value in Netscape (e.g. 99, 100 ....)
	theYY = theDate.getYear()>1900?theDate.getYear():theDate.getYear()+1900
	theMM = theDate.getMonth()
	theDD = theDate.getDate()

	if (MM == theMM && DD == theDD)
	{
		return "";
	}
	else
	{
		return "- " + objname + "\n";
	}
}
