function activate_teaser_box() {
	// Bild 2 einblenden
	if (this.fade_pic) this.fade_pic.stop();
	this.fade_pic = this.getElement('img.teaser-box-image-grey').effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('0');
	// Textelement reinfahren
	if (this.slide_text) this.slide_text.stop();
	this.slide_text = this.getElement('div.info-arrow').effect('top', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('67px');
	// Farbe der Überschrift faden
	if (this.fade_h2) this.fade_h2.stop();
	this.fade_h2 = this.getElement('h2.teaser_h2').effect('color', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('#c30426');
}

function deactivate_teaser_box() {
	// Bild 2 ausblenden
	if (this.fade_pic) this.fade_pic.stop();
	this.fade_pic = this.getElement('img.teaser-box-image-grey').effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('1');
	// Textelement rausfahren
	if (this.slide_text) this.slide_text.stop();
	this.slide_text = this.getElement('div.info-arrow').effect('top', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('120px');
	// Farbe der Überschrift faden
	if (this.fade_h2) this.fade_h2.stop();
	this.fade_h2 = this.getElement('h2.teaser_h2').effect('color', {transition: Fx.Transitions.Cubic.easeInOut, duration:400}).start('#9d907c');
}

function init_teaser_boxes() {
	var teaser_boxes;
	teaser_boxes= $$('div.teaser-img-wrap');
	teaser_boxes.each(
		function(el) {
			el.addEvent('mouseenter', activate_teaser_box);
			el.addEvent('mouseleave', deactivate_teaser_box);
			el.addEvent('click', function(el) {
				var url = this.getElement('a');
				location.href = url;
			});
		}
	);
}

function activate_more_link() {
	if (this.fade_text) this.fade_text.stop();
	this.fade_text = this.getElement('p.link2').effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:200}).start('0');
}

function deactivate_more_link() {
	if (this.fade_text) this.fade_text.stop();
	this.fade_text = this.getElement('p.link2').effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:200}).start('1');
}

function init_more_links() {
	var more_links;
	more_links= $$('div.moreLinks_wrap');
	more_links.each(
		function(el) {
			el.addEvent('mouseenter', activate_more_link);
			el.addEvent('mouseleave', deactivate_more_link);
			el.addEvent('click', function(el) {
				var url = this.getElement('a');
				location.href = url;
			});
		}
	);
}

function init_downloads() {
	var teaser_boxes;
	teaser_boxes= $$('div.docs_item_wrap');
	teaser_boxes.each(
		function(el) {
			el.addEvent('click', function(el) {
				var url = this.getElement('a');
				location.href = url;
			});
		}
	);
}

var findAndDisplayOverlay = function(el,arg1) {
	parent = this.getParent().getParent();
	if (parent) {
		child = parent.getElement('div.dam-details-wrap');
		if (child) {
			alert(arg1);
			child.setStyle('display',arg1);
		}
	}
}

function display_overlay() {
	parent = this.getParent().getParent();
	if (parent) {
		child = parent.getElement('div.dam-details-wrap');
		if (child) {
			child.setStyle('opacity','0');
			child.setStyle('display','block');
			coords = child.getCoordinates();
			child.setStyle('top','-'+(coords.height-150)+'px');
			child.setStyle('left','-'+(coords.width+100)+'px');
			if (this.fade_overlay) this.fade_overlay.stop();
			this.fade_overlay = child.effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:200}).start('1');
		}
	}
}

function hide_overlay() {
	parent = this.getParent().getParent();
	if (parent) {
		child = parent.getElement('div.dam-details-wrap');
		if (child) {
			if (this.fade_overlay) this.fade_overlay.stop();
			this.fade_overlay = child.effect('opacity', {transition: Fx.Transitions.Cubic.easeInOut, duration:200}).start('0');
		}
	}
}

function init_dam() {
	var teaser_boxes;
	info_icons= $$('a.dam-link-detail');
	info_icons.each(
		function(el) {
			el.addEvent('mouseenter', display_overlay);
			el.addEvent('mouseleave', hide_overlay);
		}
	);
}

function init() {
	init_teaser_boxes();
	init_more_links();
	init_downloads();
	init_dam();
}

window.addEvent('domready', init);

