function addPrintEvent() {
	$("print").addEvent("click", function(e) {
		e.stop();
		window.print();
	});
}

function addCloseEvent() {
	$("close").addEvent("click",function(e) {
		e.stop();
		window.close();
	});
}
function openPopup(url) {
	var width = 495;
	if(Browser.Engine.trident) {
		width = 530;
	}
	window.open(url,"news","height=412,width="+width+",menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no");	
}

var HeadAni = new Class({
	Implements: [Events,Options],
	options: {
		container: "headani",
		step1: 747,
		step2: 739,
		delay: 4000,
		aniDuration: 4000
	},
	initialize: function(options) {
		this.setOptions(options);
		this.container = $(this.options.container);
		this.step = -1 * this.options.step1.toInt();
		this.counter = 0;
		this.container.set("tween", {
			"duration": this.options.aniDuration,
			"link": "cancel",
			"transition": "linear",
			"property": "background-position"
		});
		this.image = this.container.getStyle("background-image").substr(4,this.container.getStyle("background-image").length.toInt()-5);
		this.showLoading();
		this.timer = null;
		var img = new Asset.image(this.image, {
			"onload": function() {
				this.container.setStyle("background","transparent url("+this.image+") repeat-x 0 0");
				this.timer = this.animate.delay(this.options.delay,this);
			}.bind(this)
		});
	},
	animate: function() {
		this.container.get("tween").start(this.step).chain(function() {
			this.counter++;
			if(this.counter==2) {
				// einmal komplett durchgegangen, setzte bg-position wieder auf 0
				this.container.get("tween").set(0);
		        this.step = -1 * this.options.step1.toInt();
				this.counter = 0;
			}
			else {
				this.step = this.step - this.options.step2.toInt();
			}	
			$clear(this.timer);
			this.timer = this.animate.delay(this.options.delay,this);
		}.bind(this));
	},
	showLoading: function() {
		this.container.setStyle("background","transparent url(fileadmin/images/layout/loading.gif) no-repeat center center");
	}
});
