/*
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 
 * @before   <h1 id="heading1" class="jqir">Heading 1</h1>
 *           <h2 class="jqir {src:heading2.png}">Heading 2</h2>
 *@result   <h1 id="heading1" class="jqir"><img alt="Heading 1" src="images/heading1.png"></h1> 
 */ 
 
jQuery.fn.jQIR=function(format,path,onload)
{if(!document.images)return this;path=path||"";this.each(function()
{var img=$("<img>"),el=jQuery(this);var file;var re=/(?:{src\:)(\S+)(?:})/i;var m=this.className.match(re);if(m)
{file=path+m[1];}
else
{file=path+this.id+"."+format;}
jQuery(img).attr({src:file,alt:el.text()}).load(typeof onload=="function"?onload:function(){});var a=el.find("a");var toAppend=a.length?a.empty().append(img):img;el.empty().append(toAppend);})
return this;}