$(document).ready(function() {
	// Mostra / Nasconde singolo commento
	$('.comment-toggle').click(function() {
		var parent = $(this).parents('li');
		$('.comment-text p', parent).toggle('normal');
		var imgPath = $('img', parent).attr('src');
		if ($('img', parent).attr('src').search(/delete/) == -1) {
			imgPath = imgPath.replace(/add/, 'delete');
		} else {
			imgPath = imgPath.replace(/delete/, 'add');
		}
		$('img:first', parent).attr('src', imgPath);
		return false;
	});

	// Mostra / Nasconde tutti i commenti
	$('.comments-toggle').click(function() {
		var imgPath = $('img', $(this)).attr('src');
		img = imgPath.split('/');
		img = img[img.length - 1];
		if (img.search(/delete/) != -1) {
			$('ol.commentlist li .comment-text p').hide('normal');
			imgPath = imgPath.replace(/delete/, 'add');
		} else {
			$('ol.commentlist li .comment-text p').show('normal');
			imgPath = imgPath.replace(/add/, 'delete');
		}
		$('img:first', $(this)).attr('src', imgPath);
		$('ol.commentlist li img').attr('src', imgPath);
		return false;
	});
	
	$('.comment-scroll').click(function() {
		var target = $('ol.commentlist li:last');
		$(document).scrollTo(target, 1300);
		return false;
	});
});