The rattling may be the bearings going out of your alternator. Batteries normally do not rattle. If the bearings are going out they may begin to seize up and instead of the alternator pulley turning, the belt is slipping on the pulley as the bearings get tight. Take the belt off the alternator pulley and see if you feel and grinding or tightness when you spin the pulley. If you do, change it out now. The reason the lights are going dim is because your alternator is not spinnign at the needed rpms to keep the battery charged and thus the dimming and slowing eventually you will have a dead battery too boot.