function expandcomment(mode,commentid,dest)
{
    var d = new Date();
    new Ajax.Updater(dest, '/comment_new/ajax/expand.asp', { 
        method: 'get',
        parameters: { mode: mode, id: commentid, dest: dest, timestamp: d.getTime() }
        });
}

function notify(dest,ownerid,ownertypeid,userid,mode)
{
    // Depending on the number of comments there may be TWO notify buttons, top and bottom (in separate span elements with ID=dest).
    // This code makes sure they all toggle.
    var d = new Date();
    new Ajax.Request('/comment_new/ajax/notify.asp', { //NB NOT Ajax.Updater
        method: 'get',
        parameters: { o: ownerid, t: ownertypeid, u: userid, mode: mode, timestamp: d.getTime() },
        onSuccess: function(transport) {
            var f = $$('.'+dest); //CSS rule to match all elements whose class is dest
	        for(var i=0; i<f.length; i++){ //loop and update
		        f[i].update(transport.responseText)
	        }
            }
        });
}

function savecomment(mode,form,adest)
{
    var d = new Date();
    new Ajax.Updater(adest, '/comment_new/ajax/save.asp', { 
        method: 'get',
        parameters: {
        mode: mode,
        u: form.userid.value, 
        c: form.c.value, 
        o: form.o.value, 
        t: form.t.value, 
        username: form.username.value, 
        rank: form.rank.value,
        status: form.status.value,
        interesting: form.interesting.value,
        reviewed: form.reviewed.value,
        reason: form.reason.value,
        commentbody: form.commentbody.value, 
        notify: form.notify.value,
        adest: adest, 
        timestamp: d.getTime() }
        });
}

function comments(mode,ownerid,ownertypeid,idest,adest,commentcount,userid,post)
{
    document.body.style.cursor = 'wait';
    showcomments(mode,ownerid,ownertypeid,userid,idest,adest,commentcount,post);
    if(idest!='') {
        var d = new Date();
        new Ajax.Updater(idest, '/comment_new/ajax/icon.asp', { 
            method: 'get',
            parameters: { mode: mode, o: ownerid, t: ownertypeid, idest: idest, adest: adest, c: commentcount, u: userid, post: post, timestamp: d.getTime() }
            });
    }
    document.body.style.cursor = 'default';
}

function showcomments(mode,ownerid,ownertypeid,userid,idest,adest,commentcount,post)
{
    var d = new Date();
    new Ajax.Updater(adest, '/comment_new/ajax/show.asp', { 
        method: 'get',
        parameters: { mode: mode, o: ownerid, t: ownertypeid, u: userid, idest: idest, adest: adest, c: commentcount, post: post, timestamp: d.getTime() }
        });
}