// @author: Kevin Alberts
// @date: 02-08-2011

$(document).ready(function(){
	//Hide (Collapse) the toggle containers on load
	$("#nummer_form").hide(); 
	//Setup variables to use in functions
	nummerformToggled=0;
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("#nummer_belme").mouseenter(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
		nummerformToggled=1;
		return false; //Prevent the browser jump to the link anchor
	});
	$('#nummer_form').mouseleave(function(){
		if (nummerformToggled==1)
		{
		$("#nummer_form").toggleClass("active").andSelf().slideToggle('slow');
		nummerformToggled=0;
		return false;
		}
	});
});

$(function() {
	var active = false;
	$('#mainNavigatie li').mouseover(function() {
		active = true;
	});
	$('.listChildren').mouseout(function() {
		active = false;
		hideSub();
	});
	$('#mainNavigatie li').mouseenter(function() {
		active = true;
		
		var el = $(this).find('.listChildren');
		if(el.css('display') == 'none'){
			$(this).find('.listChildren').show('fast');
		} 
		
	});
	$('#mainNavigatie li').mouseleave(function() {
		active = false;

		var el = $(this).find('.listChildren');
		if(el.css('display') == 'block'){
			$(this).find('.listChildren').hide('fast');
		}
		hideSub();
	});

	function hideSub() {
		setTimeout(function() {
			if(active == false) {
				$('.listChildren').hide('fast');
			}
		}, 10);
	}
});
