$().ready(function() {
	
	//jquery validations
	$("#addComment").validate({
		rules: {
			name: {
				required: true,
				minlength: 3
			},
			content: 'required',
			security_code: 'required'
		},		
		messages: {
			name: {
				required: "Please give your name",
				minlength: "The name must consist of at least 3 characters"
			},
			content: "Please give your comment",
			security_code: "Please enter the security code"
		},
		invalidHandler: function(form, validator) {
			setTimeout('$.fn.colorbox.resize()', 5);
		}
	});

	$('.show_comment').click(function(e) {
		e.preventDefault();

		$.fn.colorbox({
			href: '#add_comment',
			inline: true,
			scrolling: false,
			iframe: false,
		});

		$("#addComment .item_id").val($(this).attr('rel'));
	});
	
	//approval confirmation
	$(".comment_approve").click(function() {
		return confirm('Are you sure you wish to approve this comment?');
	});
	
	//deactivation confirmation
	$(".comment_deactivate").click(function() {
		return confirm('Are you sure you wish to deactivate this comment?');
	});
	
	//delete confirmation
	$(".comment_delete").click(function() {
		return confirm('Are you sure you wish to delete this comment?');
	});
});
