Problems with analogWrite and RTC DS1307

I have a code that uses a real time clock DS1307 and RGB LEDs. However, when I use the analogWrite function along with the rtc function such as:

DateTime now = RTC.now();
for{byte x = 0; x < 254; x++){
  analogWrite(rgbPWMpin, x);
}

The LED starts to glow, but then the whole Aduino freezes after a random amount of time. Why does this happen and is there any way to fix this?

Note: I am using the library and instructions for the DS1307 from the ladyada website: DS1307 RTC tutorial

That code won't even compile. No setup(). No loop(). Snippets-r-us.com is down the internet a ways. Here, we get to see ALL the code.