var	MyTicker = new Class({
	initialize: function(strFeed, intTick, intRefresh){
		this.buffer = $("marquee");
		this.ticker = $("ticker");
		this.tickerBelt = $("ticker-belt");
		this.tickerTape = $("ticker-tape");
		
		this.copyspeed = 3;
		this.createDOM();
		
		this.ajax = new Ajax(strFeed, {
			method: "get"
		,	onComplete: this.populate.bind(this)
		});
		this.request();
		this.scroll.periodical(intTick, this);
		this.refresh = intRefresh;
	},
	move: function() {
		this.removeClass("freeze");
	},
	stop: function() {
		this.addClass("freeze");
	},
	createDOM: function() {
	//	existing tags
		this.buffer.setStyles({"position": "absolute", "top": "-200px", "left": "-100000px", "visibility": "hidden"});
		this.ticker.setStyles({"position": "relative", "overflow": "hidden"});
		this.tickerBelt.setStyles({"position": "absolute"
			,	"height": this.ticker.getStyle("height")
			,	"width": this.ticker.getStyle("width")
			});
		this.tickerTape.addEvent("mouseover", this.stop);
		this.tickerTape.addEvent("mouseout",  this.move);
		this.tickerTape.setStyles({"position": "absolute", "top": "0"
			,	"left": this.ticker.getStyle("width").toInt()+ 8 +"px"
			});
		this.tickerTape.realWidth = 10000;	// default
	//	console.log("belt height", this.ticker.getStyle("height"));
	},
	request: function() {
		this.ajax.request();
	},
	populate: function(something) {
		this.buffer.innerHTML = something;	// replaced: update
		this.tickerTape.innerHTML = this.buffer.innerHTML;	// fills with data
		this.tickerTape.setStyle("width", this.buffer.offsetWidth +"px");	// after data load, we should get the length here
		console.log(this.tickerTape.getChildren());	// dummy stuff to make .firstChild work in IE (!!!)
		this.tickerTape.realWidth = this.tickerTape.firstChild.getStyle("width").toInt();
		this.request.delay(this.refresh, this);
	//	refreshDate();	// CAUTION: HARD CODE
	},
	scroll: function() {
		if (!this.tickerTape.hasClass("freeze")) {
			if (this.tickerTape.getStyle("left").toInt() > (- this.tickerTape.realWidth)) {
				this.tickerTape.setStyle("left", this.tickerTape.getStyle("left").toInt()- this.copyspeed +"px");
			} else {
				this.tickerTape.setStyle("left", this.ticker.getStyle("width").toInt()+ 8 +"px");	// starts again, repositioned
			}
		}
//		console.log("left", this.tickerTape.getStyle("left"));
	}
});
