//====================================================================================================
//	File Name		:	sendmail.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Client side validation in JavaScript.
//	Creation Date	:	11-SEP-2006
//	History			:
//						Date				Author					Remark
//						06-SEP-2006			  --				Initial Release
//
//====================================================================================================

//====================================================================================================
//	Function Name	:	Form_Submit()
//	Purpose			:	This function will executed when user submits a form. It checks validity of
//						every field in the form.
//	Parameters		:	frm  - form name
//	Return			:	true or false
//	Creation Date	:	11-SEP-2006
//----------------------------------------------------------------------------------------------------
function Form_Submit(frm)
{
	with(frm)
	{
		if(!IsEmpty(full_name,"Please Enter Name."))
		{
			return false;
		}

		if(!IsEmpty(phone," Please Enter Phone Number. "))
		{
			return false;
		}

		if(!IsEmpty(email, " Please Enter Email Address."))
		{
			return false;
		}		
		else if(mailcheck(email.value) == false)
		{
			email.focus();
			return false;
		}
		
		if(appointmentpurpose.value == 'Other')
		{
			if(appointmentcomment.value == '')	
			{
				alert("Please Enter Appointment Purpose");
				appointmentcomment.focus();
				return false;
			}
		}
		
		if(fromtime.value == 0)
		{
			alert("Please select From Time");
			fromtime.focus();
			return false;			
		}

		if(totime.value == 0)
		{
			alert("Please select To Time");
			totime.focus();
			return false;			
		}
		
		if(!IsEmpty(appointment_date, " Please Select Appointment Date."))
		{
			return false;
		}	

		return true;
	}
}

function Validate_Feedback(frm)
{
	with(frm)
	{
		if(!IsEmpty(full_name,"Please Enter Name."))
		{
			return false;
		}

		if(!IsEmpty(email, " Please Enter Email Address."))
		{
			return false;
		}		
		if(!IsEmail(email, 'Please Enter Valid Email.'))
		{
			return false;
		}
		if(comment.value == '')
		{
			alert("Please Enter Comment");
			comment.focus();
			return false;
		}
		
		return true;
	}
}

function calendarCallback(date, month, year)
{
	if(month <= 9)
	{ month = '0'+month }
	if(date <= 9)
	{ date = '0'+date }
	date =   date +'/' + month + '/' + year ;
	document.frmAppointment.appointment_date.value = date;
	document.frmAppointment.appointment_date.focus();
}

function Purpose_Change()
{
	with(document.frmAppointment)
	{
		if(appointmentpurpose.value == 'Other')
		{
			purpose.style.display='block';	
		}
		else
		{
			purpose.style.display='none';
		}
	}	
}