// JavaScript Document
function chk(frmElement,errMsg) {
	if (trim(frmElement.value)=="") {
	 alert (errMsg);
	 frmElement.focus;
	 return false;
	}
	else return true;
}

function trim(str) {
	if (str=="") return ""
	var str0=new Array(' ','\t','\n').toString()
	if (str0.indexOf(str.charAt(0))!=-1) return trim(str.slice(1))
	if (str0.indexOf(str.charAt(str.length-1))==-1) return str
	return trim(str.slice(0,str.length-1))
}

function isemail(str) {
	var pt1,pt2,address,re
	address=str.split("@");
	if (address.length==2) {
		pt1 = address[0];
		pt2 = address[1];
  		if (pt2.split(".").length>1) {
			if (pt1.split(" ").length==1 && pt2.split(" ").length==1) {
				return true;
			}
			return false;
		}
		return false;
	}
	return false;
}

function checkparameters(str,matchstr) {
	var cnt;
	for (cnt = 1; cnt <= str.length; cnt++){
		if (matchstr.split(str.charAt(cnt-1)).length==1){
			return false;
		}
	}
	return true;
}

function validate() {
  if(document.forms.form1.firstname.value != ''){
    if(!document.forms.form1.salutation[0].checked && !document.forms.form1.salutation[1].checked){
      alert("Please enter your title")
      document.forms.form1.salutation[0].focus();
      return false;
      }
    }

  with(document.forms.form1){

    if (trim(firstname.value) == "") {
      alert("Please enter your first name.");
      firstname.focus();
      return false;
      }
    if (trim(lastname.value) == "") {
      alert("Please enter your last name.");
      lastname.focus();
      return false;
      }
    if (trim(jobtitle.value) == "") {
      alert("Please enter your job title.");
      jobtitle.focus();
      return false;
      }
    if (trim(company.value) == "") {
      alert("Please enter your company.");
      company.focus();
      return false;
      }
    if (trim(email.value) == "") {
      alert("Please enter your email address.");
      email.focus();
      return false;
      }
    if (isemail(email.value) == false) {
      alert("Please enter a valid email address.");
      email.focus();
      return false;
      }
    if (trim(telephone.value) == "") {
      alert("Please enter your telephone number.");
      telephone.focus();
      return false;
      }
    }
}
//-->
</script>

