
var actionLinks = [{ "text": document.getElementById(""), "href": "http://" + window.location.host}];


function NoteAddComment(ObjectId,Body,IsModerate, docl, nocomm,commcomm) {

  var Moderation = document.getElementById('Ismoderate').value;
var status = "";
if (IsModerate == 'true')
    status = "P";
else
    status = "A";
    
	if (Body == docl)
		alert(nocomm);
	else {
		var CommunityId = document.getElementById('CommunityId2').value;
		var url = '/Global/Services/Comments.asmx/AddInNote';												
		new Ajax.Request(url, {method: 'post', parameters: { ObjectId: ObjectId, Body: Body, CommunityId: CommunityId, Status: status },												
            onSuccess: function(transport) {     
                var rsp = transport.responseText.evalJSON().rsp;
                if(rsp.stat != 'fail')
                    alert(rsp.err.msg);
			}});
		document.getElementById('commentario_Begin').style.display = 'none';
		document.getElementById('commentario_End').style.display = 'block';
		
		if (Moderation == 'True')
		{
		    document.getElementById('comentario_pendiente').style.display = 'block';
		}
		document.getElementById('Body').innerHTML = document.getElementById('line').value;
		
		if(document.getElementById('checkFaceShare'))
		{
		    if(document.getElementById('checkFaceShare').checked)
	        {
	            var title = document.getElementById('communityTitle').value;
	            callPublish('',{'name':commcomm + title,'href':window.location.href,'description':Body},actionLinks);
	        }
	    }
	}
}

function DeleteComment(ObjectId,ObjectTypeId,Id)
{
    var url = '/Global/Services/Comments.asmx/CommentDel';												
					new Ajax.Request(url, {method: 'post', parameters: { ObjectId: ObjectId, ObjectTypeId: ObjectTypeId, Id: Id },												
									 onSuccess: function(transport) {     
                					 var rsp = transport.responseText.evalJSON().rsp;
								if(rsp.stat != 'fail')
									alert(rsp.err.msg);

																			
                        } });
                 
}


function NoteApproval(Id,ObjectId)
{

    var url = '/Global/Services/Comments.asmx/NoteApproval';												
					new Ajax.Request(url, {method: 'post', parameters: { Id: Id, ObjectId: ObjectId},
									 onSuccess: function(transport) {     
                					 var rsp = transport.responseText.evalJSON().rsp;
								if(rsp.stat != 'fail')
									alert(rsp.err.msg);

																			
                        } });

}

function NoteDesapproval(Id,ObjectId)
{

    var url = '/Global/Services/Comments.asmx/NoteDesapproval';												
					new Ajax.Request(url, {method: 'post', parameters: { Id: Id, ObjectId: ObjectId},												
									 onSuccess: function(transport) {     
                					 var rsp = transport.responseText.evalJSON().rsp;
								if(rsp.stat != 'fail')
									alert(rsp.err.msg);

																			
                        } });
                 
}


function NoteBloqUser(Id,ObjectId)
{

    var url = '/Global/Services/Comments.asmx/NoteBloqUser';												
					new Ajax.Request(url, {method: 'post', parameters: { Id: Id, ObjectId: ObjectId},												
									 onSuccess: function(transport) {     
                					 var rsp = transport.responseText.evalJSON().rsp;
								if(rsp.stat != 'fail')
									alert(rsp.err.msg);

																			
                        } });
                 
}

function refresh(doc)
    {
     if (document.getElementById('line').value == doc)
        document.getElementById('line').value = '';
    }

    function checkEmpty(doc)
{
    var element = document.getElementById('line').value;
    if(element == '')
    {
        document.getElementById('line').value = doc;
    }
}

function cambio(e, pre, post) 
{

    var element = document.getElementById('line').value
    n = element.length;
    t = 164;
    if (n > t) {
        document.getElementById('line').value = document.getElementById('line').value.substring(0, t);
        document.getElementById('cont').innerHTML = post + ' ' + num + ' ' + pre;
    }
    else {
        num = t - n;
        document.getElementById('cont').innerHTML = post + ' ' + num + ' ' + pre;
    }
}

function TestAddComment(ObjectId, Body, IsModerate, docl, commcomm)
{
    var status = "";
    if (Body == docl || Body == '')
    {
        status = "A";
        Body="";
    }
    else
    {
        if (IsModerate == 'true')
            status = "P";
        else
            status = "A";
    }

    var Title = document.getElementById('TitlecUserComment').innerHTML;
	var CommunityId = document.getElementById('CommunityId').value;
	var url = '/Global/Services/Comments.asmx/AddInTest';												
	new Ajax.Request(url, {method: 'post', parameters: { ObjectId: ObjectId, Body: Body, CommunityId: CommunityId, Status: status, Title: Title },												
					 onSuccess: function(transport) {     
					 var rsp = transport.responseText.evalJSON().rsp;
				if(rsp.stat != 'fail')
					alert(rsp.err.msg);
		} });
			
	document.getElementById('commentario_Begin').style.display = 'none';
	document.getElementById('commentario_End').style.display = 'block';
	document.getElementById('Body').innerHTML = document.getElementById('line').value;
	
	if(status == 'P') document.getElementById('comentario_pendiente').style.display = 'block';
	    
	if(document.getElementById('checkFaceShare').checked)
	{
	    var title = document.getElementById('communityTitle').value;
	    callPublish('',{'name':commcomm +title,'href':window.location.href,'description':Body},actionLinks);
	}
}

function callPublish(msg, attachment, action_link) 
{
    FB.ensureInit(function () {
        FB.Connect.streamPublish('', attachment, action_link);
    });
}
