James Foster struck his first century of the season to put Essex in charge on a rain-affected third day against Leicestershire at Grace Road.