function addCommentForm(commentsSpot,user,url,listID,listItemID,userID) {
	results=document.getElementById(commentsSpot);

	if(user)
	{
	 	var cmtForm = '<form name="form' + listItemID + '" action="http://www.10to1.com/' + url + '" method="POST" id="commentForm" onsubmit="return addThisComment(\'' + 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="listItemID" id="listItemID" value="' + listItemID + '"> ' +
	 	'<textarea name="newComment" id="newComment' + listItemID + '" rows="2" class="commentBox" style="width:93%"></textarea><br /> ' +
	 	'<input id="addComment' + listItemID + '" name="addComment' + listItemID + '" type="submit" value="Add Comment" /> ' +

	 	'</form>';

	 	results.innerHTML = cmtForm;

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

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

				// load the SimpleEditor..
				var myEditor = new YAHOO.widget.SimpleEditor('newComment' + listItemID, myConfig);
				myEditor._defaultToolbar.buttonType = 'advanced';
				myEditor.render();

				//Inside an event handler after the Editor is rendered
				YAHOO.util.Event.on('addComment' + listItemID, 'click', function() {
				    //Put the HTML back into the text area
				    myEditor.saveHTML();
				    //The var html will now have the contents of the textarea
				    var html = myEditor.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
				//		    myEditor.saveHTML();
				//		    var html2 = myEditor.get('element').value;
				//		});
		})();
*/
	} else {

	 	var cmtForm = '<form name="form' + listItemID + '" action="http://www.10to1.com/login.php" method="GET" onsubmit="return popupMsg(event,\'loginPopup\',\'<b>Want to comment on this list?</b> &nbsp;Please <a href=\\\'http://www.10to1.com/login.php\\\'>login</a> or <a href=\\\'http://www.10to1.com/register.php\\\'>join 10to1</a> for free.\');"> ' +
	 	'<textarea onclick="return popupMsg(event,\'loginPopup\',\'<b>Want to comment on this list?</b> &nbsp;Please <a href=\\\'http://www.10to1.com/login.php\\\'>login</a> or <a href=\\\'http://www.10to1.com/register.php\\\'>join 10to1</a> for free.\');" rows="2" class="commentBox" style=\'width:93%\'></textarea> ' +
	 	'<input type="submit" value="Save Comment"/> ' +
	 	'</form>';

	 	results.innerHTML = cmtForm;
	}
}


function addThisComment(listID,listItemID,userID) {
	var ajax = getXMLHttpRequestObject();
	if(ajax) {
		results='addCommentResults'+listItemID;
		results=document.getElementById(results);
		results.innerHTML = '<img src="http://www.10to1.com/Images/Site_Images/animate/w6.gif">';
		comment='newComment'+listItemID;
		ajax.open('post', 'http://www.10to1.com/addComment.php');
		ajax.onreadystatechange = function() {
			handleCResponse(ajax,results,comment,listID,listItemID);
		}
		var values = 'listID='+encodeURIComponent(listID)+'&listItemID='+encodeURIComponent(listItemID)+'&userID='+encodeURIComponent(userID)+'&newComment='+encodeURIComponent(document.getElementById(comment).value);
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.send(values);

		// Hide that fancy text editor!
		showHide('showComments' + listItemID, 'hideComments' + listItemID);
		showHide('', 'commentsSpot' + listItemID);

		return false;
	}
}
function handleCResponse(ajax,results,comment,listID,listItemID) {
	if(ajax.readyState == 4) {
		if((ajax.status == 200) || (ajax.status == 304)) {
			if(ajax.responseText=='Your Comment Has Been Successfully Added')
			{
				results.innerHTML=''; /* Clear "Updating Comments" */
				document.getElementById(comment).value='';
				/* 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()
				{
					handleComments(ajax,listItemID);
				}
				ajax.send(null);
				/* End of Grab Comments */
			}
			else
			{
				results.innerHTML=ajax.responseText;
			}
		}
		else
		{
			document.getElementById('commentForm').submit();
		}
	}
}
function handleComments(ajax,listItemID)
{
	if(ajax.readyState==4)
	{
		if((ajax.status==200)||(ajax.status==304))
		{
			results='displayComments'+listItemID;
			var results=document.getElementById(results);
			results.innerHTML=ajax.responseText;
		}
	}
}
