What Iran is doing is only logical. a) they see that their neighpor got invaded preemtively by the US on false charges adn b) nuklear weapons is the only defense the US respects.It is good we are in Iraq, because we are right next door to Iran. This makes an invasion much easier.
Had Iraq not been invaded there would not have been any need for Iran to go down the nuklear path, considering embargos, trade sanctions and such. President Hamid considers himself doing this in self defence.
It is worth noting that Hans Blix former chief of UN weapons inspection has suggested that Iran drop their nuklear plans in exchange for guarantee by USA that they will not be invaded. USA is not interested.