function isBlank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != " ") && (c != "\n") && (c != "\t")) return false;
	}
	return true;
}

function checkForm (contactForm) {
  errorFound = false;
  msg  = "\n";
  msg += "Error(s) in contact form:\n\n";
  
  if ((contactForm.name.value=="")||(isBlank(contactForm.name.value))) {
	msg += "Please fill in your name\n";
	errorFound = true;
  }
  if ((contactForm.email.value=="")||(isBlank(contactForm.email.value))) {
	msg += "Please fill in your email address\n";
	errorFound = true;
  } else {
	  fitem = contactForm.email;
	  
	  // Verify email address
	  //
	  if ((fitem.value != "")&&(!isBlank(fitem.value))) {
		// Verify email address content
		//
		atPos = fitem.value.indexOf("@");
		dotPos = fitem.value.indexOf(".",atPos);
		if ((atPos < 1)||(dotPos-atPos < 2)) {
		  msg += "Email address invalid\n";
		  fitem.focus();
		  fitem.select();
		  errorFound = true;
		}
	  }

  }
  
  if ((contactForm.message.value=="")||(isBlank(contactForm.message.value))) {
	msg += "Please fill in a message\n";
	errorFound = true;
  }
  
  if (errorFound){
	alert (msg);
	return false;
  }
  return true;
}


function SH( me, id ) {
	var you = document.getElementById( id );
	if( me.innerHTML == "Hide contact form" ) {
		me.innerHTML = "Contact form";
		you.style.display = "none";
	} else {
		me.innerHTML = "Hide contact form";
		you.style.display = "block";
	}
}


