
function sizeText(size) {
	var link;
	var url;
	var pos;
	
	$('head link').each(function(i) {
		url = $(this).attr('href');
		pos = url.indexOf('fontsize');
		if (pos > 0) {
			link = $(this);
			url = url.substring(0, pos + 8) + size + url.substring(pos + 9);
			
			$(this).attr('href',url);
		}
	});
	document.cookie = "lettergrootte=" + size + ";expires=31/12/2099 00:00:00";
	return false;
}

var total_divs=0; 
var className='items';
function fadeEngine(x) {
	var y=x;
	if(x==total_divs) y=1; else y++;
		$("#fade"+x).fadeOut(2000);
		$("#fade"+y).fadeIn(2000);
			
		setTimeout('fadeEngine('+y+')',5000);
}

$(document).ready(function () {


	$('.newwindowlink').attr("target", "_blank");
	$(".newwindowlink a").attr("target", "_blank");
		
		
	
	$('.submitbtn').hover(function(){
		$(this).addClass("hover");
	}, function(){ 
		$(this).removeClass("hover");
	});
	
	$("."+className).attr("id", function (arr) {
		total_divs++;
		return "fade" + (arr+1);
	});
	fadeEngine(0);
	
	/* Tooltip engine */
	$('.tooltip-show').hover(function(){
			$('.tooltip').hide();
	
			var offset = $("#"+this.id).offset();
			
			$("#tt-" + this.id).css({
				'left' : offset.left-250, 
				'top' : offset.top-90, 
				'position' : 'absolute',
				'height' : '100px',
				'width' : '300px'
			});
	
			$("#tt-" + this.id + " div").addClass("content");
			$(".tooltip-close").fadeIn("fast");
			$("#tt-" + this.id).fadeIn();
	
	},
	    function(){
	        $('div.tooltip').hide();
	    }
	);
	/*end*/
	
	/* Leslocatie hover tooltip engine */
	$('.les-tooltip-show').hover(function(){
			$('.lestooltip').hide();
	
			var offset = $("#"+this.id).offset();
			
			$("#lestt-" + this.id).css({
				'left' : "-2px", 
				'top' : 0, 
				'position' : 'absolute',
				'height' : 'auto',
				'width' : '200px'
			});
	
			$("#lestt-" + this.id + " div").addClass("content");
			$(".les-tooltip-close").fadeIn("fast");
			$("#lestt-" + this.id).fadeIn();
			
	
	},
	    function(){
	      /*  $('div.lestooltip').hide();*/
	    }
	
	);
	$('.lestooltip').mouseleave(function(){
	    $('div.lestooltip').hide();
	});
	/*end*/
    $(".watermarksearch").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "titel, onderwerp, etc."
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarksearch").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("titel, onderwerp, etc.");
    });
    
    $(".watermarknieuwsbrief").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "Uw email adres"
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarknieuwsbrief").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("Uw email adres");
    });
	
	$(".watermarkstraatnaam").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "Straatnaam"
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarkstraatnaam").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("Straatnaam");
    });
	
	$(".watermarkpostcode").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "Postcode"
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarkpostcode").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("Postcode");
    });

	$(".watermarkhuisnr").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "Huisnr"
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarkhuisnr").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("Huisnr");
    });
	
	$(".watermarkwoonplaats").focus(function() {
        $(this).filter(function() {
            return $(this).val() == "" || $(this).val() == "Woonplaats"
        }).removeClass("watermarkOn").val("");
    });    
    $(".watermarkwoonplaats").blur(function() {
        $(this).filter(function() {
            return $(this).val() == ""
        }).addClass("watermarkOn").val("Woonplaats");
    });


if($('#tabcontent').length > 0) {
	$('#tabcontent').tabs({ fxFade: false, fxSpeed: 'fast' });
	$('.tabstitle').show();
}

if($('#locatieaccordion').length > 0) {
	$("#locatieaccordion").accordion({
		active: false,
		header: '.accordionheader',
		alwaysOpen: false
	});
}
/* Tooltip engine */
$('.tooltip-show').click(function(){
		$('.moreinformation').fadeOut("fast");
		var offset = $("#"+this.id).offset();
		$("#tt-" + this.id + " div").addClass("content");
		$(".tooltip-close").fadeIn("fast");
		$("#tt-" + this.id).fadeIn();
		return false;
});
$('.tooltip-close').click(function(){
	$(".moreinformation").fadeOut("fast");
	return false;
});
/*end*/


function doSomething() {
    $("#meeropties").css('width', '1px');
	var countedWidth = $(document).width();
	var countedHeight = $(document).height();
	var sidebarWidth = 218;
	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
		var ieversion=new Number(RegExp.$1) 
		if (ieversion>=6) {
			sidebarWidth = 238;
		}
		if (ieversion>=7) {
			sidebarWidth = 218;
		}
	}
	countedWidth = countedWidth - sidebarWidth;
	$("#meeropties").css('width', countedWidth);
	$("#jsddm ul ul").css('width', countedWidth);
	$(".foldout").css('height', countedHeight);
	$(".foldoutBack").css('height', countedHeight);
};

