function init_comments() {
	jQuery(function( $ ){
		$("#comments").init_bbcode({
			form_name: 'COMMENTS_FORM', 
			text_name: 'DATA[COMMENT]',
			bbcode_buttons:	'.insert_bbcode'
		});
	});
	$(".s-msg-reply").click(function(){
		var parent = $(this).parents("div.info").get(0);
		var parent_id = '#' + $(parent).attr("id");
		$("#COMMENT").html('[quote=' + $("#AUTHOR_" + $(parent).attr("id")).text() + ']' + $("#SOURCE_" + $(parent).attr("id")).attr("value") + '[/quote]');
		$("#comment_PARENT_ID").attr("value", $("#ID_" + $(parent).attr("id")).attr("value"));
		$("#comment_LEVEL").attr("value", parseInt($("#LEVEL_" + $(parent).attr("id")).attr("value") + 1));
		$("#comment_PARENT_ID").removeAttr("disabled");
		$("#comment_LEVEL").removeAttr("disabled");
		$("#form-comment-add").insertAfter('#comment' + $("#ID_" + $(parent).attr("id")).attr("value"));
		$("#form-comment-add").show();
		return false;
	});
	$(".s-msg-add").click(function(){
		$("#comment_PARENT_ID").attr("disabled", "disabled");
		$("#comment_LEVEL").attr("disabled", "disabled");
		$("#comment_PARENT_ID").attr("value", "");
		$("#comment_LEVEL").attr("value", "");
		$("#COMMENT").html("");
		$("#form-comment-add").insertAfter('#comments_form_start_position');
		$("#form-comment-add").show();
		return false;
	});
}

function init_lightbox() {
	$.each($("a"),function(i,obj){
		if ($(obj).attr('rel') == 'lightbox')
		$(obj).lightBox();
	});
}

//main jquery hook-up function
$(document).ready(
	function() {
		init_lightbox();
		init_comments();
	}
);