 
 function getHost() {
	 var a = document.URL.split("//"); // split at protocol
	 a = (a[1] ? a[1] : a[0]).split("/");
	 return a[1];
 }
 
 var track = 0;							// Track the reply 
 var posted_comment = "";				// Comment text
 var click_count = 0;					// User can not click more than once
 var textFieldValue = 0;				// Can not post a blank reply 
 var ajaxPost = 0; 						// Only a single post is allowed
 var req_path = (document.location.host == 'www.effinfunny.com' || document.location.host == 'effinfunny.com') ? ( '/' ) : ( '/' + getHost() + '/' );

 $(document).ready(function(){ 
	$(".comment_submit").click(function(){
	//var comment_node_id = $('#edit-comment-node-id-track').val();	// Comment node id
	$("textarea").each(function(){
		if(this.value) {
			posted_comment = this.value;
		}
	});	
	
	if(!textFieldValue ) {
		
		// do nothing
	} else if(click_count == 0 && !ajaxPost) {
		
		$(".comment_submit").attr("disabled", "disabled").addClass("comment_submit_disabled"); // disable the button 
		
		click_count++;
		ajaxPost = 1;
		$("#quote").fadeIn("slow");						 
		$.ajax({
		   type: "post",
		   url: req_path + "ajax_comment/reply",
		   data: "form_id=" + $('#edit-comment-form').val() + "&form_comment=" + posted_comment + "&form_token=" + $('#edit-comment-form-form-token').val() + "&submit=Post Comment&form_op=Post Comment&form_node_id=" + comment_node_id + "&form_reply_id=" + track + "&centered=" + captcha,
		   success: function(msg){
				$("textarea").each(function(){
					this.value = "";
				});
				track = 0;
				$("#quote").fadeOut("slow");
				$("textarea").each(function(){
					$("textarea").val(msg).attr("disabled", true);
				});
		   }
		 });	
	 } else if(click_count > 0) { 
	  		if(!ajaxPost) {
	  			alert("Please do not click on the post comment button more than once."); 
				click_count = 0;
			}
	  }
	  
	  return false;
   });
 });

