<!-- //
var __setInterval   = window.setInterval;
var __clearInterval = window.clearInterval;
var __interval      = 10;
var __intervalID    = null;
var __intervalFrame = 0;

var __pcount    = 0;
var __lastpid   = 0;
var __process   = new Object();
var __delay     = new Object();

var ERROR_ARG = new Error('引数が不正です');

window.setInterval = function(func, delay) {
func = (typeof func == 'string') ? new Function(func) : func ;
if (typeof func != 'function') throw ERROR_ARG;

__pcount++;
__lastpid++;
__process[__lastpid] = func;
__delay[__lastpid]   = Math.floor(delay / __interval) || 1;

if (! __intervalID) __intervalID = __setInterval(__execProcess, __interval);

return __lastpid;
}


window.clearInterval = function(pid) {
if (__process[pid]) {
delete __process[pid];
delete __delay[pid];

if (! --__pcount) {
__clearInterval(__intervalID);
__intervalID = null;
}
}
}

window.__execProcess = function() {
__intervalFrame++;
for (var i in __process) ! (__intervalFrame % __delay[i]) && __process[i]();
}
//--></SCRIPT>