// Save Rating (Method)
function RefreshRatings(EpisodeID) {
	new Ajax.Updater('rating', 'Tools/RefreshRating.asp', {
		method:		'post',
		postBody: 	'EpisodeID=' + EpisodeID
	});
}

// Save Rating (Method)
function SaveRating(EpisodeID, Rating) {
	new Ajax.Updater('rating_confirm', 'Tools/SaveRating.asp', {
		method:		'post',
		postBody: 	'EpisodeID=' + EpisodeID + 
					'&Rating=' + Rating
	});

	RefreshRatings(EpisodeID);
}


// Save Comment (Method)
function SaveComment(EpisodeID) {
	if (document.getElementById('AddComment_EMail').value == null || document.getElementById('AddComment_EMail').value == '') {
		document.getElementById('login_required').style.display = 'block';
	} else {
		// Hide the login required div, and save comment
		document.getElementById('login_required').style.display = 'none';
		document.getElementById('preview_comment').style.display = 'none';
		new Ajax.Updater('AddComment_Response', 'Tools/SaveComment.asp', {
			method:		'post',
			postBody: 	'EpisodeID=' + EpisodeID + 
						'&Comments=' + escape(document.getElementById('Comments').value) + 
						'&AddComment_EMail=' + escape(document.getElementById('AddComment_EMail').value) + 
						'&AddComment_NickName=' + escape(document.getElementById('AddComment_NickName').value),
			onLoading: function(e) {
				document.getElementById('AddComment_Response').innerHTML = 'Posting. Please wait...';
			}
		});
	}
}

// Preview Comment (Method)
function PreviewComment() {
	if (document.getElementById('AddComment_EMail').value == null || document.getElementById('AddComment_EMail').value == '') {
		document.getElementById('login_required').style.display = 'block';
	} else {
		document.getElementById('preview_comment').style.display = 'block';
		document.getElementById('preview_username').innerHTML = document.getElementById('AddComment_NickName').value;
		document.getElementById('preview_comment_text').innerHTML = document.getElementById('Comments').value;
	}
}
