var Ticker = Class.create();
Ticker.prototype = {
	messages: new Array(),
	counter: 0, interval: 0,
	target: null, source: null,
	updateRate: 7,
	
	initialize: function(target, source){
 		this.target = $(target);
		this.source = $(source);
		this.messages = $$('#notabeneSection p');
		this.start();
	},
	start: function(){
		this.interval = new PeriodicalExecuter(function() {
			this.target.update('&nbsp;');
			this.messages[this.counter].hide();
			this.target.appendChild(this.messages[this.counter]);
			this.counter++;
			this.target.lastChild.show();
			if(this.counter == this.messages.length){ this.counter = 0;}
		}.bind(this), this.updateRate);
	},

	stop: function(){
		this.interval.stop();
	}
};




function imglink_mouseover(e){
	Event.element(e).src = Event.element(e).src.replace(/off.gif/g, "on.gif");
}
function imglink_mouseout(e){
	Event.element(e).src = Event.element(e).src.replace(/on.gif/g, "off.gif");
}
function initSite(){
	var notabeneTicker = new Ticker('notabeneTicker','notabeneSection');
	var timeline = $('nzz_timeline');
	
	
	if(timeline != null){initCarousel();}
	
	
	$$('a img').each(function(s){
		s.observe('mouseover',imglink_mouseover);
		s.observe('mouseout',imglink_mouseout);
	})
	
	
	
	if(window.STATION === undefined){
		Event.stopObserving($('station_sf'),'mouseover',imglink_mouseover)
		Event.stopObserving($('station_sf'),'mouseout',imglink_mouseout)
		Event.stopObserving($('station_vox'),'mouseover',imglink_mouseover)
		Event.stopObserving($('station_vox'),'mouseout',imglink_mouseout)
		Event.stopObserving($('station_hd'),'mouseover',imglink_mouseover)
		Event.stopObserving($('station_hd'),'mouseover',imglink_mouseover)
		Event.stopObserving($('station_3sat'),'mouseout',imglink_mouseout)
		Event.stopObserving($('station_3sat'),'mouseout',imglink_mouseout)
		$('station_3sat').src = $('station_3sat').src.replace(/off.gif/g, "on.gif");
		$('station_hd').src = $('station_hd').src.replace(/off.gif/g, "on.gif");
		$('station_vox').src = $('station_vox').src.replace(/off.gif/g, "on.gif");
		$('station_sf').src = $('station_sf').src.replace(/off.gif/g, "on.gif");
	}else{
		if(STATION == 'SF1'){
			Event.stopObserving($('station_sf'),'mouseover',imglink_mouseover)
			Event.stopObserving($('station_sf'),'mouseout',imglink_mouseout)
			$('station_sf').src = $('station_sf').src.replace(/off.gif/g, "on.gif");
		}
		if(STATION == 'SFZWEI'){
			Event.stopObserving($('station_sf'),'mouseover',imglink_mouseover)
			Event.stopObserving($('station_sf'),'mouseout',imglink_mouseout)
			$('station_sf').src = $('station_sf').src.replace(/off.gif/g, "on.gif");
		}
		if(STATION == 'VOX'){
			Event.stopObserving($('station_vox'),'mouseover',imglink_mouseover)
			Event.stopObserving($('station_vox'),'mouseout',imglink_mouseout)
			$('station_vox').src = $('station_vox').src.replace(/off.gif/g, "on.gif");
		}
		if(STATION == 'HDSUISSE'){
			Event.stopObserving($('station_hd'),'mouseover',imglink_mouseover)
			Event.stopObserving($('station_hd'),'mouseout',imglink_mouseout)
			$('station_hd').src = $('station_hd').src.replace(/off.gif/g, "on.gif");
		}
		if(STATION == '3SAT'){
			Event.stopObserving($('station_3sat'),'mouseover',imglink_mouseover)
			Event.stopObserving($('station_3sat'),'mouseout',imglink_mouseout)
			$('station_3sat').src = $('station_3sat').src.replace(/off.gif/g, "on.gif");
		}
	}

};
Event.observe(window, 'load', initSite);




