/* This script is licenced under the GPL 2.0.
   Author: Emmanuel Decitre (decitre at gmail dot com)

<rdf:RDF xmlns="http://web.resource.org/cc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<Work rdf:about="">
   <license rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" />
   <dc:type rdf:resource="http://purl.org/dc/dcmitype/Software" />
</Work>

<License rdf:about="http://creativecommons.org/licenses/GPL/2.0/">
<permits rdf:resource="http://web.resource.org/cc/Reproduction" />
   <permits rdf:resource="http://web.resource.org/cc/Distribution" />
   <requires rdf:resource="http://web.resource.org/cc/Notice" />
   <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
   <requires rdf:resource="http://web.resource.org/cc/ShareAlike" />
   <requires rdf:resource="http://web.resource.org/cc/SourceCode" />
</License>

</rdf:RDF>

*/



/* Periodicity module.
 * The 'post' function runs the 'fn' function periodically every 'time' milliseconds.
 * 'fn' gets 'vargs' as parameter and shall return a modified version to allow recursion, or "end" to
 * stop the calling sequence.
 * usage example: <body onload='post(new Function ("", "alert((new Date()).getTime())"), 1000);'>
*/


function post (fn, time, vargs) {
  nvargs = fn(vargs);
  if (nvargs != "end")
    setTimeout( hook(fn, time, nvargs), time);
}

function hook(fn, time, vargs) { 
  return function() { post (fn, time, vargs) ; }
}
