function bozobin_auteurgegevens(element) {
	return $(element).parent().parent().children('div.CommentHeader').children(':nth-child(2)').children(':first-child');
}
function bozobin_verstopauteur(auteur) {
	var postings = $('.CommentObject').filter(function (index){return $(this).children('div.CommentHeader').children(':nth-child(2)').children(':first-child').text() == auteur;});
	postings.hide();
}
function bozobin_userID(tekst) {
	// tekst heeft formaat:  <a href="http://lm/forum/account.php?u=1">admin</a>
	var index_1 = tekst.indexOf('?');
	return tekst.substring(index_1 + 3, tekst.length);
}
$(document).ready(function() {
	$('.bozobinlink').click(function(event) {
		var Comments = $('.CommentObject');
		var gegevens = bozobin_auteurgegevens(this);
		// eerst alle postings van dexe auteur verstoppen
		bozobin_verstopauteur(gegevens.text());
		var user = bozobin_userID(gegevens.attr('href'));
		$.post('/forum/extensions/Bozobin/block.php', {BlockUserID: user, User: gegevens.text()}, function(response) {alert(response);}, "text");
		return false;
	});
});
function stelToolIn(element, img, titel, tekst, functie) {
	$(element).html('<img src="/forum/themes/luiemotorfiets/styles/default/'+img+'" class="tool" alt="'+titel+'"/>&nbsp;'+titel);
	$(element).attr(titel, tekst);
	$(element).unbind('click');
	$(element).click(functie);
}
function performActie(trueOrFalse, type) {
	var DiscussionID = $('#OnderwerpID').html();
	var PostBackKey = $('#SessionPostBackKey').html();
	$.ajax({
		type: "GET",
		url: "/forum/ajax/switch.php",
		data: "Type="+type+"&Switch="+trueOrFalse+"&DiscussionID="+DiscussionID+"&PostBackKey="+PostBackKey,
		//success: function(response){alert(response);},
		dataType: "text"
	});
}
function showBookmark() {
	stelToolIn($('#SetBookmark'), 'bookmark.png', 'Bookmark', 'Zet bij je bookmarks', function() {performActie(true, 'Bookmark');showUnBookmark();return false;});
}
function showUnBookmark() {
	stelToolIn($('#SetBookmark'), 'unbookmark.png', 'UnBookmark', 'Verwijder uit je bookmarks', function() {performActie(false, 'Bookmark');showBookmark();return false;});
}
function startshowBookmark() {
	$(document).ready(function() {
		$('#SetBookmark').click(function(e) {performActie(true, 'Bookmark');showUnBookmark();return false;});
	});
}
function startshowUnBookmark() {
	$(document).ready(function() {
		$('#SetBookmark').click(function(e) {performActie(false, 'Bookmark');showBookmark();return false});
	});
}
function showHide() {
	stelToolIn($('#SetHide'), 'verberg.png', 'Verberg', 'Verberg onderwerp voor alle lezers', function() {performActie(false, 'Active');showUnHide();return false;});
}
function showUnHide() {
	stelToolIn($('#SetHide'), 'tevoorschijn.png', 'Toon', 'Maak onderwerp weer zichtbaar voor alle lezers', function() {performActie(true, 'Active');showHide();return false;});
}
function startshowHide() {
	$(document).ready(function() {
		$('#SetHide').click(function() {performActie(false, 'Active');showUnHide();return false;});
	});
}
function startshowUnHide() {
	$(document).ready(function() {
		$('#SetHide').click(function() {performActie(true, 'Active');showHide();return false;});
	});
}
function showOpen() {
	stelToolIn($('#SetClose'), 'nietopslot.gif', 'Heropen', 'Heropen onderwerp', function() {performActie(false, 'Closed');showClose();return false;});
}
function showClose() {
	stelToolIn($('#SetClose'), 'opslot.gif', 'Sluit', 'Sluit dit onderwerp', function() {performActie(true, 'Closed');showOpen();return false;});
}
function startshowOpen() {
	$(document).ready(function() {
		$('#SetClose').click(function() {performActie(false, 'Closed');showClose();return false;});
	});
}
function startshowClose() {
	$(document).ready(function() {
		$('#SetClose').click(function() {performActie(true, 'Closed');showOpen();return false;});
	});
}
function showNotSticky() {
	stelToolIn($('#SetSticky'), 'notsticky.png', 'UnSticky', 'Maak onderwerp niet sticky', function() {performActie(false, 'Sticky');showSticky();return false;});
}
function showSticky() {
	stelToolIn($('#SetSticky'), 'sticky.png', 'Sticky', 'Maak onderwerp sticky', function() {performActie(true, 'Sticky');showNotSticky();return false;});
}
function startshowNotSticky() {
	$(document).ready(function() {
		$('#SetSticky').click(function() {performActie(false, 'Sticky');showSticky();return false;});
	});
}
function startshowSticky() {
	$(document).ready(function() {
		$('#SetSticky').click(function() {performActie(true, 'Sticky');showNotSticky();return false;});
	});
}
function showUnSink() {
	stelToolIn($('#SetSink'), 'ontzink.png', 'Onhoog', 'Haal onderwerp terug', function() {performActie(false, 'Sink');showSink();return false;});
}
function showSink() {
	stelToolIn($('#SetSink'), 'zink.png', 'Omlaag', 'Duw onderwerp naar beneden', function() {performActie(true, 'Sink');showUnSink();return false;});
}
function startshowUnSink() {
	$(document).ready(function() {
		$('#SetSink').click(function() {performActie(false, 'Sink');showSink();return false;});
	});
}
function startshowSink() {
	$(document).ready(function() {
		$('#SetSink').click(function() {performActie(true, 'Sink');showUnSink();return false;});
	});
}