function Q2CSched(countdown,towhat){return{t:null,delay:countdown,action:towhat,refreshPage:function(){var that=this;var checkLater=function(){that.delay=Math.ceil(5+Math.random()*10)*1000;if(that.t)clearTimeout(that.t);that.set();};var onSuccess=function(o){if(this.action=='end') {var response=eval("("+o.responseText+")");if(response.res=='ended') {clearTimeout(this.t);location.reload();} else {checkLater();}}};var onFailure=function(o){};var callback={success:onSuccess,failure:onFailure,scope:this,cache:false};if(this.t!=null) {if(this.action=='start') {clearTimeout(this.t);location.reload();} else {var url='q2cEventSchedServer.php?action=end';var postData="action=end";var request=YAHOO.util.Connect.asyncRequest('GET',url,callback);}}},set:function(){var o=this;if(this.delay>0) {if(this.action=='end') {this.delay+=Math.floor(Math.random()*21)*1000;} this.t=setTimeout(function(){o.refreshPage();},this.delay);}}}};
