/*--- Rewritten by Adam T to separate JS from on-page HTML 06/08/08* ---*/

window.onload = init_smartButton;
/*-------------------------------*/

function init_smartButton()
{
	var bod = document.body;

	var preload_img = document.createElement('img')
	preload_img.src = 'http://admin.instantservice.com/resources/smartbutton/6066/20465/available.gif?' + Math.floor(Math.random()*10001)
	preload_img.id = 'webchat_preloader'

	bod.appendChild(preload_img)

	if (document.getElementById('webchat_preloader'))
		{document.getElementById('webchat_preloader').onload = agents_available;}

}

function agents_available()
{
	var smartbut = document.getElementById('find_plan')
	smartbut.id = 'webchat'
	smartbut.innerHTML =
	'<h3>Web chat</h3>'
	+
	'<p>Talk to one of our advisers online now</p>'
	+
	'<a href="" title="Click to chat to one of our Bupa agents" onClick="window.open(\'/heartbeat/html/instantservice_static_prechat_invite.html\',' +
	'\'custclient\',\'width=500,height=370,scrollbars=1\');return false;"/>' +
	'Let\'s talk</a>';
	return true;
}