
/*
* Is Form validate?
*/
function _CF_onError(form_object, input_object, object_value, error_message)
{
	alert(error_message);	// to display a error message.
	input_object.focus();
	return false;	
}

function _CF_hasValue(obj, obj_type)
{
	if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
		if (obj.value.length == 0) 
			return false;
		else 
			return true;
	}
	else 
		if (obj_type == "SELECT")		// list box
		{
			if (obj.options[obj.selectedIndex].value == "")
				return false;
			else
				return true;
		}
		else 
			if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
			{
				if (obj.checked)
					return true;
				else
					return false;	
			}
			else 
				if (obj_type == "RADIO" || obj_type == "CHECKBOX")
				{
					for (i=0; i < obj.length; i++)
					{
						if (obj[i].checked)
							return true;
					}
					return false;	
				}
}


function  _CF_checkValidForm_ContactUs(_CF_this)
{
	if  (!_CF_hasValue(_CF_this.fullname, "TEXT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.fullname, _CF_this.fullname.value, "Full name must not be left blank."))
		{
			return false; 
		}
	}
	
	if  (!_CF_hasValue(_CF_this.email, "TEXT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "Email must not be left blank."))
		{
			return false; 
		}
	}
	
	if  (!_CF_hasValue(_CF_this.phone, "TEXT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.phone, _CF_this.phone.value, "Phone must not be left blank."))
		{
			return false; 
		}
	}

	if  (!_CF_hasValue(_CF_this.subject, "SELECT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.subject, _CF_this.subject.value, "Please select at least one subject."))
		{
			return false; 
		}
	}
	if  (!_CF_hasValue(_CF_this.inquiry, "TEXT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.inquiry, _CF_this.inquiry.value, "Inquiry must not be left blank."))
		{
			return false; 
		}
	}

	return true;
}
