var iframediv, ifr, onfunc;

onfunc = function() 
{
	// Loop through all the A tags and find the ones with REF class
	SetupIFrameDiv();
	var hlp = document.getElementsByTagName("a");
	for (var i=0; i<hlp.length; i++)
	{
		if (hlp[i].parentNode.className.match(/\bquestionhelp\b/)) 
		{
			var h = hlp[i].href;
			h = h.replace(/http:\/\/www.smallbiz.nsw.gov.au\/businessloanfinder#/, 'http://www.smallbiz.nsw.gov.au/businessloanfinder/refdata/') + '.html';
			hlp[i].pophref = h;
			hlp[i].onclick = function() { ShowIFrameDiv(this.pophref); return false; };
		}
	}
}

function SetupIFrameDiv()
{
	iframediv = document.createElement('div');
	iframediv.id = 'iframediv';
	p = document.createElement('div');
	p.id = 'cls'; p.onselectstart = p.ondragstart = function() {return false;}; p.innerHTML = '<a href="#" onclick="HideIFrameDiv();return false;">close</a>';
	iframediv.appendChild(p);
	p = document.createElement('div');
	p.id='ifrdiv'; p.innerHTML='<iframe id="ifr" name="ifr" frameborder="none"></iframe>';
	iframediv.appendChild(p);
	document.body.appendChild(iframediv);
}

function ShowIFrameDiv(url)
{
	if (!ifr) ifr = document.getElementById('ifr');
	ifr.src = '';
	iframediv.style['display'] = 'block';
	ifr.src = url;
}

function HideIFrameDiv()
{
	iframediv.style['display'] = 'none';
}

// Do the 'immediate' stuff, include the stylesheet and attach the load function
document.write('<link rel="stylesheet" href="http://www.smallbiz.nsw.gov.au/businessloanfinder/divstyle.css" type="text/css">');
if (window.addEventListener) window.addEventListener ( 'load', onfunc, false); 
else if (window.attachEvent) window.attachEvent ( 'onload', onfunc);

