// JavaScript Document

// JavaScript Document
//<script type='text/javascript'>

function validatef(){
	// Make quick references to our fields
	var fname = document.getElementById('fname');
	var emailid = document.getElementById('emailid');
	var phone = document.getElementById('phone');
	var subject = document.getElementById('subject');
	var country = document.getElementById('country');
	
	
	// Check each input in the order that it appears in the form!
	
	if(notEmpty(fname, "please Enter your name")){
		
		  if(emailValidator(emailid, "Please enter a valid email address")){
			  
			 if(isNumeric(phone, "please enter number values in phone number")){
					  
					  if(notEmpty(subject, "please Enter Subject")){
						  
						   if(notEmpty(country, "please Enter country")){
	
	    
							return true;
						}
			
			}
	}
								}
	}

	
	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 notEmpty1(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function notEmpty3(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 isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

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 webval(elem, helperMsg) {
    var web = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if(elem.value.match(web)){
		return true;
	}else
	{
	alert(helperMsg);
		elem.focus();
		return false;
	}
}
/*</script>*/
