// JavaScript Document
function IsEmpty( inputStr ) 
	{
		if ( null == inputStr || "" == inputStr ) 
			{ 
				return true; 
			} 
			else
			{
				return false; 
			}
	}

function ValidateForm(form) 
	{
		
		var errmsg = "";
		var newline = "\n";
		var txtFocusControlName = "";
		var Ok = true;
		if(IsEmpty(form.name.value))
		   {
		   	  errmsg = errmsg + ">>Contact name required.";
		      if (txtFocusControlName=="") txtFocusControlName = 'name';
		      Ok  = false ;
		   }
		
		if(IsEmpty(form.email.value))
			{
				errmsg = errmsg + newline + ">>Email address cannot be blank.";
				if (txtFocusControlName =="") txtFocusControlName = 'email';
				Ok  = false ;
			}
			else 
			{
				if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)))
			   		{
				 		errmsg = errmsg + newline + ">>Not a valid email address.";
		      			if (txtFocusControlName =="") txtFocusControlName = 'email';
		      			Ok  = false ;
		     		}
			}

		if(IsEmpty(form.residence.value))
		   {
				errmsg = errmsg + newline + ">>Country of residence required.";
				if (txtFocusControlName=="") txtFocusControlName = 'residence';
				Ok  = false ;
		   }
	
		if(IsEmpty(form.enquiry.value))
		   {
				errmsg = errmsg + newline + ">>Please state the nature of the enquiry.";
				if (txtFocusControlName=="") txtFocusControlName = 'enquiry';
				Ok  = false ;
		   }
		if (Ok) return(true) ;
		alert(errmsg ) ;
		document.getElementById(txtFocusControlName).focus();
		return false;
	}
