var keepChecking = true; // Whether to keep checking for new proactive chat requests var alreadyrunflag = 1; // flag to indicate whether target function has already been run var refreshInterval = 7000; // In miliseconds, default 7000 var recheckRunFlag = false; var recheckUri = 'http://www.kalatec.com.br/2009/index.php?/component/option,com_livechat/do_not_log,true/format,raw/lang,pt/task,check_proactive/view,popup/=&refresh_only=1'; function injectProactiveChat() { recheckProactiveChats(); if(alreadyrunflag == 1) { return false; } alreadyrunflag = 1; requestLiveChat('http://www.kalatec.com.br/2009/index.php?/component/option,com_livechat/lang,pt/view,popup/=&tmpl=component&iframe=1', 'iframe'); } function recheckAction() { var body = document.getElementsByTagName('body').item(0); var existingScript = document.getElementById('livechat_recheck_script'); if(existingScript) { existingScript.parentNode.removeChild(existingScript); } var script = document.createElement('script'); script.src = recheckUri; script.id = 'livechat_recheck_script'; script.type = 'text/javascript'; body.appendChild(script); } function recheckProactiveChats() { if(recheckRunFlag) { return false; } var livechatLayer = document.getElementById('livechat_iframe'); recheckRunFlag = true; if(keepChecking && !closedPermanently && !livechatLayer) { // Keep refreshing setTimeout('recheckAction(); recheckRunFlag=false; recheckProactiveChats();', refreshInterval); } } if (document.addEventListener) { document.addEventListener("DOMContentLoaded", function(){ injectProactiveChat() }, false) } else if (document.all && !window.opera) { document.write('