$(document).ready(function() {

	$('#subnav li:first').css({'background' : 'none'});
	$('#slider').append('<span id="corners"></span>');

	$('#content-clients-logos').carouFredSel({
		items				: 4,
		direction			: "left",
		scroll : {
			items			: 1,
			effect			: "linear",
			duration		: 600,							
			pauseOnHover	: true
		}					
	});
		
	Cufon.replace('h1, #menu li a', { fontFamily: 'Calibri', hover: 'true' });
	$('#images').cycle({ timeout: 200, fx: 'fade' });


	$('#subnav li a').hover(function() { 
		$(this).css({'background-color' : '#639bce', 'color' : '#fff'}).append('<span id="shadow"></span>');
	}, function() {
		$(this).css({'background' : 'none', 'color' : '#000'});
		$('#shadow').remove();
	});
	
	$('.answ').hide();
	$('form#contact-zone').bind('submit', function(e){
		$('#contact-res').css({'opacity' : 1});
		var nume  = $('input#numeV').val();
		var mail  = $('input#mailV').val();
		var mesaj  = $('textarea#mesajV').val();
		if (nume == '') {
			if($('#contact-res').is(':visible')) { $('#contact-res').html('Completati numele dumneavoastra.'); }
			else { $('#contact-res').html('Completati numele dumneavoastra.').slideToggle(); }
			return false;
		}
		if (mail == '') {
			if($('#contact-res').is(':visible')) { $('#contact-res').html('Completati adresa de e-mail.'); }
			else { $('#contact-res').html('Completati adresa de e-mail.').slideToggle(); }
			return false;
		}
		if (mesaj == '') {
			if($('#contact-res').is(':visible')) { $('#contact-res').html('Completati intrebarea pe care o aveti.'); }
			else { $('#contact-res').html('Completati intrebarea pe care o aveti.').slideToggle(); }
			return false;
		}
		if($('#contact-res').is(':visible')) { $('#contact-res').html('Va rugam sa asteptati...'); }
		else { $('#contact-res').html('Va rugam sa asteptati...').slideToggle(); }
		e.preventDefault();
		$.ajax({
			type: 'POST',
			url: '?action=send',
			data: 'mail='+mail+'&nume='+nume+'&mesaj='+mesaj,
			success: function(){
				$('#contact-res').animate({opacity: 0}, 5000).slideToggle();
				$('#contact-res').html('Mesajul a fost trimis cu succes!');
			},
			error: function(){
				$('#contact-res').animate({opacity: 0}, 5000).slideToggle();
				$('#contact-res').html('Ups! A aparut o eroare.');
			}
			
		});
		return false;
	});

	
});
