function disableLink(e) {
    // cancels the event
    e.preventDefault();

    return false;
}

//WICHTIG ändern:
var anzahlProjekte = 25;

$(function() {
	
	$(".an").css("text-decoration", "none");
	$(".links").mouseenter(function() {
		$(".links p").fadeIn(500, function () {});
		$(".links .bg").fadeIn(500, function () {});
		$(".an").css("text-decoration", "none");
	}).mouseleave(function() {
		$(".links p").fadeOut(200, function () {});
		$(".links .bg").fadeOut(200, function () {});
		$(".an").css("text-decoration", "line-through");
	});
			
	$(".rechts").mouseenter(function() {
		$(".rechts p").fadeIn(500, function () {});
		$(".rechts .bg").fadeIn(500, function () {});
	}).mouseleave(function() {
		$(".rechts p").fadeOut(200, function () {});
		$(".rechts .bg").fadeOut(200, function () {});
	});
	
	// Ausschließlich Web- oder CD-Projekte
	var arrayWeb = new Array (2, 7, 12, 13, 16, 18, 22, 23, 24);
	var arrayCD = new Array (3, 4, 17, 19, 20);
	
	var noWeb = false;
	var noCD = false;
	
	$(".bu1").click(function() {
		noWeb = true;
		$(".bu1").addClass('aktiv');
		$(".bu2").removeClass('aktiv');
		for (i = 0; i < arrayWeb.length; i++) {
			$(".element" + arrayWeb[i]).fadeTo(1000, 0.2, function(){});
			$(".element" + arrayWeb[i]).bind('click', disableLink);
			$(".element" + arrayWeb[i] + " a").addClass('inaktiv');
		}
		
		if (noCD) {
			noCD = false;
			for (i = 0; i < arrayCD.length; i++) {
				$(".element" + arrayCD[i]).fadeTo(1000, 1, function(){});
				$(".element" + arrayCD[i]).unbind('click', disableLink);
				$(".element" + arrayCD[i] + " a").removeClass('inaktiv');
			}
		}
		
	});
	
	$(".bu2").click(function() {
		noCD = true;
		$(".bu1").removeClass('aktiv');
		$(".bu2").addClass('aktiv');
		for (i = 0; i < arrayCD.length; i++) {
			$(".element" + arrayCD[i]).fadeTo(1000, 0.2, function(){});
			$(".element" + arrayCD[i]).bind('click', disableLink);
			$(".element" + arrayCD[i] + " a").addClass('inaktiv');
		}
		
		if (noWeb) {
			noWeb = false;
			for (i = 0; i < arrayWeb.length; i++) {
				$(".element" + arrayWeb[i]).fadeTo(1000, 1, function(){});
				$(".element" + arrayWeb[i]).unbind('click', disableLink);
				$(".element" + arrayWeb[i] + " a").removeClass('inaktiv');
			}
		}
	});
	
	// Startseitenweiche:
	var topic = window.location.href.slice(window.location.href.indexOf('?') + 1);
	if (topic == "corporate_design") {
		$(".bu1").click();
	} else if (topic == "artdirektion_internet") {
		$(".bu2").click();
	}
	
	// Nummeranzeige
	var nummer = parseFloat(window.location.href.slice(window.location.href.indexOf('#') + 2));
	if (nummer >= 1) {
		if (nummer < 10) {
			nummer = "0"+nummer;
		}
		$(".num").text(nummer);
		$(".gesamt").text(anzahlProjekte);
	}
	
});
