/****************************************************************************************************************
Fisier care contine functiile js folosite in pagina de contact
****************************************************************************************************************/
$('document').ready(function() {
$('#nume').bind('focus', function() {
		if ($(this).val() == 'nume') {
			$(this).val('');
		}
	});
	$('#telefon').bind('focus', function() {
		if ($(this).val() == 'telefon') {
			$(this).val('');
		}
	});
	$('#email').bind('focus', function() {
		if ($(this).val() == 'email') {
			$(this).val('');
		}
	});
	$('#continutMesaj').bind('focus', function() {
		if ($(this).html() == 'mesajul dumneavoastra') {
			$(this).html('');
		}
	});
	$('#nume').bind('blur', function() {
		if ($(this).val() == '') {
			$(this).val('nume');
		}
	});
	$('#telefon').bind('blur', function() {
		if ($(this).val() == '') {
			$(this).val('telefon');
		}
	});
	$('#email').bind('blur', function() {
		if ($(this).val() == '') {
			$(this).val('email');
		}
	});
	$('#continutMesaj').bind('blur', function() {
		if ($(this).html() == '') {
			$(this).html('mesajul dumneavoastra');
		}
	});
	

	$('#formContNou').submit(function() {
		var str = '';
		var corect = true;
		var checkemail = /(^[a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$)/i;

		
			
			if ($('#nume').val()=='nume'  ) {
				corect = false;
				str += '<p>Numele este incorect!</p>';
			}
			if ($('#email').val()=='email' && !checkemail.test($('#email').attr('value'))) {
				corect = false;
				str += '<p>Adresa de email este incorecta!</p>';
			}
		
	

		// daca sunt erori
		if (!corect) {
				$('#warning').html(str);
				$('#warning').show('fast');
				$('html, body').animate({scrollTop: 0}, "slow");
		} else {
				$('#warning').css({'display': 'none'});
				this.submit();
		}
		return corect;
	});
});