	function checkdate(bdDay, dbMonth, dbYear)
	{
		if(!IsValidDate(bdDay, dbMonth, dbYear)) 
		{
			return false;
		}
		return true;
	}

	function DaysInMonth(CMonth,CYear)
	{
		 var intMonth = parseInt(CMonth);
		 var intYear = parseInt(CYear);
		 if ((intMonth == 4) ||
		  (intMonth == 6) ||
		  (intMonth == 9) ||
		  (intMonth == 11))
		  return 30;
		 if (intMonth==2) {  // Leap year stuff
		  if ((intYear % 400)==0) return 29;
		  if ((intYear % 100)==0) return 28;
		  if ((intYear % 4)==0) return 29;
		  return 28;
		 }
		 return 31;
	}

	function IsDate(CDay, CMonth, CYear)
	{
		if ((CDay <= 0) || (CDay > 31) ||
		(CMonth <= 0) || (CMonth > 12) ||
		(CYear <= 0))
		return false;
		var intDay = parseInt(CDay);
		var intMonth = parseInt(CMonth);
		var intYear = parseInt(CYear);
		if (intDay <= DaysInMonth(intMonth, intYear)) return true;
		return false;
	}

	function IsValidDate(CDay, CMonth, CYear)
	{
		if(!IsDate(CDay, CMonth, CYear)) 
		{
			alert("Please select valid date");
			return false;
		}
		Today = new Date();
		DayBeforeYesterday = new Date((Today.getTime() - 172800000));
		Hours = Today.getHours();
		Minutes = Today.getMinutes()+1;
		Seconds = Today.getSeconds();
		StartDate= new Date(CYear,(CMonth - 1),CDay,Hours,Minutes,Seconds);
		if (StartDate>Today) 
		{ 
			alert("Date must be below current date!");
			return false;
		}
		return true;
	}

	function checkAdmin(mf)
	{
		if(mf.admuserid.value=="")
		{
			alert("Please enter administrator userid");
			mf.admuserid.focus();
			return false;
		}
		if(mf.admuserpass.value=="")
		{
			alert("Please enter administrator password");
			mf.admuserpass.focus();
			return false;
		}
		return true;
	}

	function checkAdminDetails(mf)
	{
		if(mf.admuserid.value=="")
		{
			alert("Please enter administrator userid");
			mf.admuserid.focus();
			return false;
		}
		if(mf.admuserpass.value=="")
		{
			alert("Please enter administrator password");
			mf.admuserpass.focus();
			return false;
		}
		if(mf.admcuserpass.value!=mf.admuserpass.value)
		{
			alert("Passwords not matching. Please re-enter your password");
			mf.admcuserpass.focus();
			return false;
		}
		return true;
	}

	function checkEmail(myForm)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value))
		{
			return (true);
		}
		alert("Invalid e-mail address! please re-enter");
		return (false);
	}


	function trim(inputString) 
	{
		if (typeof inputString != "string") { return inputString; }
		var retValue = inputString;
		var ch = retValue.substring(0, 1);
		while (ch == " ") 
		{ 
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		while (ch == " ") 
		{
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
		}
		while (retValue.indexOf("  ") != -1) 
		{ 
			retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
		}
		return retValue; 
	}

	function checkPhotoGallery(mf)
	{
		if(mf.categoryid.value=="")
		{
			alert("Please select category");
			mf.categoryid.focus();
			return false;
		}
		if(mf.image_upload.value=="")
		{
			alert("Please select photo");
			mf.image_upload.focus();
			return false;
		}
		return true;
	}

	function checkCode(mf)
	{
		if(mf.name.value=="")
		{
			alert("Please enter name");
			mf.name.focus();
			return false;
		}
		if(trim(mf.email.value)=="")
		{ 
			alert("Please enter your e-mail address");
			mf.email.focus();
			return false;
		}
		if(checkEmail(mf)==false)
		{
			mf.email.focus();
			return false; 
		}
		if(mf.usercode.value=="")
		{
			alert("Please enter code for user");
			mf.usercode.focus();
			return false;
		}
		if(isNaN(mf.usercode.value))
		{
			alert("Please enter code for user in numbers only");
			mf.usercode.focus();
			return false;
		}
		return true;
	}

	function checkUserCode(mf)
	{
		if(mf.usercode.value=="")
		{
			alert("Please enter code for user");
			mf.usercode.focus();
			return false;
		}
		if(isNaN(mf.usercode.value))
		{
			alert("Please enter code in number only");
			mf.usercode.focus();
			return false;
		}
	}

	function checkUserPhotoGallery(mf)
	{
		if(mf.userid.value=="")
		{
			alert("Please select user");
			mf.userid.focus();
			return false;
		}
		if(mf.image_upload.value=="")
		{
			alert("Please select photo");
			mf.image_upload.focus();
			return false;
		}
		return true;
	}



