function register_button(deptid,eltid, imgsrc){
	try{
		inviteButtons[eltid] = {id:deptid,img:imgsrc};
		document.write('<img src="https://rs.instantservice.com/resources/smartbutton' +
		  '/7491/' + deptid + '/available.gif?' + Math.floor(Math.random()*10001) +
		  '" style="width:0;height:0;visibility:hidden;position:absolute;"' +
		  ' onLoad="agents_available(\'' + eltid + '\')" onError="agents_not_available(\'' + eltid + '\')">');
	}catch(err){
		if(navigator.userAgent.indexOf('Firefox') > 0 && null != console && null != console.log){
			console.log(arguments);
			console.log(err);
		}
	}
}

function agents_available(eltid)
{
	var elt = document.getElementById(eltid);
	if(elt){
		elt.innerHTML =
		'<a href="" onClick="javascript:window.open(\'https://admin.instantservice.com/links' +
		'/7491/' + inviteButtons[eltid].id + '\',\'chat_client\',\'width=600,height=324,scrollbars=0\');' +
		'return false;"><img border="0" alt="Click for Live Chat" src="' + inviteButtons[eltid].img + '"></a>';
		return true;
	}
	else{
		return false;
	}
}
function agents_not_available(eltid)
{
	var elt = document.getElementById(eltid);
	if(elt){
		elt.innerHTML = '';
		return true;
	}
	else{
		return false;
	}
}



