/* javascript-contact.js */

function contactus_onclick()
{
  if (validate_contactform()==true)
  {
    document.contactform.method="post";
    document.contactform.action="contact.php";
    document.contactform.submit();	
  }
}

function validate_contactform()
{

	document.contactform.first_name.value = nolrspaces(document.contactform.first_name.value);
	document.contactform.last_name.value = nolrspaces(document.contactform.last_name.value);
	document.contactform.email.value = nolrspaces(document.contactform.email.value);
	
    document.getElementById('firstnameREQUIRED').style.display = "none";
    document.getElementById('lastnameREQUIRED').style.display = "none";
    document.getElementById('emailREQUIRED').style.display = "none";
	
	  if (document.contactform.first_name.value == "")
	  {
	    document.getElementById('firstnameREQUIRED').style.display = "";
		alert("Please provide your first name.");
	    return false;
	  }
	  
	  if (document.contactform.last_name.value == "")
	  {
	    document.getElementById('lastnameREQUIRED').style.display = "";
		alert("Please provide your last name.");
	    return false;
	  }
	  
	  if (document.contactform.email.value == "")
	  {
	    document.getElementById('emailREQUIRED').style.display = "";
	    alert("Please provide your email address.");
	    return false;
	  }
	
  return true;
}


// START strip off leading and trailing spaces from string ///////////////////
function nolrspaces(strinx)
{
	while (strinx.charCodeAt(0)==32)
		{ strinx = strinx.substring(1, strinx.length); 
		}
	while (strinx.charCodeAt(strinx.length-1)==32)
		{ strinx = strinx.substring(0, strinx.length - 1); 
		}
	return strinx;
}
// END strip off leading and trailing spaces from string ///////////////////