$(document).ready(function(){
	$('#frmContact').submit(function(){
		if( $('#frmContact #selCategorie').val() == '__NONE__' ) {
			alert('Alegeti o categorie pentru subiect');
			$('#selCategorie').focus();
			
			return false;
		}
		
		if( $('#frmContact input:radio:checked').length == 0 ) {
			alert('Alegeti "Titlu"');
			return false;
		}
		
		if( $('#frmContact #txtPrenume').val() == '' ) {
			alert('Prenumele nu poate fi gol');
			$('#frmContact #txtPrenume').focus();
			
			return false;
		}
		
		if( $('#frmContact #txtNume').val() == '' ) {
			alert('Numele nu poate fi gol');
			$('#frmContact #txtNume').focus();
			
			return false;
		}
		
		if( !isValidEmail( $('#frmContact #txtEmail').val() ) ) {
			alert('Adresa de email nu este valida');
			$('#frmContact #txtEmail').focus();
			
			return false;
		}
		
		if( $('#frmContact textarea').val() == '' ) {
			alert('Mesajul nu poate fi gol');
			$('#frmContact textarea').focus();
			
			return false;
		}
		
		if( ! $('#frmContact #chkAccept').is(':checked') ) {
			alert('Nu ati acceptat termenii si conditiile');
			$('#frmContact #chkAccept').focus();
			
			return false;
		}
		
	});
});

function isValidEmail(email) {
	return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email);
}
