I think that when they go grey, it means that they have lost the location of the application that they represent.
If you put your mouse over each one, it will tell you what application it is that it has lost.
Go to wherever you have that application stored, usually the applications folder, and drag the icon of the application down into the dock. A new icon is created for you.
Repeat with the other grey icons in the dock.
To remove the grey icons, left click and hold while you drag the icon out of the dock and onto the desktop. Release the mouse button and the icon will disappear in a puff of smoke.