

function do_nothing(){return 0;}

function censor_comment(comment_id){

	var tool = document.getElementById("tool").value;
		

	// Build the URL to connect to
	var url = "responder.dwp?tool=" + escape(tool) +
						 "&event=censor_comment" +
						 "&comment_id=" + comment_id +
						 "&my_status=y" ;
	//alert(url);

	request.onreadystatechange = censor_comment_update;
	request.open('GET', url, true);
	request.send(null);

}


function censor_comment_update(){

				
	if (request.readyState == 4) {
						
		if (request.status == 200) {
		
			var response = request.responseText;
		
			//alert(response);

			my_lop = response.split(":");
			my_error = my_lop[0];
			my_id = my_lop[1];
			my_direction = my_lop[2];
			
			if(my_error=="1") alert("error");
			
			if(my_error == "0"){

				div = document.getElementById("comment_content_" + my_id);
				
				censor_text(div);
				
				span = document.getElementById("censor_link_" + my_id);
				
				censor_link(span, my_id);
				
				
			}else{
				alert("The setting was not changed on the server for some reason.");
			
			}
			
			request.abort(); // detach the current connection so we can reuse it (IE)
			
		}else{
			alert("ERROR from server. Responder URL not found. HTTP Error Code: " + request.status);
			
		} // end ok
	} // end if state
} // end censor_link_update



function censor_text(div){
	
	//alert(censor_text);

	// put censor message text into comment div
	div.innerHTML = '<div class="SM_censor_message">Censored</div>';

}


function censor_link(span, my_id){

	//alert(censor_link);

	// swap censor link
	my_censor_link = 'javascript:uncensor_comment('+my_id+');';
	 
	span.innerHTML = '[<a href="' + my_censor_link + '">Uncensor</a>]';

}



function uncensor_comment(comment_id){

	var tool = document.getElementById("tool").value;
		

	// Build the URL to connect to
	var url = "responder.dwp?tool=" + escape(tool) +
						 "&event=censor_comment" +
						 "&comment_id=" + comment_id +
						 "&my_status=n" ;
	//alert(url);

	request.onreadystatechange = uncensor_comment_update;
	request.open('GET', url, true);
	request.send(null);

}


function uncensor_comment_update(){

				
	if (request.readyState == 4) {
						
		if (request.status == 200) {
		
			var response = request.responseText;
		
			//alert(response);

			my_lop = response.split(":");
			my_error = my_lop[0];
			my_id = my_lop[1];
			my_direction = my_lop[2];
			
			if(my_error=="1") alert("error");
			
			if(my_error == "0"){

				div = document.getElementById("comment_content_" + my_id);
				
				uncensor_text(div);
				
				span = document.getElementById("censor_link_" + my_id);
				
				uncensor_link(span, my_id);
				
				
			}else{
				alert("The setting was not changed on the server for some reason.");
			
			}
			
			request.abort(); // detach the current connection so we can reuse it (IE)
			
		}else{
			alert("ERROR from server. Responder URL not found. HTTP Error Code: " + request.status);
			
		} // end ok
	} // end if state
} // end censor_link_update



function uncensor_text(div){
	
	//alert(censor_text);

	// put censor message text into comment div
	div.innerHTML = '<div class="SM_censor_message">Uncensored. Original message will appear.</div>';

}


function uncensor_link(span, my_id){

	//alert(censor_link);

	// swap censor link
	my_censor_link = 'javascript:censor_comment('+my_id+');';
	 
	span.innerHTML = '[<a href="' + my_censor_link + '">Censor</a>]';

}



function rate_comment(comment_id,vote_score){

	var tool = document.getElementById("tool").value;
	var member_id = document.getElementById("member_id").value;
		

	// Build the URL to connect to
	var url = "responder.dwp?tool=" + escape(tool) +
						 "&event=rate_comment" +
						 "&comment_id=" + comment_id +
						 "&vote_score=" + vote_score +
						 "&member_id=" + escape(member_id) ;
	//alert(url);

	request.onreadystatechange = rate_comment_update;
	request.open('GET', url, true);
	request.send(null);

}


function rate_comment_update(){

				
	if (request.readyState == 4) {
						
		if (request.status == 200) {
		
			var response = request.responseText;
		
			//alert(response);

			my_lop = response.split(":");
			my_error = my_lop[0];
			my_id = my_lop[1];
			my_rating = my_lop[2];
			my_total = my_lop[3];
			my_positives = my_lop[4];
			
			
		//	alert(my_query);
			
			if(my_error=="1") alert("error");
			
			if(my_error == "0"){

				div = document.getElementById("comment_rating_" + my_id);
							
				// put censor message text into comment div
				div.innerHTML = my_positives + ' out of ' + my_total + ' members like this comment.';

				
				
			}else{
				alert("The setting was not changed on the server for some reason.");
			
			}
			
			request.abort(); // detach the current connection so we can reuse it (IE)
			
		}else{
			alert("ERROR from server. Responder URL not found. HTTP Error Code: " + request.status);
			
		} // end ok
	} // end if state
} // end censor_link_update



