To be fair, McCains ad isn't exactly honest.
Obama didn't write the bill. He did allow it to get through his committee, though it would have been very hard for him to stop it.
The bill does require teaching of age appropriate sex education. Which gives him some wiggle room.
And looking at the legislative history, i don't see where it passed.