function isEmail(string){
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}

function checkForm(){
	var sw=0;	
	if (((document.getElementById('c_nume').value.length == 0) || (document.getElementById('c_nume').value == "Nume"))){
		alert('Va rugam introduceti numele! \n');
		document.getElementById('c_nume').focus();
		sw=1;
		return false;
	}
	if (isEmail(document.getElementById('c_email').value) == false && (sw==0)) {
		alert('Va rugam introduceti o adresa de e-mail valida! \n');
		document.getElementById('c_email').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('c_subiect').value.length == 0)){
		alert('Va rugam selectati subiectul! \n');
		document.getElementById('c_subiect').focus();
		sw=1;
		return false;
	}		
	if ((document.getElementById('c_mesaj').value.length == 0)){
		alert('Va rugam introduceti mesajul! \n');
		document.getElementById('c_mesaj').focus();
		sw=1;
		return false;
	}
	if (sw==0) {
		document.getElementById('formContact').submit();
	} else {
		alert('Eroare trimitere formular!');
	}		
}

function doCheckComment(){
	var sw=0;
	var user = document.getElementById('nume_c').value;
	var email = document.getElementById('email_c').value;
	var mesaj = document.getElementById('message_c').value;

	if (((user == "Nume") || (user.length==0)) && (sw==0)){
		alert('Va rugam introduceti numele!');
		$('#nume_c').focus();
		sw = 1;
		return false;
	} 
	
	if (((email == "Email") || (email.length==0)) && (sw==0)){
		alert('Va rugam introduceti o adresa de email!');
		$('#email_c').focus();
		sw = 1;
		return false;
	} 	
	
	if(!isEmail(email)){
		alert('Va rugam introduceti o adresa de email valida!');
		$('#email_c').focus();
		sw = 1;
		return false;		
	}

	if (((mesaj == "Comentariu") || (mesaj.length==0)) && (sw==0)){
		alert('Va rugam introduceti comentariul!');
		$('#message_c').focus();
		sw=1;
		return false;
	}
	
	if ((mesaj.length>400) && (sw==0)){
		alert('Comentariul nu trebuie sa depaseasca 400 de caractere!');
		$('#message_c').focus();
		sw=1;
		return false;
	}
	
	if(sw==0){	
		document.getElementById('commentForm').submit();
	}
}
