// JavaScript Document

function com_comment_submit(setID){
	var comment = document.getElementById("commentTextField_"+setID).value;
	var parentID = document.getElementById("commentParentField_"+setID).value;
	var name = document.getElementById("commentNameField_"+setID).value;
	var email = document.getElementById("commentEmailField_"+setID).value;
	var location = document.getElementById("commentLocation_"+setID).value;
	
	if(name == ''){
		name = "Anonymous";	
	}
	
	if(comment == ''){
		document.getElementById("commentTextField_"+setID).focus();
		return false;
	}
	
	comment = comment.replace(/\n/g,"<br/>");
	
	var ajax = "components/com_comments/ajax.php?action=addComment&setID="+setID;
	ajax +=	   "&comment="+comment;
	ajax +=	   "&parentID="+parentID;
	ajax +=	   "&name="+name;
	ajax +=	   "&email="+email;
	ajax +=	   "&location="+location;
	
	executeAjax(ajax,"postComments_"+setID);
	document.getElementById("commentTextField_"+setID).value = "";
}



function com_comment_reply(commentID, name, setID){
	document.getElementById("commentParentField_"+setID).value = commentID;
	document.getElementById("commentType_"+setID).innerHTML = name == 'new' ? "Your Comment" : "Your Reply to "+name+" - <a href='javascript:;' onclick=\"com_comment_reply('0','new','"+setID+"')\">Cancel Reply</a>";
	document.getElementById("commentTextField_"+setID).focus();
}