$(function(){
    // Strijp Label:
    $("#strijpLabel").hover(function(){
        $(this).stop().animate({left: -90, top: 139}, 200, function(){
            $("#strijpBanner").show(); 
        });
    }, function(){
        $(this).stop().animate({left: -70, top: 140}, 200);
        $("#strijpBanner").hide(); 
    });
    
    
    
    // Subscribe voor nieuwsbrief:
    $("#subscribe input.text, .content input.text").focus(function(){
        $(this).val('');
    });
    
    
    
    // Dropdowns:
    $("#navigation ul li").hover(function(){
        $("ul", this).show(); 
    }, function(){
        $("ul", this).hide(); 
    });
    
    
    
    // Snelnavigatie:
    /*
    var snelNavigatieHeight = $("#snelNavigatie").height();    
    $("#snelNavigatie").css({top: -snelNavigatieHeight, display: "block"}).hover(function(){
        $("#snelNavigatie").stop().animate({top: 0}, 500);
    }, function(){
        $("#snelNavigatie").stop().animate({top: -snelNavigatieHeight}, 500);
    });
    */
    
	// Eerst FLIR doen vóór de home-content verborgen wordt!
    // FLIR.init({path: '/flir/'});

    /*
	$("h1, h2, h3").each(function(){
	    FLIR.replace(this, new FLIRStyle({cFont:'sohogothicpro', realFontHeight: true, mode: 'wrap' }));
	});
	*/

    Cufon.replace('h1,h2,h3');

    // Home Content:	
	var id=0;
	if($("var.showId").text()=='') {
		$("#contentHome .content:not(:first)").hide();
		$("#links .links:not(:first)").hide();
    } else {
		id = $("var.showId").text();
		$("#contentHome .content:not(.panel_"+id+")").hide();
		$("#links .links:not(.panel_"+id+")").hide();
	}
	
    
    // Checkbox:
    $("input.checkbox").checkbox({empty: '/assets/templates/natlab/images/empty.png'});
    
    
    
    // Woningzoeker:
    $(".woningen .top li a").click(function(){
        $(".woningen .top li").removeClass("active");
        $(this).parent().addClass("active");
        var a  = $(this).parent().attr("class").split('_');
        var id = a[1];
        // Load AJAX data:
        $.get('/ajax/woningtypes.html', {id: id}, function(data) {
            $(".woningen .left, .woningen .right").html('');
            $(".woningen .left").html(data);            
            bindWoningenFunctions();
        });
        return false;
    });
    
    bindWoningenFunctions();
    
        
    // FLIR:
    /*
    $("#navigation ul a").not("ul ul li a", this).each( function(){
        FLIR.replace(this, new FLIRStyle({ cFont:'sohogothicpro', realFontHeight: true }));
    });
	*/

    Cufon.replace('#navigation ul a:not(ul ul li a), #links a');

    // $("#links a, div.woningen .top a").each(function(){
    /*
    $("#links a").each(function(){
        FLIR.replace(this, new FLIRStyle({ cFont:'sohogothicpromedium', realFontHeight: true }));
    });
    */
    
    
    
    // SWFObject:
	swfobject.embedSWF("/assets/templates/natlab/swf/header.swf", "flashHeader", "910", "300", "9.0.0", "/assets/templates/natlab/swf/expressInstall.swf", {activeID: id, xmlFile: "/navigation.xml"}, {wmode: "transparent"}, {id: "flashHeader"});
	swfobject.embedSWF("/assets/templates/natlab/swf/minimap.swf", "flashMap", "175", "220", "9.0.0", "/assets/templates/natlab/swf/expressInstall.swf", {activeId: id}, {wmode: "transparent"}, {id: "flashMap"});
});



function bindWoningenFunctions() {
    $(".woningen .left li").hover(function(){
        $("a", this).addClass("hover");
    }, function(){
        $("a", this).removeClass("hover");
    }).click(function(){
        /*
        $(".woningen .left li").removeClass("active");
        $(this).addClass("active");
        */
        $("a", this).click();
    }).css({cursor: "pointer"});
    
    $(".woningen .left li a").click(function(){
        $(".woningen .left li").removeClass("active");
        var a  = $(this).parent().parent().attr("class").split('_');
        var id = a[1];
        $(this).parent().parent().addClass("active");
        $(".woningen .right").html('<img src="/ajax-loader.gif" style="margin-left: 170px; margin-top: 50px;" />');
        // Load AJAX data:
        $.get('/ajax/woningdetail.html', {id:id}, function(data){
            $(".woningen .right").html(data); 
        });
        return false;
    });    
}



function showHomeContent(className, changeBig) {
	/*
    $("#contentHome .content:visible").fadeOut(250, function(){
        $("#contentHome ."+className).fadeIn(250);        
    });
    $("#links .links:visible").fadeOut(250, function(){
        $("#links ."+className).fadeIn(250);        
    });
	*/
    $("#contentHome .content:visible").hide();
    $("#contentHome ."+className).show();
	
    $("#links .links:visible").hide();
    $("#links ."+className).show();
	
	var a = className.split('_');

	if(changeBig==undefined) { changeBig = false; }

	if(changeBig) {
		// Verander de grote plaat:
		var flashObject = document.getElementById("flashHeader");
		flashObject.activate(a[1]);
	} else {
		var flashObject = document.getElementById("flashMap");
		flashObject.activate(a[1]);
	}
	
}


