$(document).ready(function() {
  $(".overview-teaser li a").mouseenter(function() {
    var imgObj = $(this).parent().parent().parent().prev().children();
    imgObj.attr("src", $(this).attr("imgSrc"));
  });
  
  // init aplan
  aPlan.init();
  
  //check zip downloads
  $("a.dl").each(function() {
    if ($(this).attr("href").indexOf(".zip") > -1) {
      $(this).addClass("dl-zip");
    }
  });
				
	$('ul#sujet').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '200px'
	});


			$(".lightbox").lightbox({
			    fitToScreen: true,
			    imageClickClose: false
		    });
			
			$(".lightbox-2").lightbox({
			    fitToScreen: true
		    });

});

var netural = {
    openWindow: function(title, url, width, height) {
        // no url, no popup
        if (!url) return;
        // set default title, width and height if not set
        if (!title) title = "newWindow";
        if (!width) width = 400;
        if (!height) height = 400;
        
        //open new window
        var newWindow = window.open(url, title, "width=" + width + ",height=" + height);
            // let newWindow get focus
            if (window.focus) {
               newWindow.focus();
        }
    }
}

function tab(tab, that) {
    if (!tab) return;
    $("#tab .handler").removeClass("on");
    $("#tab .tab").hide(0);
    $(that).addClass("on");
    $("#"+tab).show(0);
}

var aPlan = {
    path: "/MKW.Node/_ext/aplan/",
    init: function() {
        if ($("#a-plan")) {
            $("#a-l-p").click(aPlan.step1);
            $("#a-p-1").click(aPlan.step1);
        }
    },
    
    step0: function() {
        $("#a-img").attr("src", aPlan.path + "plan_1.jpg");
        $("#a-p-1").show();
        $("#a-p-2").hide();
        $("#a-l-m").css("opacity", 0.3);
        $("#a-l-m").css("cursor", "default");

        $("#a-l-p").unbind("click").click(aPlan.step1);
    },
    
    step1: function() {
        $("#a-img").attr("src", aPlan.path + "plan_2.jpg");
        $("#a-p-1").hide();
        $("#a-p-2").show();
        $("#a-p-3-a").hide();
        $("#a-p-3-b").hide(); 
        $("#a-l-m").css("opacity", 1);
        $("#a-l-m").css("cursor", "pointer");
        
        $("#a-l-m").unbind("click").click(aPlan.step0);
        $("#a-l-p").unbind("click").click(aPlan.step2);
        $("#a-p-2").unbind("click").click(aPlan.step2);
    },
    
    step2: function() {
        $("#a-img").attr("src", aPlan.path + "plan_3.jpg");
        $("#a-p-2").hide();
        $("#a-p-3-a").show();
        $("#a-p-3-b").show(); 
        $("#a-l-p").css("opacity", 1);
        $("#a-l-p").css("cursor", "pointer");

        $("#a-l-m").unbind("click").click(aPlan.step1);
        $("#a-l-p").unbind("click").click(aPlan.step3);
        $("#a-p-3-a").unbind("click").click(function() { aPlan.step3("haag") });
        $("#a-p-3-b").unbind("click").click(function() { aPlan.step3("weibern") });

        $("#a-ext").hide();
    },
    
    step3: function(loc) {
        if (loc == "haag") {
            $("#a-img").attr("src", aPlan.path + "plan_5.jpg");
        } else {
            $("#a-img").attr("src", aPlan.path + "plan_4.jpg");
        }
        $("#a-l-p").css("opacity", 0.3);
        $("#a-l-p").css("cursor", "default");
        $("#a-p-3-a").hide();
        $("#a-p-3-b").hide(); 
        
        $("#a-ext").show();

        $("#a-l-m").unbind("click").click(aPlan.step2);
    }
}

