var timerFtext,ftextHost,obIs15=false;
var obFTRssCron = new Class({
	init: function(){
		var divMsg = document.createElement("div");
			divMsg.id = 'ob-cron-res';
			divMsg.style.display = 'none';
			divMsg.innerHTML = '<input type="hidden" id="ob-cron-stop" name="ob-cron-stop" value="0"/>';
		document.getElementsByTagName('body')[0].appendChild(divMsg);
		this.run();
	},
	run: function(){
		var url = ftextHost+'index.php?option=com_fulltextrss&task=callaio';	
		if(obIs15){
			new Ajax(url,{onComplete:function(txt){new obFTRssCron().next(txt)}}).request();
		}else{
			new Request({url:url,method:'get',onSuccess:function(txt, responseXML){new obFTRssCron().next(txt)}}).send();
		}
	},
	next: function(txt){
		var res = this.getId('ob-cron-res');
		if(!res) return;
		
		res.innerHTML = txt;
		var stop = this.getId('ob-cron-stop');
		if(!stop) return;
		if(stop.value == '0'){
			this.run();			
		}else {
			clearTimeout(timerFtext);
			timerFtext = setTimeout ('new obFTRssCron().run()',60000);			
		}
	},
	getId: function(id){
		return document.getElementById(id);
	}
});
