$(function(){	
	//	Stripe Comments
	$(".divComment:even").addClass("divCommentEven");
	$(".divComment:odd").addClass("divCommentOdd");
	
	//	Save the Comment
	//	pre-submit callback
	function preSubmit(formData, jqForm, options){
		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' 
	       } }); 
		return true;
	}
	//	post-submit callback
	function postSubmit(responseText, statusText){
		$.unblockUI();
		$.prompt(responseText);
		$("#frmComment").resetForm();
	}
	$("#frmComment").ajaxForm({beforeSubmit:preSubmit, success:postSubmit, url:"/resources/library/processors/commentProc/proc.saveBlogComment.php", type:"post"});
});
