/*******************************************************
	functia de validare
********************************************************/
function validare(camp, cod_validare, text_eroare) {
	switch (cod_validare) {
		case "text":
		{
			if (document.getElementById(camp).value=="") {
				window.alert(text_eroare);
				document.getElementById(camp).select();
				document.getElementById(camp).focus();
				return false;
			} else { return true; }
			break;
		}

		case "NaN": 
		{
			if (validare(camp, "text", text_eroare)) {
				if (isNaN(document.getElementById(camp).value)) {
					window.alert(text_eroare);
					document.getElementById(camp).select();
					document.getElementById(camp).focus();
					return false; }
				else { return true; }
			} else { return false; }
			break;
		}

		case "email": 
		{						
			var validRegExp = /^[^@]+@[^@]+\.[a-z]{2,4}$/i;
			var strEmail = document.getElementById(camp).value;

			if (strEmail.search(validRegExp) == -1) {
				window.alert(text_eroare);
				document.getElementById(camp).select();
				document.getElementById(camp).focus();
				return false; }
			else { return true; }
			break;
		}

		case "web":
		{
			var j = new RegExp();
			j.compile("^(http|https){1}://.+$");

			if (!j.test(document.getElementById(camp).value)) {
				window.alert(text_eroare);
				document.getElementById(camp).select();
				document.getElementById(camp).focus();
				return false; }
			else { return true; }
			break;
		}
	}
}

/*******************************************************
	functia de comparare a valorilor a 2 campuri
********************************************************/
function match(camp1, camp2, text) {
	if (document.getElementById(camp1).value != document.getElementById(camp2).value) {
		alert(text);
		document.getElementById(camp2).select();
		document.getElementById(camp2).focus();
		return false; }
	else { return true; }
}


