

var cspkListEditor = function (type)
{
  this.type = type;
};

cspkListEditor.prototype.send = function(slug)
{
  if (this.type != cityspk.types.MESSAGE) return;
  
  cityspk.api.message.moveToTmp( function(response)
  {
    if (response.type == cityspk.SUCCESS)
    {
      location.href = cityspk.urlmap.app_message_customize;
    } else alert(response.data);
  }, slug);
};

cspkListEditor.prototype.modify = function(slug)
{
  /* if (this.type == cityspk.types.MESSAGE)
  {
    cityspk.api.message.moveToTmp( function(response)
    {
      if (response.type == cityspk.SUCCESS)
      {
        location.href = cityspk.urlmap.app_message_customize;
      } else alert(response.data);
    }, slug);
  }
  else
  {
    //TODO: a real thickbox form for editing?
    location.href = cityspk.urlmap.app_photo_organizer;
  }*/	
	return false;
};


cspkListEditor.prototype.remove = function(slug)
{
  if (this.type == cityspk.types.MESSAGE)
  {
    cityspk.api.message.destroy( function(response)
    {
      if (response.type == cityspk.SUCCESS) location.reload();
      else alert(response.data);
    }, slug);
  }
	else if(this.type == 'Friend')
	{
		cityspk.api.user.removeFriend( function(response){
			if (response.type == cityspk.SUCCESS) location.reload();
		}, slug);
	}	
  else
  {
    cityspk.api.photos.erase(function(response)
    {
      if (response.type == cityspk.SUCCESS) location.reload();
      else alert(response.data);
    }, { 'slug' : slug })
  }
};

