
function SubmitComments()
{
  var url = "/Ajax/Comment";

  var comment  = document.forms['frmComments'].fldComments.value;
  var obj_id   = document.forms['frmComments'].objectID.value;
  var obj_type = document.forms['frmComments'].objectType.value;

  var params = "object_type=" + obj_type + "&object_id=" + obj_id + "&comment=" + escape(comment);
  url += '?' + params;
  makeHttpRequest(url, "add_comment", "GET", '', true );
}

function add_comment( responseXML )
{

  var status = responseXML.getElementsByTagName("status")[0].firstChild.data;

  if ( status == 'OK' ) {

    document.getElementById( 'comments' ).innerHTML = "<h2>Comment Added</h2>";

    var comment = responseXML.getElementsByTagName("comment")[0].firstChild.data;
    var cdate = responseXML.getElementsByTagName("comment_date")[0].firstChild.data;
    var ccomp = responseXML.getElementsByTagName("user_company")[0].firstChild.data;
    var cuser = responseXML.getElementsByTagName("user_name")[0].firstChild.data;


    var comment_html = '<p class="date_block">By ' + cuser;
    comment_html += '<span>' + cdate;
    if ( ccomp ) {
	comment_html += ' - ' + ccomp;
    }
    comment_html += '</span></p><p>' + comment + '</p><hr />';

    document.getElementById( 'new-comment' ).innerHTML = comment_html;
  }
  else {
  	var msg = responseXML.getElementsByTagName("message")[0].firstChild.data;
  }
}

