var gotoTopic = function (id) {
	location.href = '/forum/temat/' + id;
}
var gotoSection = function (id) {
	location.href = '/forum/dzial/' + id;
}

$(document).ready(function() {
	$('.remove-post').click (function (event) {
		var answer = confirm("Czy na pewno usunąć post");
		if (answer){
		}
		else{
			event.preventDefault();
		}
	});
	
	$('.remove-section').click (function (event) {
		var answer = confirm("Czy na pewno usunąć dział");
		if (answer){
		}
		else{
			event.preventDefault();
		}
	});
	
	$('.remove-topic').click (function (event) {
		var answer = confirm("Czy na pewno CAŁY temat, ze wszystkimi postami?");
		if (answer){
		}
		else{
			event.preventDefault();
		}
	});
	
	$('.tip').click(function (event) {
		event.preventDefault();
	})
	
	$('#search-forum-form').submit(function (event) {
		event.preventDefault();
		if ($('#search-forum').val().length >= 3) {
			location.href = '/forum/szukaj/' +  $('#search-forum').val();
		} else {
			alert('Wpisana fraza jest za krótka. Podaj co najmniej 3 znaki.');
		}
	});
	
	$('#search-topic-form').submit(function (event) {
		event.preventDefault();
		if ($('#search-topic').val().length >= 3) {
			location.href = '/forum/szukaj-temat/' + topicId + '/' + $('#search-topic').val();
		} else {
			alert('Wpisana fraza jest za krótka. Podaj co najmniej 3 znaki.');
		}
	});
	
	$('#search-section-form').submit(function (event) {
		event.preventDefault();
		if ($('#search-section').val().length >= 3) {
			location.href = '/forum/szukaj-dzial/' + sectionId + '/' + $('#search-section').val();
		} else {
			alert('Wpisana fraza jest za krótka. Podaj co najmniej 3 znaki.');
		}
	});
	
	$('#forum-tip').tooltip({ 
		delay: 0, 
		showURL: false, 
		bodyHandler: function() { 
			return $("\
<p>W treści postu można użyć BB-kodu:</p>\n\
	<ul>\n\
		<li>[b]wyraz[/b] dla <b>pogrubienia</b></li>\n\
		<li>[i] dla <i>kursywy</i></li>\n\
		<li>[u] dla <u>podkreślenia</u></li>\n\
		<li>[link http://omonetach.pl/]treść linku[/link]\n\ dla <a href='http://omonetach.pl/'>odnośnika</a></li>\n\
		<li>[cytat]treść[/cytat] dla cytatu</li>\n\
	</ul>\n\
"); 
		} 
	});
});


