
function isEmpty(theField)
{
	//Precondition: theField must be field
	//postcondition: return true if the value of theField is empty
	//               Otherwise, return false
	//Need LTrim()
	
	var flag = false;			//return value
	var str = theField.value;	//for string
	str = LTrim(str);	//remove spaces in front of the first non-space character.
	
	if (str.length < 1)
	{
		flag = true;
	}

	return flag;
}

function LTrim(str)
{
	//Pre-condition: str must be string type
	//Post-condition: remove the leftmost spaces
	
	var c;		//for charcter in string
	var retStr;	//return value
	var len;		//length of string
	var i;		//counter for "for" loop
	len = str.length;	//set lenght of string
	retStr = "";		//Initialize return value
	
	//you do not need trimming
	if (len < 1)
	{
		return retStr;
	}

	//find out the position of the first non-space character
	for (i = 0; i < len; i++)
	{
		c = str.charAt(i);	
		if (c != " ")	// if the current char is not space, exist loop
		{
			break;
		}
	}
	//i must be less than lenght of string
	//if i == len, there is no non-space characters in string
	if (i < len)
	{
		retStr = str.substring(i,len);	
	}
	
	return retStr;
}

function checkDate(strDate)
{
	//Precondition: strDate must be string
	//postcondition: return true if the value of strDate is valid date fromat
	//               Otherwise, return false
	
	var isDate = true;
	var len = strDate.length;
	var slash = strDate.charAt(2);	//second char
	var mm = strDate.substring(0,2); //from 0th char to 1th char
	var yy = strDate.substring(3,5); //from 3rd char to 4th char
	var mmyy = mm + yy;
	
	if (len != 5 || slash != "/" || isNaN(mmyy) == true )
	{
		isDate = false;
	}

	return isDate;
}
