//###########################################################################################
//###########################################################################################
//###########################################################################################
//###########################################################################################
//#############                                                                                                                                                  #############
//#############                                                                                                                                                  #############
//#############				© Sinful Feelings.com                                                                                          #############
//#############				                                                                                                                         #############
//#############                                                                                                                                                  #############
//###########################################################################################
//###########################################################################################
//###########################################################################################
//###########################################################################################


var now = new Date();	
var now_D = now.getDate();
var now_M = now.getMonth();
var now_Y = now.getYear();


	
function get_comment_form(post_id_numb){
	var comment_form = "<div id='waiting'><form style='margin-top: 0; margin-bottom: 0;'  name='comment_submission_form'><textarea class='mediumblack' name='comment' cols='60' rows='5'></textarea> <input class='mediumblack' type='button' onclick='submitted_comment_CALL(\""+post_id_numb+"\")' value='Reply'></form></div>";
	document.getElementById('feed_back_from_getting_comment_form'+post_id_numb).innerHTML = comment_form;
	}
	
	
function get_comment_reply_form(comment_id_numb,post_id_numb,name,email,reply_form_index_number){
	var reply_form = "<br><br><table class='medium' border='0' width='475' cellpadding='5' bgcolor='black' style='color:white'><tr><td align='left' colspan='2'>"+name+":<br><textarea name='visitors_reply' rows='3' cols='55'></textarea></td></tr><tr><td align='left' valign='top'><input type='checkbox' name='keep_me_updated' value='y'> Notify me of followup comments via email ("+email+")<br><img src='/images/filler.gif' alt='' width='400' height='0' border='0' alt='0'></td><td align='left' width='100%'>	<input type='button' value='Reply' onClick='update_comments(\""+reply_form_index_number+"\")';></td></tr></table>";
	document.getElementById('feedback_from_getting_reply_form'+comment_id_numb).innerHTML = reply_form;
	}



// sending a server request
function getXMLHTTPRequest(){
	var req = false;
	try{req = new XMLHttpRequest();} /*  e.g. Firefox  */
	catch(err1){
		try{req = new ActiveXObject("Msxm12.XMLHTTP");} /*  some versions IE  */
		catch(err2){ 
			try{req = new ActiveXObject("Microsoft.XMLHTTP");} /*  some versions IE  */
			catch(err3){req = false;}
			}
		}
	return req;
	}
var myRequest = getXMLHTTPRequest();

	
function submitted_sin_CALL(){
	var description = document.sin_submission_form.description.value;
	//description = description.replace(/\'/g, "");
	
	var url = "/cgi-bin/submit.pl?do=sin_processor&description=" + encodeURIComponent(description);
//	alert(url);
	var myRandom=parseInt(Math.random()*99999999);
	myRequest.open("GET", url + "&rand=" + myRandom, true);
	myRequest.onreadystatechange = submitted_sin_RESPONSE;
	myRequest.send(null);
	}
function submitted_sin_RESPONSE(){
	if(myRequest.readyState == 4){
		document.getElementById('waiting').innerHTML = '';
		if(myRequest.status == 200){
			var value = myRequest.responseText; 
			document.getElementById('feedback_from_submitting_confession').innerHTML = value;
			}
		else{
			alert("An error has occurred: " + myrequest.statusText);
			}
		}
	else{
		document.getElementById('waiting').innerHTML = '<img src="http://www.schoolclipart.net/images/throbber.gif">';
		}
	}





function submitted_comment_CALL(post_id_numb){
	var comment = document.comment_submission_form.comment.value;
	//comment = comment.replace(/\'/g, "");

	
	var url = "/cgi-bin/submit.pl?do=comment_processor&comment=" + encodeURIComponent(comment) + "&post_id_numb=" + post_id_numb;
//	alert(url);
	var myRandom=parseInt(Math.random()*99999999);
	myRequest.open("GET", url + "&rand=" + myRandom, true);
	myRequest.onreadystatechange = submitted_comment_RESPONSE;
	myRequest.send(null);
	}
function submitted_comment_RESPONSE(){
	if(myRequest.readyState == 4){
		document.getElementById('waiting').innerHTML = '';
		if(myRequest.status == 200){
			var value = myRequest.responseText; 
			var value_array = value.split('||');
			document.getElementById('feedback_from_submitting_comment'+value_array[0]).innerHTML = value_array[1];
			}
		else{
			alert("An error has occurred: " + myrequest.statusText);
			}
		}
	else{
		document.getElementById('waiting').innerHTML = '<img src="http://www.schoolclipart.net/images/throbber.gif">';
		}
	}
	
	
	
	
	
function comment_being_rated(comment_id,rating){
	document.getElementById('comment_feedback'+comment_id).innerHTML = 'Thanks!';
	var url = "/cgi-bin/submit.pl?do=comment_rating_processor&comment_id=" + encodeURIComponent(comment_id) + "&rating=" + rating;
//	alert(url);
	var myRandom=parseInt(Math.random()*99999999);
	myRequest.open("GET", url + "&rand=" + myRandom, true);
	myRequest.onreadystatechange = comment_being_rated_RESPONSE;
	myRequest.send(null);
	}
function comment_being_rated_RESPONSE(){
	if(myRequest.readyState == 4){
		//document.getElementById('waiting').innerHTML = '';
		if(myRequest.status == 200){
			var value = myRequest.responseText; 
			var value_array = value.split('||');
			document.getElementById('comment_feedback'+value_array[0]).innerHTML = value_array[1];
			}
		else{
			alert("An error has occurred: " + myrequest.statusText);
			}
		}
	else{
		//document.getElementById('waiting').innerHTML = '<img src="http://www.schoolclipart.net/images/throbber.gif">';
		}
	}
