Soak the dried salted cod in cold water for 24 hours, changing the water several times.
Bring a large pot of water to a boil. Add the soaked cod and boil for about 5 minutes, or until fish flakes easily with a fork. Remove cod from water and save water for cooking potatoes. Remove skin and bones from the cod and flake the meat into pieces using a fork. Set fish aside in a large bowl.
In a small bowl stir together the olive oil, 1 clove of garlic, 1 tablespoon of parsley, chilli flakes and black pepper. Pour over the fish and toss lightly to coat.
Preheat the oven to 180 degrees C. Place the potatoes into the fish water and bring to a boil. Cook for 20 minutes or until tender. Drain under cool water, peel and cut into 5mm slices.
While the potatoes are cooking melt the butter in a large frypan over medium heat. Add the onions and saute until golden and caramelised. Stir one clove of garlic into the onions. Set aside.
Layer half of the potato slices in the bottom of a greased 20x30cm baking dish. Cover with half of the cod then half of the onions. Repeat layers, ending with onion.
Bake for 15 minutes in the preheated oven until lightly browned. Before serving, garnish the top with green and black olives and hard-cooked eggs. Sprinkle with remaining parsley.