// JavaScript Document
function IsNumeric(sText, alertno){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   val = sText.value;
 
   for (i = 0; i < val.length && IsNumber == true; i++) 
      { 
      Char = val.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
		 alert(alertno);
		 sText.focus();
         }
      }
   return IsNumber;
   
}
   
   
function check(form, message) {
	if (form.value == "") {
		alert(message);
		form.focus();
		return false;
	}
	else return true;
}


var testresults;
function checkmail(form){
	var str=form.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		testresults=true;
	else{
		alert("Introduceti o adresa de email valida!");
		form.focus();
		testresults=false;
	}
	return (testresults);
}



function checkform_contact() {
	stat = true;
	if (stat == true) stat = check(document.formular.nume, 'Completati numele dumneavoastra!');
	if (stat == true) stat = check(document.formular.telefon, 'Completati telefonul dumneavoastra!');
	if (stat == true) stat = IsNumeric(document.formular.telefon, 'Numarul de telefon nu este valid!')
	if (stat == true) stat = checkmail(document.formular.email);
	return stat; 
}