﻿function AcceptFriend(Id) {
    var url = '/Friend/Friend.ashx?Accept&Format=json';												
					new Ajax.Request(url, {method: 'post', parameters: { FriendId: Id },												
									 onSuccess: function(transport) {     
                					 var rsp = transport.responseText.evalJSON().rsp;
								if(rsp.stat != 'fail')
									alert(rsp.err.msg);

																			
                        } });
                        
        document.getElementById('Aceptar_' + Id).style.display = "none";
        document.getElementById('Ignorar_' + Id).style.display = "none";
        document.getElementById('FeedBack_True_' + Id).style.display = "block";
}
 function Ignore(Id, UserName, LastName) { 
	if(!confirm('¿Estás seguro que quieres borrar a '+ UserName + ' ' + LastName + ' de tu lista de contactos?'))
	{
	 
	}
	else
	{
		var url = '/Friend/Friend.ashx?Ignore&Format=json';												
						new Ajax.Request(url, {method: 'post', parameters: { FriendId: Id },												
										 onSuccess: function(transport) {     
										 var rsp = transport.responseText.evalJSON().rsp;
									if(rsp.stat != 'fail')
										alert(rsp.err.msg);
							} });
							document.getElementById('LabelName' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelBody' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelVisitas' + Id).style.textDecoration = "line-through";
							
							document.getElementById('LabelAmigos' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelFotos' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelVideos' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelNotas' + Id).style.textDecoration = "line-through";
							document.getElementById('LabelNotas' + Id).style.textDecoration = "line-through";
							document.getElementById('Img' + Id).src = "../images/usuario_eliminado.gif";
	}
}

 function IgnoreFriend(Id, UserName, LastName) {
	if(!confirm('¿Estás seguro que quieres ignorar a '+ UserName + ' ' + LastName + ' de tu lista de contactos?'))
	{
	 
	}
	else
	{
		var url = '/Friend/Friend.ashx?Ignore&Format=json';												
						new Ajax.Request(url, {method: 'post', parameters: { FriendId: Id },												
										 onSuccess: function(transport) {     
										 var rsp = transport.responseText.evalJSON().rsp;
									if(rsp.stat != 'fail')
										alert(rsp.err.msg);
							} });
		document.getElementById('Aceptar_' + Id).style.display = "none";
		document.getElementById('Ignorar_' + Id).style.display = "none";
		document.getElementById('FeedBack_False_' + Id).style.display = "block";    
	}                   
}

 function DeleteFriend(ParentContactId, ChildContactId, CommunityId) {
 	if(!confirm('¿Estás seguro que quieres borrar a tu amigo de tu lista de contactos?'))
	{
	 
	}
	else
	{
     var url = '/Delete.asmx/DeleteFriend';
        new Ajax.Request(url, 
        {
		    method: 'post', 
		    parameters: 
		    { 
			    ParentContactId: ParentContactId,
			    ChildContactId: ChildContactId,
                CommunityId : CommunityId
		    },
		    onSuccess: function(transport) {
			    if(transport.status == 200)
			    {
				    if (transport.responseXML.getElementsByTagName("ut_response")[0].attributes[0].value == 'fail')
				    {
					    var errorCode = transport.responseXML.documentElement.getElementsByTagName("error")[0].attributes[0].value;
					    var errorMge = transport.responseXML.documentElement.getElementsByTagName("error")[0].attributes[1].value;
					    alert(errorCode+'-'+errorMge);
				    }
				    else
				    {
				        window.top.location.reload();
				    }
			    }
		    }
	    });
	}
 }