$(document).ready(function(){

    var zIndex = 1;
    
    $('a[rel*=lightbox]').lightBox();
    
    $("#top .top-images img").hover(
	function() {
	    $(this).css('zIndex', zIndex++);
	}
	);

    $("#bottom .img-shortcuts a").hover(
	function() {
	    $(this).css('zIndex', zIndex++);
	}
	);

    $('ul.fe-thumb-gallery li a.link').click(function(event) {
	var src = $(this).attr('href'),
	originalImg = $(this).attr('rel'),
	img = '<img src="'+ src +'" alt=""/>';
	img = '<a href="'+ originalImg +'" rel="lightbox">' + img + '</a>';
	$('div.medium-picture').empty().append(img);
	$('div.medium-picture img').hide().fadeIn(1500);
	$('a[rel*=lightbox]').lightBox();
	return false;
    });

    $('ul.fe-thumb-gallery li a.link ').eq(0).click();


    $('#send-email').click(function() {
	sendEmail($('#nume').val(), $('#telefon').val(), $('#subiect').val(), $('#email').val(), $('#mesaj').val());
    });
});


function sendEmail(nume, telefon, subiect, email, mesaj) {
    $('#send-email').removeAttr('disabled').attr('disabled', 'disabled');
    $('#bottom .messages').empty().append('Operatie in curs...');
    $.post('email.php', 
    {
	nume: nume,
	telefon: telefon,
	subiect: subiect,
	email: email,
	mesaj: mesaj
	},
	function(data) {
	    $('#bottom .messages').empty().append(data);
	    $('#send-email').removeAttr('disabled');
	});
}



