// JavaScript Document
function isEmailAddr (s){ 
	var rv = false
	if ((s == null) || (s.length == 0)) 
       rv = false;
  else {
		var reEmail =/([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		//reEmail = /.+\@.+\..+$/
		
		rv = reEmail.test(s)
    }
	if(rv){
	return rv
	}else{
		return false
	}
}

 function comp(theForm){
  if (theForm.Name.value == ""){
    alert("Please enter your name.");
    theForm.Name.focus();
    return (false);
  }
  if (theForm.Company.value == ""){
    alert("Please enter your company name.");
    theForm.Company.focus();
    return (false);
  }
  
  if (!isEmailAddr(theForm.email_from.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email_from.focus();
    return (false);
  }
  if (theForm.Phone.value == ""){
    alert("Please enter a phone number.");
    theForm.Phone.focus();
    return (false);
  }
  if (!theForm.terms.checked){
    alert("Please accept the terms & conditions.");
    theForm.terms.focus();
    return (false);
  }
return true
}
 
 function validation(theForm){
  if (theForm.First_name.value == ""){
    alert("Please enter your first name.");
    theForm.First_name.focus();
    return (false);
  }
    if (theForm.Last_name.value == ""){
    alert("Please enter your last name.");
    theForm.Last_name.focus();
    return (false);
  }
  if (theForm.Phone.value == ""){
    alert("Please enter a phone number.");
    theForm.Phone.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.email_from.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email_from.focus();
    return (false);
  }
  if (theForm.Question.value == ""){
    alert("Please enter your question/enquiry.");
    theForm.Question.focus();
    return (false);
  }
return true
}

function register(theForm){
  if (theForm.firstname.value == ""){
    alert("Please enter your first name.");
    theForm.firstname.focus();
    return (false);
  }
    if (theForm.lastname.value == ""){
    alert("Please enter your surname.");
    theForm.lastname.focus();
    return (false);
  }
  if (theForm.Company.value == ""){
    alert("Please enter your company name.");
    theForm.Company.focus();
    return (false);
  }
  if (theForm.Address.value == ""){
    alert("Please enter your company address.");
    theForm.Address.focus();
    return (false);
  }
  if (theForm.Phone.value == ""){
    alert("Please enter your company phone number.");
    theForm.Phone.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.Email.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.Email.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.Email2.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.Email2.focus();
    return (false);
  }
  if (theForm.Email.value != theForm.Email2.value){
    alert("Your email does not match.");
    theForm.Email2.focus();
    return (false);
  }
  if (theForm.Password.value == ""){
    alert("Please enter your password.");
    theForm.Password.focus();
    return (false);
  }
  if (theForm.Password.value.length < 5){
    alert("Your password should be atleast 5 characters long");
    theForm.Password.focus();
    return (false);
  }
  if (theForm.Password.value != theForm.Password2.value){
    alert("Your passwords do no match.");
    theForm.Password2.focus();
    return (false);
  }
  
return true
}

function makeNumerical(o){
		var bag = '0123456789'
		var s = ''
		for(var i=0;i<o.value.length;i++)
			if(bag.indexOf(o.value.charAt(i)) != -1)
				s+=o.value.charAt(i)
		if(s == '')
			s = 1
			o.value = s
			
}

