function kaComments(article, reviewsContainerId, writeContainerId, mediaType) {
	if(mediaType == '' || mediaType == undefined || mediaType == null) {
		mediaType = 'emedia';
	}

	if(reviewsContainerId == '' || reviewsContainerId == undefined || reviewsContainerId == null) {
		reviewsContainerId = '.reviews .page-reviews';
	}

	if(writeContainerId == '' || writeContainerId == undefined || writeContainerId == null) {
		writeContainerId = '.reviews .write-review form';
	}

	// Setup default variables
	var articleId = article;

	var containerId = containerId;

	var mediaType = mediaType;

	var cookieName = 'ArticleComment';

	var keepWaiting = true;

	var ratingInterval;

	var init = function() {
		checkReviewCookie(function() {
			bindWriteRating();

			$(reviewsContainerId).find('.comment-pager a').live('click', function() {
				var target = $(this);

				$(reviewsContainerId).find('.review-page').fadeOut(function() {
					$(reviewsContainerId).find('.reviews-page-' + $(target).attr('rel')).fadeIn();
					
					$('span.currentCommentPage').html($(target).attr('rel'));
				});

				return false;
			});
		});
	}

	var checkReviewCookie = function(callback) {
		var ratingCookie = $.cookie('ArticleComment_' + articleId);

		if(ratingCookie != false) {
			if(typeof callback == 'function') {
				callback();
			}
		} else {
			var isNarrow = $('input[name="get-comments-narrow"]').val();
			
			$.get('/kickapps/public/get-comments/id/' + articleId + '/ajax/1/narrow/' + isNarrow, function(response) {
				$(reviewsContainerId).fadeOut(function() {
					$(this).html(response).fadeIn(function() {
						if(typeof callback == 'function') {
							callback();
						}
					});
				});
			});
		}
	}

	var bindWriteRating = function() {
		$(writeContainerId).unbind('submit').bind('submit', function() {
			var comments = getComments();

			if(comments != false) {
				addComment(comments);
			} else {
				alert('Please enter text before submitting.');
			}

			return false;
		});
	}

	var getComments = function() {
		var comments = $(writeContainerId).find('textarea[name="comments"]').val();

		if(comments != '' && comments != null && comments != undefined) {
			return comments;
		}

		return false;
	}

	var addComment = function(comments) {
	$.post('/kickapps/public/add-comment', { media: articleId, comments: comments }, function(response) {

		if(response == 'success') {
			var isNarrow = $('input[name="get-comments-narrow"]').val();
			
			$.get('/kickapps/public/get-comments/id/' + articleId + '/ajax/1/narrow/' + isNarrow, function(response) {
				$(writeContainerId).find('textarea').val('');

				$(reviewsContainerId).fadeOut(function() {
					$(this).html(response).fadeIn(function() {
						bindWriteRating();
					});
				});
			});
		} else {
			if(response == 'notlogged') {
				jQuery.get('/kickapps/public/ajax-login', function(data) {
					jQuery.facebox(data, 'faceboxRegistration');
				});
			} else {
				alert('There was a general error: ' + response);
			}
		}

	});
}

init();
}