// {IE:6685} SoM LV 28-04-2008
function js_date_ddMMyy(id)
{
		var strCheckDate =document.getElementById(id).value;
		var result=true;
		var intIndex=-1;
		var arrDate;
		var regExpInfo="/";
		
		//blank field
		if (strCheckDate == "")
		{
			result=true;
		}
		//longer than 8
		else if (strCheckDate.length !=8)
		{
			result=false;
		}
		else
		{	
			intIndex=strCheckDate.search(regExpInfo);
			if (intIndex == -1)
			{
				result=false;
			}
			else
			{
				arrDate =  new Array(strCheckDate);
				arrDate = strCheckDate.split("/"); 
				if (arrDate.length != 3)
				{
					result=false;
				}
				else
				{
					//check year
					if ( fnIsIntNum(arrDate[2]))
					{
						if (parseInt(arrDate[2], 10) < 1 || parseInt(arrDate[2], 10) > 99) 
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
					//check month
					if ( fnIsIntNum(arrDate[1]))
					{
						if (parseInt(arrDate[1],10) < 1 || parseInt(arrDate[1],10) > 12)
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
					//check day
					if ( fnIsIntNum(arrDate))
					{
						var intDayCount = fnComputerDay(parseInt(arrDate[2], 10),parseInt(arrDate[1], 10));
						if(intDayCount < parseInt(arrDate[0], 10))
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
				}
			}
		}
		if (result==false)
		{
			document.getElementById(id).style.backgroundColor = "#FFCCFF";
			alert("Error: The field must only contain date with the format of DD/MM/YY");
                        document.getElementById(id).focus();
		}
		else
		{
			document.getElementById(id).style.backgroundColor = "white";
		}
		return result;
		
}


function js_date_ddMMyyyy(id)
{
		var strCheckDate =document.getElementById(id).value;
		var result=true;
		var intIndex=-1;
		var arrDate;
		var regExpInfo="/";
		
		//blank field
		if (strCheckDate == "")
		{
			result=true;
		}
		//if not length of 10
		else if (strCheckDate.length !=10)
		{
			result=false;
		}
		else
		{	
			intIndex=strCheckDate.search(regExpInfo);
			if (intIndex == -1)
			{
				result=false;
			}
			else
			{
				arrDate =  new Array(strCheckDate);
				arrDate = strCheckDate.split("/"); 
				if (arrDate.length != 3)
				{
					result=false;
				}
				else
				{
					//check year
					if ( fnIsIntNum(arrDate[2]))
					{
						if (parseInt(arrDate[2], 10) < 2000) 
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
					//check month
					if ( fnIsIntNum(arrDate[1]))
					{
						if (parseInt(arrDate[1],10) < 1 || parseInt(arrDate[1],10) > 12)
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
					//check day
					if ( fnIsIntNum(arrDate))
					{
						var intDayCount = fnComputerDay(parseInt(arrDate[2], 10),parseInt(arrDate[1], 10));
						if(intDayCount < parseInt(arrDate[0], 10))
						{
							result = false;
						} 
					}
					else
					{
						result=false;
					}
				}
			}
		}
		if (result==false)
		{
			document.getElementById(id).style.backgroundColor = "#FFCCFF";
			alert("Error: The field must only contain date with the format of DD/MM/YYYY\nYear must be greater than 2000.");
                        document.getElementById(id).focus();
		}
		else
		{
			document.getElementById(id).style.backgroundColor = "white";
		}
		return result;
		
}



// {IE:6685} EoM LV 28-04-2008

function fnIsIntNum(strNum)
{
	var strCheckNum = strNum + "";
	//if(strCheckNum.length < 1) //blank field
	//	return false;
	//else if(isNaN(strCheckNum)) //not number
	//	return false;
	//else if(parseInt(strCheckNum, 10) < 1) //not positive
	//	return false; 
	//else if(parseFloat(strCheckNum) > parseInt(strCheckNum, 10)) //not int
	//	return false;

	return true;
}

function fnComputerDay(intYear,intMonth)
{
	var dtmDate = new Date(intYear,intMonth,-1);
	var intDay = dtmDate.getDate() + 1;
	return intDay; 
}



