function addReplyForm(cID,replySection,replySection_2,replyLink,replyResults,uri,listID,listItemID,userID) {

	results=document.getElementById(replySection_2);

 	var replyForm = '<form name="form' + cID + '" action="http://www.10to1.com/' + uri + '" method="POST" id="replyForm" onsubmit="javascript:return addThisReply(\'' + cID + '\',\'' + listID + '\',\'' + listItemID + '\',\'' + userID + '\');"> ' +
 	'<input type="hidden" name="userID" id="userID" value="' + userID + '"> ' +
 	'<input type="hidden" name="listID" id="listID" value="' + listID + '"> ' +
 	'<input type="hidden" name="commentID" id="commentID" value="cID">' +
 	'<textarea name="reply" id="reply' + cID + '" rows="2" class="commentBox" style="width:93%"></textarea><br /> ' +
 	'<input id="addReply' + cID + '" name="addReply' + cID + '" type="submit" value="Add Reply" /> ' +
 	'<!--- a name="spellClick" id="spellClick" href="javascript:spellCheck(\'reply' + cID + '\');" class="blue12">&nbsp;&nbsp;Check Spelling</a ---> ' +
 	'</form>';

 	results.innerHTML = replyForm;
/*
	(function() {
		//Setup some private variables
		var Dom = YAHOO.util.Dom,
			Event = YAHOO.util.Event;

			//The SimpleEditor config
			var myConfig = {
				height: '140px',
				width: '100%',
				focusAtStart: true
			};

			// load the SimpleEditor..
			var myEditorRep = new YAHOO.widget.SimpleEditor('reply' + cID, myConfig);
			myEditorRep._defaultToolbar.buttonType = 'advanced';
			myEditorRep.render();

			//Inside an event handler after the Editor is rendered
			YAHOO.util.Event.on('addReply' + cID, 'click', function() {
			    //Put the HTML back into the text area
			    myEditorRep.saveHTML();
			    //The var html will now have the contents of the textarea
			    var html = myEditorRep.get('element').value;
			});

			//Inside an event handler after the Editor is rendered
			//		YAHOO.util.Event.on('spellClick', 'click', function() {
			//		    //Put the HTML back into the text area
			//		    myEditorRep.saveHTML();
			//		    var html2 = myEditorRep.get('element').value;
			//		});
	})();
*/
}



function addThisReply(commentID,listID,listItemID,userID) {
	var ajax = getXMLHttpRequestObject();
	if(ajax) {
		ajax.open('POST', 'http://www.10to1.com/addReply.php');
		ajax.onreadystatechange = function() {
			handleAddReply(ajax,commentID,listID,listItemID);
		}
		var reply = document.getElementById('reply'+commentID).value;
		var values = 'commentID='+ encodeURIComponent(commentID) +'&reply='+ encodeURIComponent(reply) +'&listID='+ encodeURIComponent(listID) +'&userID='+ encodeURIComponent(userID);
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.send(values);
		return false;
	}
}
function handleAddReply(ajax,commentID,listID,listItemID) {
	if(ajax.readyState == 4) {
		if((ajax.status == 200) || (ajax.status == 304)) {
			if(ajax.responseText=='Your Reply Has Been Successfully Added')
			{
				document.getElementById('reply'+commentID).value=''; /* Clear out reply box */
				/* End of update DB, now grab all comments */
				ajax.open('GET','http://www.10to1.com/getComments.php?listID='+ listID +"&listItemID="+ listItemID +"&" + Math.random());
				ajax.onreadystatechange=function()
				{
					handleAddReply2(ajax,commentID,listItemID);
				}
				ajax.send(null);
				/* End of Grab Comments */
			}
			else
			{
				var results = document.getElementById('replyResults'+commentID);
				results.innerHTML=ajax.responseText;
			}
		}
	}
}
function handleAddReply2(ajax,commentID,listItemID)
{
	if(ajax.readyState==4)
	{
		if((ajax.status==200)||(ajax.status==304))
		{
			results='displayComments'+listItemID;
			var results=document.getElementById(results);
			results.innerHTML=ajax.responseText;
			/* Switch out of add reply and show replies */
			var replyLink='replyLink'+commentID;
			var replySection='replySection'+commentID;
			var hideReplies='hideReplies'+commentID;
			var showReplies='showReplies'+commentID;
			var replySpot='replySpot'+commentID;
			showHide(replyLink,replySection);
			showHide(hideReplies,showReplies);
			showHide(replySpot,'');
		}
	}
}
