image with error constantly flashes
<p>Situation:</p>

<p>I have products which a logo is added dynamically. for example. The image will have title="nike" and jquery adds the nike logo.</p>

<p>Problem:
The logo image is added by using the path to the image but the image can be either .gif or .png. The image with error flashes on/off and doesnt stop.</p>

<p>Code:</p>

<pre><code>$('div.mainpic').each(function () {
    var $this = $(this);
    var logoName = $(this).find('img').attr('title');

    $("&lt;img&gt;").prependTo($this).addClass('prod-logo').attr('src', '../../img/logos/' + logoName + '.gif');

    $("img.prod-logo").error(function () {
        $(this).attr('src', '../../img/logos/' + logoName + '.png');
    });
});
</code></pre>

<p>Any help would be appreciated.</p>
