﻿function AddComment(ObjectId, ObjectTypeId, ActionId, Body)
{
	var url = '/Global/Services/Comments.asmx/AddIn';
    var type = '';
     
	switch(ObjectTypeId)
	{
		case 5000:
			type = 'post';												
			break;
			
		case 2002:
			type = 'photo';									
			break;

		case 2001:
			type = 'video';						
			break;

		case 13000:
			type = 'presentation';									
			break;
	}
	new Ajax.Request(url,
	{
	    method: 'post', parameters: { Type: type, ObjectId: ObjectId, Body: Body},
	    onSuccess: function(transport) {}
	});
    
    document.getElementById('commentario_'+ActionId).style.display = 'block';
    document.getElementById('Comment_'+ActionId).innerHTML = document.getElementById('line_'+ActionId).value;
    document.getElementById('commentarioBegin_'+ActionId).style.display = 'none';
    document.getElementById('CommentButton_'+ActionId).style.display ='none'; 
}

function ShowContentComment(ActionId)
{
    document.getElementById('commentarioBegin_'+ActionId).style.display = 'block';
    document.getElementById('line_'+ActionId).value = '';
    document.getElementById('line_'+ActionId).focus(); 
    document.getElementById('CommentButton_'+ActionId).style.display = 'none';
}

function HideContentComment(ActionId)
{
    if (document.getElementById('line_'+ActionId).value == '')
    {
        document.getElementById('commentarioBegin_'+ActionId).style.display = 'none';
        document.getElementById('CommentButton_'+ActionId).style.display = 'block';  
    }
}

function cambio(e, pre, post,id)
{
    var element = document.getElementById('line_' + id).value
    n = element.length;
    t = 164;
    if (n > t)
    {
        document.getElementById('line_' + id).value = document.getElementById('line_' + id).value.substring(0, t);
        document.getElementById('cont_' + id).innerHTML = post + ' ' + num + ' ' + pre; 
    }
    else
    {
        num = t - n;
        document.getElementById('cont_' + id).innerHTML = post + ' ' + num + ' ' + pre;
    }
}
