$(function(){	
	//	Stripe Comments
	$(".divComment:even").addClass("divCommentEven");
	$(".divComment:odd").addClass("divCommentOdd");
	
	$("#commentSubmit").live('click', function(){
		var authorName = $("#author_name").val();
		var authorEmail = $("#author_email").val();
		var captchaTxt = $("#captcha_text").val();
		var content = $("#comment_content").val();
		var containingId = $("#containing_id").val();
		var errorMsg = '';
		//	If the containingId is empty, stop and have the user refresh browser.
		if(containingId == ''){
			$.prompt("ERROR:  Please refresh your browser window.");
			return false;
		}
		
		if(authorName == ''){
			errorMsg = errorMsg + "Please enter your name.<br/>";
		}
		
		if(authorEmail == ''){
			errorMsg = errorMsg + "Please enter your email.<br/>";
		}
		if(captchaTxt == ''){
			errorMsg = errorMsg + "Please enter the text you see in the image.<br/>";
		}
		else{
			$.ajax({
				type: "POST",
				url: "/resources/library/classes/Captcha/image_proc.php",
				data: "captchaTxt=" + captchaTxt,
				async: false,
				success: function(data){
					if(whiteSpace(data) != "true"){
						errorMsg = errorMsg + "Your text doesn't match the text in the image. You can click the image to refresh the text.<br/>";
					}
				}
			});
		}
		
		if(content == ''){
			errorMsg = errorMsg + "Please enter your comment.<br/>";
		}
					
		if(errorMsg != ''){
			$.prompt(errorMsg);
			return false;
		}
		$.blockUI({ css: { 
	           border: 'none', 
	           padding: '15px', 
	           backgroundColor: '#000', 
	           '-webkit-border-radius': '10px', 
	           '-moz-border-radius': '10px', 
	           opacity: '.5', 
	           color: '#fff' 
	       } }); 
	       
	       $.post('/resources/library/processors/commentProc/proc.saveEpisodeComment.php',{author_name: authorName, author_email: authorEmail, comment_content: content, containing_id: containingId}, function(responseText){
		       	$.unblockUI();
		       	$.prompt(responseText);
		       	$("#frmComment").resetForm();
	       });
	       return false;
	});
});