function linkAttDels() {
    
	$("div.thumbnail").each(function(index) {
		var thumb = this;
		var elem_id = this.id.split(".");
		var att_id = elem_id[1];
		$(thumb).find("div.delLink a").click(function(e) {
			if (confirm("Na pewno chcesz usunąć załącznik?")) {
				$("div.thumbnail div.delLink a").fadeOut("slow");
				$.getJSON("/usun-zalacznik/" + att_id, undefined, function(deleted) {
					if (deleted) {
						$(thumb).slideUp("slow");
						$("div.thumbnail div.delLink a").fadeIn("slow");
					}
				});
			}
			return false;
		});
	});
}
$(function() {
     $("#flashMessage.success, .flashMessage.success").css({backgroundColor: "#E2F1A8"}).
        animate({ backgroundColor: "#BEDF5D" }, 1000).
        animate({ backgroundColor: "#E2F1A8" }, 1000).
        animate({ backgroundColor: "#BEDF5D" }, 1000).
        animate({ backgroundColor: "#E2F1A8" }, 1000);
    $("#flashMessage.failure, .flashMessage.failure").css({backgroundColor: "#F97D88"}).
        animate({ backgroundColor: "#ff2f3a" }, 1000).
        animate({ backgroundColor: "#F97D88" }, 1000).
        animate({ backgroundColor: "#ff2f3a" }, 1000).
        animate({ backgroundColor: "#F97D88" }, 1000);
    $("#flashMessage.info, .flashMessage.info").css({backgroundColor: "#7CB4FA"}).
        animate({ backgroundColor: "#ace1ff" }, 1000).
        animate({ backgroundColor: "#7CB4FA" }, 1000).
        animate({ backgroundColor: "#ace1ff" }, 1000).
        animate({ backgroundColor: "#7CB4FA" }, 1000);
    linkAttDels();
    var i;
});
function uploadifyCompleted(event, queueID, fileObj, response, data) {
    alert(response);
}

/* funkcja wykorzystywana do ajaxowej paginacji */
function getAJAX(link, page, div) {
	$(div + ' .comment-form').hide();
	$(div + ' .data').slideUp('slow');
	
	jQuery.get(
		link,
		{
			page: page,
			ajax: true
		},
		function(data) {
			$(div + ' .data').html(data);
			$(div + ' .data').slideDown('slow');
			$(div + ' .loader').hide();
			
		},
		'html'
	);
	return false;
}

function divAJAX(element, div_id) {

	if (div_id == null)
		div_id = 'ajaxDIV';
	$('#' + div_id).html('<div class="infoAjaxBox">Trwa ładowanie...<br /><br /><img src="/img/loadingAnimation.gif" alt="" /></div>');
	$.ajax({
		type: "POST",
		url: $(element).attr('href'),
		data: "ajax=true",
		async: false,
		success: function(msg) {
			$('#' + div_id).html(msg);
		}
	});
	return false;	
}



function mainmenu(){
	$(" #nav ul ").css({display: "none"}); // Opera Fix
	$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(250);
		},function(){
		/*$(this).find('ul:first').css({visibility: "visible",display: "block"}).hide(250);*/
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
$(document).ready(function(){
	mainmenu();
});

$(document).ready(function(){
	$('a.scrollTo').click(function() {
		$(document).scrollTo('#answer_form', 1000);
		return false;
	});
});
