$(document).ready(function() {	
	var lock = false; 
	$('.addEntry .button a').click(function(){
		if(!lock){
			 lock = true;
			 $.ajax({
				 type: "POST",
				 url: BASE_URL+'/comments/comments/add/srcmodule/page',
				 data: $("#commentForm").serialize(),
				 dataType: 'json',
				 success: function(msg){	
				 	if(msg.noValid == null){
				 		$('#commentForm input[type="text"], #commentForm textarea').each(function(){
				 			$(this).val('');
				 		});			 
				 		window.location.reload( false );
				 	} else {
				 		$('#commentForm .errorMsg').text('Wypełnij poprawnie formularz.').css('color', '#F00');	
				 	}					 	
				 	lock = false;
			 	}
			 });
		 }
	});
	$('#sendMsg a').click(function(){	
		 if(!lock){
			 lock = true;
			 $.ajax({
				 type: "POST",
				 url: BASE_URL+'/contact/contact/send',
				 data: $("#contactForm").serialize(),
				 dataType: 'json',
				 success: function(msg){	
				 	if(msg.noValid == null){
				 		$('#contactForm input[type="text"], #contactForm textarea').each(function(){
				 			$(this).val('');
				 		});			 
				 		$('#contactForm .errorMsg').text('Twoja wiadomość została wysłana pomyślnie.').css('color', '#7AA7BC');
				 	} else {
				 		$('#contactForm .errorMsg').text('Wypełnij poprawnie formularz.').css('color', '#F00');	
				 	}					 	
				 	lock = false;
			 	}
			 });
		 }
		 return false;
	});	
	$('#gallery a').lightBox({
		fixedNavigation:true,
		imageLoading: BASE_URL+'/public/js/externals/lightbox/images/lightbox-ico-loading.gif',
		imageBtnClose: BASE_URL+'/public/js/externals/lightbox/images/lightbox-btn-close.gif',
		imageBtnPrev: BASE_URL+'/public/js/externals/lightbox/images/lightbox-btn-prev.gif',
		imageBtnNext: BASE_URL+'/public/js/externals/lightbox/images/lightbox-btn-next.gif',
		imageBlank: BASE_URL+'/public/js/externals/lightbox/images/lightbox-blank.gif',
		txtImage: 'Zdjęcie',
		txtOf : 'z'
	});
});

