Cosmic evolution of metal densities: the enrichment of the intergalactic medium