function formValidator(){
	// Make quick references to our fields
	var nume = document.getElementById('nume');
	var prenume = document.getElementById('prenume');
	var nume_companie = document.getElementById('nume_companie');
	var email = document.getElementById('email');
	var telefon = document.getElementById('telefon');
	var ora_contact = document.getElementById('ora_contact');
	var oras = document.getElementById('oras');	
	var cod_zip = document.getElementById('cod_zop');
	var domeniu = document.getElementById('domeniu');
	var nr_posturi = document.getElementById('nr_posturi');

	
	// Check each input in the order that it appears in the form!
	if(isAlphabet(nume, "Va rugam introduceti doar litere pentru campul nume!")){
		if(isAlphabet(prenume, "Va rugam introduceti doar litere pentru campul prenume!")){
			if(notEmpty(nume_companie, "Nu ati completat numele companiei!")){
				if(emailValidator(email, "Va rugam introduceti o adresa de email valida")){
					if(isNumeric(telefon, "Va rugam introduceti doar cifre pentru campul telefon")){
						if(madeSelection(ora_contact, "Alegeti o ora de contact")){
							if(isAlphabet(oras, "Va rugam introduceti doar litere pentru campul oras!")){
								if(isNumeric(cod_zip, "Va rugam introduceti doar cifre pentru campul cod zip")){
									if(madeSelection(domeniu, "Alegeti un domeniu")){						
										if(madeSelection(nr_posturi, "Selecteaza...", "Alegeti numarul de posturi")){
											alert("Mesaj trimis cu succes");
											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 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 == "Selecteaza..."){
		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;
	}
}