window.addEvent('domready',function(){
	$('smoke2').addEvent('click',function(){
		Growl.Smoke({image:'../../img/icon.png',duration:3,sticky:true});
		return false;
	});
	var feed = [
		['Random Range mit AS3', '/304/random-range-mit-as3'],
		['Twitter damals und heute', '/313/twitter-damals-und-heute'],
		['11 Arten UIs mit Mootools zu verschönern', '/110/11-arten-user-interfaces-mit-mootols-zu-verschonern'],
		['10 nützlche Sans Serif Fonts', '/151/10-nutzliche-free-sans-serif-fonts'],
		['Multitouch Trackpad Customization mit Multiclutch', '/242/macbook-trackpad-customization-multiclutch']
	];
	var running = false;
	var randomize = function() {
		if (!running) return;
		// Random message from the feed
		var item = feed.getRandom();
		// First argument title, second message body
		roar.alert(item[0], '@ Apfelkuh.de: ' + item[1]);
		// Get last added element and add the click event

		roar.items.getLast().addEvent('click', function() {
			// Old school way for forcing a new window (not the best style!)
			window.open('http://www.apfelkuh.de/blog/' + item[1], 'demo')
		});
	};
	// Our roar instance for all our messages
	var roar = new Roar({
		position: 'upperRight',
		onHide: randomize,
		duration:3000
	});
	// A bit control for the nervous feed
	$('demo-control').addEvent('change', function() {
		if (!running && this.checked) { // restart
			running = true;
			randomize();
		} else { // stop
			running = false;
			roar.empty();
		};
	});
	var roarclick = new Roar({
		position: 'lowerRight',
		duration:3000
	});
	$('smoke').addEvent('click',function(el){
		running=false;
		$('demo-control').checked = false
		roarclick.alert('Hallo wie geht es dir?','ich bin eine message!');
		return false;
	})

})