var timer;

$(document).ready(function() {
	// NIEUWSBRIEF VELD /	
	var nieuwsbrief_val = $("#nieuwsbrief_email").val();
	
	// verwijderd de ingevulde standaard tekst van het nieuwsbrief veld 
	$("#nieuwsbrief_email").focus(function() {
		if ($(this).val() == nieuwsbrief_val) $(this).val("");
	}).blur(function() {
		$(this).val( $.trim($(this).val()) );
		if ($(this).val() == "") $(this).val(nieuwsbrief_val);
	});
	
	$("div.nieuwsbrief form").submit( function() {
		$("div.nieuwsbrief form input.button").attr("disabled", "disabled");
		if ($("#nieuwsbrief_email").val() == nieuwsbrief_val) {
			$("div.nieuwsbrief form input").removeAttr("disabled");
			return false;
		} 
	});
	// NIEUWSBRIEF VELD EIND //
	
	// zoekcriteria pandenoverzicht
	if ($.cookie('zoekcriteria') == "closed") {
		$("#zoekcriteria div.openclose").text("open venster");
		$("#zoekcriteria table").hide();
	} else {
		$("#zoekcriteria div.openclose").text("sluit venster");
	}
	
	$("#zoekcriteria div.openclose").click( function() {
		if ($.cookie('zoekcriteria') == "closed") {
			$("#zoekcriteria div.openclose").text("sluit venster");
			$.cookie('zoekcriteria', 'opened');
			$("#zoekcriteria table").show();
		} else {
			$("#zoekcriteria div.openclose").text("open venster");
			$.cookie('zoekcriteria', 'closed');
			$("#zoekcriteria table").hide();
		}
	});
	
	
	var bg_pand_even = $("div.pand_even").css("background-color");
	var bg_pand_oneven = $("div.pand_oneven").css("background-color");
	
	$("div.pand_even, div.pand_oneven").click(function() {
		document.location = $(this).find("a").attr("href");
	});
	
	$("div.pand_even").mouseover(function() {
		$(this).stop().animate({ backgroundColor: "#e5e5cc" }, 200);
	}).mouseout(function() {
		$(this).stop().animate({ backgroundColor: bg_pand_even }, 200);
	});
	
	$("div.pand_oneven").mouseover(function() {
		$(this).stop().animate({ backgroundColor: "#86746e" }, 200);
	}).mouseout(function() {
		$(this).stop().animate({ backgroundColor: bg_pand_oneven }, 200);
	});
	
	
	
	// verberg alle sub nav items en opent de subitems van de actieve nav
	$("#nav ul").hide();
	$("#nav li.active ul").show();
	$("#nav li.active").children("a").addClass("foldout");
	
	$("#nav > li").not(".active").mouseover(function() {
		$(this).stop().animate({ backgroundColor: '#492d2a' }, 200);
	}).mouseout(function() {
		$(this).stop().animate({ backgroundColor: '#381514' }, 200);
	});
	
	$("#nav > li li").not(".active").mouseover(function() {
		$(this).stop().animate({ backgroundColor: '#928968' }, 200);
	}).mouseout(function() {
		$(this).stop().animate({ backgroundColor: '#78645d' }, 200);
	});
	

	// mouseover op de submenus zodat deze uitklappen
	$("#nav").children().not(".active").mouseover(function() {
		clearTimeout(timer);
		$(this).children().addClass("foldout");
		$(this).children("ul").animate( {height: 'show'}, 400 );
	}).mouseout(function() {
		clearTimeout(timer);
		timer = setTimeout("hideAllSubNav()", 800);
	});
});

function closeSubNav() {
	$("#nav").children().removeClass("hover");
	if ($("#subnavbox").css("left") != subNavClosed) {
		$("#subnavbox").stop().animate( {left: subNavClosed}, 200, function() {
			$(this).empty();
		});
	}
}

function hideAllSubNav() {
	// verbergt alle, behalve de actieve, submenu's
	$("#nav li").not(".active").children("ul").animate( {height: 'hide'}, 400, function() {
		$(this).parent().children().removeClass("foldout");
	});
}

function closeSubNav() {
	$("#nav").children().removeClass("hover");
	if ($("#subnavbox").css("left") != subNavClosed) {
		$("#subnavbox").stop().animate( {left: subNavClosed}, 200, function() {
			$(this).empty();
		});
	}
}

