There are a number of JavaScript libraries that are designed to allow old IE to support SVG images.
There's a list of them here.
They use various techniques, and offer various features, so you'll need to evaluate them yourself to determine which is most suitable to your situation, but most of them ultimately convert the SVG to VML as a fall-back for old IE.
One or two of them also use other technologies (Flash, Silverlight, etc) to do the conversion, which may be a good thing, since VML can be slow, and also because IE isn't the only old browser still in use that doesn't support SVG (eg Android 2.3 and earlier).
But in general, the idea of these libraries is that they're transparent to the user and to the developer; you just provide the SVG, and the library displays it to the user. You don't need to worry about it being VML or anything else; all you need to worry about is the SVG.
I note that your question specifies that you need to support IE5. I would warn you that it's very unlikely that many of these scripts will work in IE5. IE6 should be fairly safe, but IE5 is going to be very difficult to support.
Ignoring the IE5 aspect, if you're creating your images in JavaScript, as implied in the question, I would suggest using the Raphael library as the best option. But try out the various scripts listed and see what works for you.
Hope that helps.