var resizeTimer = null;
$(window).bind('resize', function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(doSomething, 100);
});

	var countedHeight = $(document).height();
	countedHeight = countedHeight;
	$('#hoofdnavigatie .foldout').css('height',  countedHeight);
	$('#hoofdnavigatie .foldoutBack').css('height',  countedHeight);

	var config = {    
     sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: makeTall, // function = onMouseOver callback (REQUIRED)    
     timeout: 500, // number = milliseconds delay before onMouseOut    
     out: makeShort // function = onMouseOut callback (REQUIRED)    
	};

	
	
	$('#hoofdnavigatie .head').hoverIntent( config );

	function makeTall() {
		//$(".foldoutBack").css('display', 'block');
		$(this).find(".foldout").css('display', 'block');
		//$(this).find(".foldout").fadeIn(400);
		$('#hoofdnavigatie li a',this).removeClass("active");
		$('a',this).addClass("active");
		$("#meeropties").fadeOut("fast");
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
			var ieversion=new Number(RegExp.$1) 
			if (ieversion>=6) {
				$("select").hide();
			}
		}
	};
	function makeShort() {
		$(this).find(".foldout").css('display', 'none');
		$('a',this).removeClass("active");
		
	};
	$('#hoofdnavigatie').mouseout(function(){
		//$(".foldoutBack").css('display', 'none');
		
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
			var ieversion=new Number(RegExp.$1) 
			if (ieversion>=6) {
				$("select").show();
			}
		}
	});
	
	function removefoldoutBack(){
		//$(".foldoutBack").css('display', 'none');
	};



	var meeroptiesStatus = 0;
	$('.meeropties').click(function(){
		var countedWidth = $(document).width();
		
			var sidebarWidth = 218;

			if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
				var ieversion=new Number(RegExp.$1) 
				if (ieversion>=6) {
					sidebarWidth = 239;
				}
				if (ieversion>=7) {
					sidebarWidth = 218;
				}
			}
			countedWidth = countedWidth - sidebarWidth;

		if(meeroptiesStatus == 0) {
			$("#meeropties").fadeIn("slow");
			$("#meeropties").css('width', countedWidth);
			$('.meeropties').html("minder zoekopties");
			$('.meeropties').addClass("active");
			meeroptiesStatus = 1;
		} else {
			$("#meeropties").fadeOut("fast");
			$('.meeropties').html("meer zoekopties");
			$('.meeropties').removeClass("active");
			meeroptiesStatus = 0;
		}
		return false;
	});

	var timeout    = 500;
	var closetimer = 0;
	var ddmenuitem = 0;
	var subnavStatus = 1;
	var defaultStatus ;

	function jsddm_open() {  
		jsddm_canceltimer();
		jsddm_close();
		var countedWidth = $(document).width();
		
		if(subnavStatus == 0) {
			ddmenuitem = $(this).find('ul').slideDown("medium");
			subnavStatus = 1;
		} else {
			ddmenuitem = $(this).find('ul').css('display', 'block');	

		}
		var sidebarWidth = 240;
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
			var ieversion=new Number(RegExp.$1) 
			if (ieversion>=6) {
				sidebarWidth = 261;
			}
			if (ieversion>=7) {
				sidebarWidth = 240;
			}
			if (ieversion>=8) {
				sidebarWidth = 260;
			}
		}
		countedWidth = countedWidth - sidebarWidth;
		$(this).find('ul').css('width', countedWidth);
		$('#jsddm').find('a').removeClass("current");
		$(this).find('a:first').addClass("current");
		//$(".echo").append("tuut#");

	}

	

	function jsddm_close() 
	{  
		if(ddmenuitem) {
			ddmenuitem.css('display', 'none');
			//ddmenuitem.slideUp("medium");
		}
		$('#jsddm').find('a').removeClass("current");
	}
	function removeStatus() {
		
			window.clearTimeout(defaultStatus);
			defaultStatus = 0;
	}

	function jsddm_timer()
	{  
		closetimer = window.setTimeout(jsddm_close, timeout);
		defaultStatus = window.setTimeout(removeStatus, timeout);
	}

	function jsddm_canceltimer()
	{  
		if(closetimer)
		{  
			window.clearTimeout(closetimer);
			closetimer = null;
		}	  
	}

	$(document).ready(function()
	{  
	   $('#jsddm > li').bind('mouseover', jsddm_open);
	   $('#jsddm > li').bind('mouseout',  jsddm_timer);
	});

	document.onclick = jsddm_close;


});




