function trim(s) 
  {
	while(s.substring(0,1) == ' ') 
	{
		s = s.substring(1,s.length);
	}
	
	while(s.substring(s.length-1,s.length) == ' ') 
	{
		s = s.substring(0,s.length-1);
	}
	
	return s;
  }	
  
  function isValidEmail(S)
  {
	return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(S);
  }
  
  function validateForm()
  {
  	var fn = document.getElementById('fn')
  	var sj = document.getElementById('sj')
  	var em = document.getElementById('em')
  	var ms = document.getElementById('ms')
  	var sc = document.getElementById('sc')
  	var msg = '';
  	
  	if( trim(fn.value) == '' )
  	{
  		msg += "-Your Name is Required\n";
  	}
  	
  	
  	if( trim(sj.value) == '' )
  	{
  		msg += "-Subject is Required\n";
  	}
  	
  	
  	if( !isValidEmail(em.value) )
  	{
  		msg += "-A Valid Email is Required\n";
  	}
  	
  	
  	if( trim(ms.value) == '' )
  	{
  		msg += "-Message is Required\n";
  	}
  	
  	if( trim(sc.value) == '' )
  	{
  		msg += "-Security Code is Required\n";
  	}
  	
  	if(msg != '')
  	{
  		alert("Form contained validation errors\n" + msg)
  		return false;
  	}
  	
  	return true;
  	
  }
