
function formValidator(){
	// Make quick references to our fields
	var name = document.getElementById('name');	
	var company = document.getElementById('company');
	var phone = document.getElementById('phone');
	var email = document.getElementById('email');
	var cmnt = document.getElementById('cmnt');
	var accesscode = document.getElementById('accesscode');
	

	// Check each input in the order that it appears in the form!
	if(isAlphabet(name, "Please enter your name.")){
		if(notEmpty(company, "Please enter your company.")){
			if(isNumeric(phone, "Please enter Phone number, (Numbers only).")){
			   if(emailValidator(email, "Please enter a valid email address.")){
				   if(notEmpty(cmnt, "Please enter the Requirements / Details.")){
					   if(isAlphabets(accesscode, "Please enter the text from the image in upper case. It is case sensitive.")){
				       return true;
				   }
			   }
			}
		}
	}
}
	return false;
	
}

function formValidator2(){
	// Make quick references to our fields
	var name = document.getElementById('name');	
	var phone = document.getElementById('phone');
	var email = document.getElementById('email');
	var cmnt = document.getElementById('cmnt');
	var accesscode = document.getElementById('accesscode');
	

	// Check each input in the order that it appears in the form!
	if(isAlphabet(name, "Please enter your name.")){
			if(isNumeric(phone, "Please enter Phone number, (Numbers only).")){
			   if(emailValidator(email, "Please enter a valid email address.")){
				   if(notEmpty(cmnt, "Please enter the Requirements / Details.")){
					   if(isAlphabets(accesscode, "Please enter the text from the image in upper case. It is case sensitive.")){
				       return true;
				   }
			   }
			}
	}
}
	return false;
	
}


function signupvali(){
	// Make quick references to our fields
	var name = document.getElementById('name');	
	var company = document.getElementById('company');
	var phone = document.getElementById('phone');
	var email = document.getElementById('email');
	var cmnt = document.getElementById('cmnt');
	var accesscode = document.getElementById('accesscode');

	// Check each input in the order that it appears in the form!
	if(isAlphabet(name, "Please enter your name.")){
		if(notEmpty(company, "Please enter your company.")){
			if(isNumeric(phone, "Please enter Phone number, (Numbers only).")){
			   if(emailValidator(email, "Please enter a valid email address.")){
				   if(notEmpty(cmnt, "Please enter the details.")){
					  if(isAlphabets(accesscode, "Please enter the text from the image in upper case. It is case sensitive.")){
				       if(document.fm1.tc.checked == true){ 	
				 		     return true;
					  }
					  else
		              {alert('Please read the "Terms and Conditions" and tick the checkbox to submit the form..');
		                return false;
					  }
				   }
				}
			}
		}
	}
}
	return false;
	
}
	  
					  
					  
function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9\ \-]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z\.\ ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
function isAlphabets(elem, helperMsg){
	var alphaExp = /^[A-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}


function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == ""){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}


/* For terms and conditions opo up */  
   function poptc()
  {
    window.open("terms.html","_blank","width=680,height=500,status=0,resizable=no,menu=no");
  }

