function color(elem) {
	if (elem.attr("id") == "vertrieb") return "yellow";
	else if (elem.attr("id") == "verleih") return "blue";
	else if (elem.attr("id") == "produktion") return "red";
}

function resetFlags() {
	$('#flags a').css({backgroundPosition: '0px -22px'});
	$('body.yellow #flags #vertrieb, body.blue #flags #verleih, body.red #flags #produktion').css({backgroundPosition: '0px -6px'});
}

$('#flags').available(function () {
	resetFlags();
	$('#flags a').hover(function () {
		if (!$("body").hasClass(color($(this))))
			$(this).animate({backgroundPosition: '0px -6px', height: '52px'}, {queue: false});
		}, function () {
			if (!$("body").hasClass(color($(this))))
				$(this).animate({backgroundPosition: '0px -22px', height: '38px'}, {queue: false});
	});
});

$('#navi').available(function () {
	$('#navi li').filter(':not(.active)').hover(function () {
		var body = $(this).parents('body');
		if (body.hasClass('yellow')) {
			$(this).css('background', 'url(/fileadmin/templates/basis/images/navidot_hover_yellow.png) no-repeat 50% top');
		} else if (body.hasClass('blue')) {
			$(this).css('background', 'url(/fileadmin/templates/basis/images/navidot_hover_blue.png) no-repeat 50% top');
		} else {
			$(this).css('background', 'url(/fileadmin/templates/basis/images/navidot_hover_red.png) no-repeat 50% top');
		}
	}, function () {
		$(this).css('background', '');
	});
});

$(function () {
	$('.klappe').each(function () {
		var outer = $(this);
		var header = outer.children("h1");
		var body = header.siblings(); // outer.find(".bodytext");
		
		body.hide();
		header.click(function () {
				if ($(this).hasClass("klappeOffen")) {
					$(this).removeClass("klappeOffen");
					body.toggle("fast");
				} else {
					$(this).addClass("klappeOffen");
					body.toggle("fast");
				}
			});
	});
	$('.klappe').first().css({borderTop: "1px solid #E5CFCC"});
	
	var banner = $('#skyscraper');
	if (banner.length == 0 || banner.children().length == 0) {
		$('#innercontent').css({marginRight: "0px"});
	}
});

