$(document).ready(function() {

// TEASER BOX [Begin]
	var margin = 0;

	// Iniatialiseren der Tabs
	$(".mainHeaderNewsBoxTitle").each(function() {
	
		$(this).css('left',margin);
		margin += $(this).width() + 1;
	
		// onClick-Funktion hinzufügen
		$(this).children("span").click(function() {
			$(".mainHeaderNewsBoxTitle").each(function() {
				$(this).children("span").mouseover(function(){ $(this).css('cursor','pointer'); });
				$(this).children("span").removeClass('active');
				$(this).parent().children('.mainHeaderNewsBoxContent').hide();
			});
			$(this).mouseover(function(){ $(this).css('cursor','arrow'); });
			$(this).addClass('active');
			$(this).parent().parent().children('.mainHeaderNewsBoxContent').show();
		});

	});
	
	// Ersten Tab "Clicken" -> aktivieren
	$(".mainHeaderNewsBoxTitle:first").children("span").click();
// TEASER BOX [Ende]

// HEADER BILDMENÜ [Begin]
	$(".mainHeaderImagesWrap").hover(
		function() {
			$(this).children('.mainHeaderImagesText').fadeIn("fast");
		},
		function() {
			$(this).children('.mainHeaderImagesText').hide();
		}
	);
// HEADER BILDMENÜ [Ende]

// SCHRIFTGRÖßE [Begin]
	// Array erstellen mit allen zu verändernden Schriften
	var targets = new Array();
	targets[0] = [ $('.mainContentSubPagesAbstract') ];
	targets[1] = [ $('.mainContentElements p') ];
	//targets[2] = [ $('.mainContentElements h1') , 0.5 ];
	//targets[3] = [ $('.mainContentSubPagesTitle') , 0.5 ];

	var fontFactor = 0;		// Momentane Vergrößerungsstufe
	var steps = 2;			// Schrittweite der Vergrößerung / Verkleinerung
	var maxSteps = 2;		// Maximale Anzahl an Schritten (pro Richtung)
	var COOKIE_NAME = 'inu';	// Name des Cookies
	var options = { path: '/', expires: 14 };	// Pfad und Verfallsdatum des Cookies

	$.each(targets, function(i, val) {
		if($(this)[0].length > 0) {
			val[2] = Number($(this)[0].css('font-size').split('px')[0]);
		}
	});

	// Scalieren und in Cookie speichern
	function scale() {
		$.each(targets, function(i, val) {
			if($(this)[0].length > 0) {
				if(val[1] === undefined) { val[1] = 1; }
				$(this)[0].css("font-size",($(this)[1] * fontFactor * steps) + $(this)[2]);
			}
		});
		$.cookie(COOKIE_NAME, fontFactor, options);
	}

	// Cookie auslesen
	if ($.cookie(COOKIE_NAME) && $.cookie(COOKIE_NAME) != fontFactor){
		fontFactor = $.cookie(COOKIE_NAME);
		scale();
	}

	// Verkleinern
	$(".mainHeaderScaleDown").click(function() {
		if((fontFactor -= 1) < -maxSteps) { fontFactor = -maxSteps; }
		scale();
	});

	// Vergrößern
	$(".mainHeaderScaleUp").click(function() {
		if((fontFactor += 1) > maxSteps) { fontFactor = maxSteps; }
		scale();
	});

	// Normale Größe
	$(".mainHeaderScaleNormal").click(function() {
		fontFactor = 0;
		scale();
	});
// SCHRIFTGRÖßE [Ende]

// SOCIAL BOOKMARKS FIX [begin]
	$(".tx-timtabsociable-pi1").parent().css("margin-top", "0px");
// SOCIAL BOOKMARKS FIX [ende]

});
