function libAGENTURNET() {
	jQuery('#agentur_net').hover(function() {
		jQuery(this).find('ul li ul').show('slow');
	}, function() {
		jQuery(this).find('ul li ul').hide('slow');
	});

	jQuery('#agentur_net').click(function() {
		// alert(jQuery(this).find('a').attr('href'));
			// window.parent.location = jQuery(this).find('a').attr('href');
			window.open(jQuery(this).find('a').attr('href'));
		});
}

function mediarotate(max, act, zindex) {
	// Oberstes Bild ausblenden
	jQuery("#teaser div.mediaimage").eq(act).fadeOut("slow");

	// Bild unten wieder einfügen
	setTimeout(function() {
		jQuery("#teaser div.mediaimage").eq(act).css("z-index", zindex);
		jQuery("#teaser div.mediaimage").eq(act).fadeIn("slow");
	}, 1000);
	// Rotation erneut starten
	setTimeout(function() {
		if (act == max) {
			// z-index überprüfen
			if (zindex <= 10) {
				// Alle vorhandenen Elemente im z-index um 1000 erhöhen
				for (i = 0; i < max; i++) {
					zindex = 1000 - i;
					jQuery("#teaser div.mediaimage").eq(i).css("z-index",
							zindex);
				}
			}
			act = -1;
		}
		mediarotate(max, act + 1, zindex - 1);
	}, 5000);
}
function libMEDIA() {
	// Alle Media Bilder mit z-index versehen und anzeigen sowie den
	// Rotationswinkel festlegen
	j = 0;
	for (i = 0; i < jQuery("#teaser div.mediaimage").length; i++) {
		zindex = 1000 - i;

		jQuery("#teaser div.mediaimage").eq(i).show();
		jQuery("#teaser div.mediaimage").eq(i).css("z-index", zindex);
	}
	// Erste Rotation nach 5 Sekunden starten, wenn mehr als ein Bild
	if (i > 1) {
		setTimeout(function() {
			mediarotate(jQuery("#teaser div.mediaimage").length - 1, 0,
					zindex - 1);
		}, 5000);
	}
}


jQuery(document).ready(function() {
	libAGENTURNET();
	libMEDIA();
});
