Don't Worry ! These are scam...Advertisers thought that you are using a PC (Windows) and they want you to buy the Anitivirus from them or
May be they are trying to steal your Personal Information with that software. I'm also getting these messages many times while surfing internet. So next time when you get that message, just ignore it and don't buy/download anything.
Actually Macs only have a small number of viruses (1 out of 100) and they won't affect your Mac if you do regular software update (Apple > Software Update). Viruses usually affect the root file system and Mac won't allow to change the File system without the permission of User. I mean, Viruses won't affect your Mac without your Permission.
Also, Safari is just a browser and its doesn't have the ability to scan your Mac files.
Anyway, you can scan your Mac with a free Anti Virus application,ClamXav
and see if it founds anything.
Just do regular software update and You're safe !!
Let me know if ClamXav founds anything...