var ping_id = 0;
sendPopupCheck = function() {
  ping_id++;
  var url = getPopupCheckUrl() + "?ping=" + ping_id;
  new Ajax.Request(url, {
    method : "get",
    onSuccess : function(xml) {
		// do something with xml.responseText
		switch (xml.responseText.substr(0, 2)) {
			case "OK":
				// do nothing
				break;

			case "PO":
				// popup
				showModalBox(xml.responseText.substr(2));
				break;
		}
    },
  });
}

if (enablePopupCheck()) {
	var timer_popup = window.setInterval(sendPopupCheck, 10000);   // every ten seconds
}