function get_content_friends(type, page)
{
	//$("#public_content").hide();
	$("#public_pager").hide();
	$("#public_progress").show();
	
	var selectedSort = $("#sortFilesTab :selected").map(function(){return $(this).val();})
	
	  $.post('/friendsdrive/FriendsItems/' +type+'/'+page+'/0',
			{page:page, sort: selectedSort[0], order: selectedSort[1]},
			write_response);
}
function write_response(data) 
{
	$("#public_content").html(data);	
	$("#public_pager").show();
	$("#public_progress").hide();		
}

function showFavoreteItems(type, idd, page)
{
  $.post('/friendsdrive/FriendsItems',
	{action:'FriendsItems', type: type, id: idd, page: page},
	  function(data)
	  {
	    if(idd != '')
	    {
	      //el.innerHTML=data;
	      $("#" + idd).empty();
	      $("#" + idd).append(data);
	
	      changeTabFriend("files", "#6ca6c1", idd, "");
	      changeTabFriend("folders", "#6ca6c1", idd, "");
	      changeTabFriend("users", "#6ca6c1", idd, "");
	      
	      //$("#text_private").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'private\', \''+idd+'\', \'1\');">Private</a>&nbsp;&nbsp;');
	      //$("#text_public").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'public\', \''+idd+'\', \'1\');">Public</a>&nbsp;&nbsp;');
	      //$("#text_group").html('&nbsp;&nbsp;<a class="txtfiletab" href="javascript:showContent( \'group\', \''+idd+'\', \'1\');">Group</a>&nbsp;&nbsp;');
	
	      
	      if(type=='files')
	      {
	        changeTabFriend("files", "#c5dfee", idd, "_act");
	      }
	      else if(type=='folders')
	      {
	        changeTabFriend("folders", "#c5dfee", idd, "_act");
	      }
	      else if(type=='users')
	      {
	        changeTabFriend("users", "#c5dfee", idd, "_act");
	      }
	    }
	  }
  );
}

function changeTabFriend(type, color, idd, act)
{
  $("#folderTabDiv" + type).css("background-color", color);
  $("#folderTabImgL" + type).attr("src", "/img/folder_tab_l" + act + ".gif");
  $("#folderTabImgR" + type).attr("src", "/img/folder_tab_r" + act + ".gif");
  if (act == "")
  {
    //alert('&nbsp;&nbsp;<a id="link_' + type + '" class="txtfiletab" href="javascript: showMemberFolders("' + type + '", "' + idd + '", 1)">' + $("#link_" + type).text() + '</a>&nbsp;&nbsp;');
    $("#text_" + type).html('<a id="link_' + type + '" class="txtfiletab" href="javascript: showFavoreteItems(\'' + type + '\', \'' + idd + '\', \'1\')">' + $("#link_" + type).text() + '</a>');
  }
  else
  {
    $("#text_" + type).html('<span id="link_' + type + '">' + $("#link_" + type).text() + '</span>');
  }

}

var work=false;
function UpdateFriends(action, object_id, id_link)
{
	if(work) return;
	work=true;
  	$("#" +id_link).empty();
  	$("#" +id_link).append("<img src='/img/line_2.gif'>");
  	$.post('/friends/',
  	{action: action, object_id: object_id},
	  	function(data)
	  	{
			work=false;
	    	$("#" +id_link).empty();
	    	if (action == "add")
	    	{
		      	$("#" +id_link).append("Remove From Friends");
		      	$("#" +id_link).attr("href", "javascript:UpdateFriends( 'delete', '"+object_id+"', '" +id_link+ "')");
	    	}else{
		      	$("#" +id_link).append("Add To Friends");
		      	$("#" +id_link).attr("href", "javascript:UpdateFriends( 'add', '"+object_id+"', '" +id_link+ "')");
	    	}
	  	}
  	);
}
