﻿window.onload = function(){
   
}

function cekfriend(){
alert("silahkan login terlebih dahulu");
}


function addfriend(ln, friendLn){
      WCFMemberWall.JSON_insertFriend(ln, friendLn, insertFriendOnComplete, insertFriendOnError);

}


    function insertFriendOnComplete(result){
          if (result == "") {
          document.getElementById("divAddFren").innerHTML = "Friend requested";
          
          } else {
          document.getElementById("divAddFren").innerHTML = "Request Failed";
          }
    }  

   
    
    function insertFriendOnError(){
    
    }


function doApprove(friendLoginName){
      WCFMemberWall.JSON_approveFriend(friendLoginName, approveFriendOnComplete, approveFriendOnError);

}
    
    function approveFriendOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "Approve succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "Approve Failed";
          }
    }  
  
    function approveFriendOnError(){   
    }
    
function doIgnore(loginName){
  WCFMemberWall.JSON_ignoreFriend(loginName, ignoreFriendOnComplete, ignoreFriendOnError);

}

    function ignoreFriendOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "ignore succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "ignore Failed";
          }
    }  

    function ignoreFriendOnError(){
    }
    
 function doDelete(friendLoginName){
  WCFMemberWall.JSON_delPendingFriend(friendLoginName, delPendingFriendOnComplete, delPendingFriendOnError);

}

    function delPendingFriendOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "delete succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "delete Failed";
          }
    }  

    function delPendingFriendOnError(){
    }
    
    
    
function removeFriend(friendLoginName){
        WCFMemberWall.JSON_removeFriend(friendLoginName, removeFriendOnComplete, removeFriendOnError);

}

    function removeFriendOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "delete succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "delete Failed";
          }
    }  

    function removeFriendOnError(){
    }
    


function doApproveAll(total){
    var html = '';
    
    for (var i = 0; i < total; i++) {
        if (document.getElementById('chkFriend'+i).checked==true){
            html += '';    
            html = html + document.getElementById('divChk'+ i).innerHTML; 
                html = html + ',';
        }        
    }
    WCFMemberWall.JSON_doApproveAll(html, doApproveAllOnComplete);

}

  function doApproveAllOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "Approve succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "Approve Failed";
          }
    }  
  
  
  

function doIgnoreAll(total){
    var html = '';
    
    for (var i = 0; i < total; i++) {
        if (document.getElementById('chkFriend'+i).checked==true){
            html += '';    
            html = html + document.getElementById('divChk'+ i).innerHTML; 
                html = html + ',';
        }        
    }
    WCFMemberWall.JSON_doIgnoreAll(html, doIgnoreAllOnComplete);

}


      function doIgnoreAllOnComplete(result){
          if (result == "") {
          document.getElementById("divStatus").innerHTML = "ignore succeced";
           window.location=document.location.href;
          } else {
          document.getElementById("divStatus").innerHTML = "ignore Failed";
          }
    }  
