﻿function ShowForm()
{
    $('#profile-comment-ta').css({'height' : '40'});
    $('#form-button-holder').show();
}

function HideForm()
{
    var ta = document.getElementById('profile-comment-ta');
    if(ta != null && ta.value.length > 0) return;
    
    $('#form-button-holder').hide();
    $('#profile-comment-ta').css({'height' : '25'});
}

function ShowReplyForm(commentid)
{
    var ta = document.getElementById('reply-ta-' + commentid.toString());
    if(ta == null) return;

    if(ta.value == 'Write something ...') ta.value = '';
        
    $('#reply-ta-' + commentid.toString()).css({'height' : '40', 'color' : 'black'});
    $('#reply-button-' + commentid.toString()).show();
}

function HideReplyForm(commentid)
{
    var ta = document.getElementById('reply-ta-' + commentid.toString());
    if(ta == null) return;

    if(ta.value.length > 0) return;
    
    ta.value = 'Write something ...';
    $('#reply-ta-' + commentid.toString()).css({'height' : '25', 'color' : '#CCC'});
    $('#reply-button-' + commentid.toString()).hide();
}



function DeleteComment(commentid, div)
{
    var params = new Array();
    
    params[0] = 'comment-id=' + commentid.toString();
    
    var a = new AjaxCall('profile.comment.delete', params);

    a.sessionid = 'xx-xx';
    a.resulttype = 'xml';
    
    var line = document.getElementById(div);
    if(line != null)
    {
        $('#' + div).fadeOut(200, function()
        {
            line.parentNode.removeChild(line);
        });
    }
    
    a.Send(function(result)
    {
        //
    });
}

function DeleteStatusUpdate(id, div)
{
    var params = new Array();
    
    params[0] = 'id=' + id.toString();
    
    var a = new AjaxCall('statusupdate.delete', params);

    a.sessionid = 'xx-xx';
    a.resulttype = 'xml';
    
    var line = document.getElementById(div);
    if(line != null)
    {
        $('#' + div).fadeOut(200, function()
        {
            line.parentNode.removeChild(line);
        });
    }
    
    a.Send(function(result)
    {
        //alert(result);
    });
}

function DeleteCommentReply()
{
    var params = new Array();
    
    params[0] = 'comment-id=' + commentid.toString();
    
    var a = new AjaxCall('profile.comment.reply.delete', params);

    a.sessionid = 'xx-xx';
    a.resulttype = 'xml';
    
    var line = document.getElementById(div);
    if(line != null)
    {
        $('#' + div).fadeOut(200, function()
        {
            line.parentNode.removeChild(line);
        });
    }
    
    a.Send(function(result)
    {
        //
    });
}

