jQuery(document).ready(function()
{
	jQuery('a.showcomments').click(function()
	{
		jQuery('#comment_parent').val('0');
		showCommentForm();
		return false;
	});

	jQuery('#commentdialog').draggable();

	jQuery('#commentdialog a').click(function()
	{
		jQuery('#commentdialog').fadeOut();
		return false;
	});

	jQuery('#commentdialog form').submit(function()
	{
		var n = jQuery.trim(jQuery('#navn').val());
		var e = jQuery.trim(jQuery('#email').val());
		var k = jQuery.trim(jQuery('#comment').val());

		if(n == '' || e == '' || k == '')
		{
			jQuery('#error').text('Udfyld venligst felterne til både navn, email og kommentar.');
			jQuery('#error').fadeIn('slow');
			return false;
		}
		else
		{
			jQuery('#error').fadeOut();
			return true;
		}
	});
	
	jQuery('#comments li').hover(function()
	{
		jQuery(this).find('.fulldate').toggle();
		jQuery(this).find('.replylink').toggle();
	});
});

function showCommentForm()
{
	var h = jQuery(window).height();
	var w = jQuery(window).width();
	jQuery('#commentdialog').css('left', (w - 500) / 2 + 'px');
	jQuery('#commentdialog').css('top', (h - 360) / 2 + 'px');
	jQuery('#commentdialog').fadeIn();
}

function respondToComment(post_id, parent_id)
{
	jQuery('#comment_post_ID').val(post_id);
	jQuery('#comment_parent').val(parent_id);
	showCommentForm();
}
