CommentsManager = function(field_id, controllerPath){
    this.field_id = field_id
    this.controllerPath = controllerPath
    }

CommentsManager.prototype.add = function (image, userid){
    var commentField = document.getElementById('commentToAdd'+this.field_id)
    var comment = commentField.value
    var d = doSimpleXMLHttpRequest(this.controllerPath+"/add?id="+image+"&comment="+comment+"&userid="+userid+"&field_id="+this.field_id);
    commentField.value = ''
    d.addCallback(bind("update", this));
}

CommentsManager.prototype.get = function(imageid){
    var d = loadJSONDoc(this.controllerPath+"/update?id="+imageid);
    d.addCallback(bind("update", this));
    }

CommentsManager.prototype.del = function(commentid, imageid, userid){
    var d = doSimpleXMLHttpRequest(this.controllerPath+"/delete?id="+commentid+"&imageID="+imageid+"&userid="+userid+"&field_id="+this.field_id);
    var f = this.field_id
    d.addCallback(bind("update", this));
}

CommentsManager.prototype.update = function(result){
    e = document.getElementById("comments"+this.field_id)
    e.innerHTML =  result.responseText
}


