/* ============================ /contact.php ============================ */

// Used to validate form in contact.php
function ValidateContactForm() {
	// init vars
	var err = "";
	
	var oName = document.frm.cname;
	var oEmail = document.frm.cemail;
	var oComments = document.frm.ccomments;
	

	if(oName.value == "") { err +="- Name can not be empty\n"; }
	if(oEmail.value=="") { err += "- Email can not be empty\n"; }
	if(oComments.value=="") { err += "- Comments can not be empty\n"; }
	
	if(err.length == 0) {
		// no errors found
		// ensure that email has proper formay
		result = IsValidEmail(oEmail.value);
		if(result) {
			return(true);
		}
		err += "-Email does not have a proper format";
	}
	err = "Errors found in form:\n"+err;
	alert(err);
	return(false);
}

function IsValidEmail(strEmail) {
   if (strEmail == "" || strEmail.indexOf ('@', 1) == -1 || strEmail.indexOf ('.', 3) == -1) 
      return (false);
   else
      return (true);
}