$(document).ready(function(){
	if (jQuery.isFunction($(document).pngFix)) {
		$(document).pngFix(); 
	}
	
	
	$("#mensen > li > a ").mouseenter(mensenShowInfo);
	//$("ul#nav > li > a").mouseenter(buttonOver);



	var cacheImage1 = document.createElement('img');
	var cacheImage2 = document.createElement('img');
	var cacheImage3 = document.createElement('img');
    cacheImage1.src = "/static/img/buttons/nieuws_down.png";
	cacheImage2.src = "/static/img/buttons/tips_down.png";
	cacheImage3.src = "/static/img/buttons/vestigingen_down.png";




	$("#mensen_container").height($(document).height()-360);
	var h = ($(document).height()-460) / 130;
	h = Math.round(h-0.5);
	h = h *130;
	$('#mensen_mask').height(h);
	$('#mensen_container .prev').fadeTo('fast', 0.25);
	$('#mensen_mask').serialScroll({
		items:'li',
		prev:'#col1 a.prev',
		next:'#col1 a.next',
		duration:1500,
		axis:'y',
		easing:'easeInOutQuart',
		force:true,
		step: 3,
		exclude:3,
		duration:1200,
		lock:false,
		lazy:true,
		cycle:false,
		onBefore:scrolling
	});
				 
 	//$(window).scroll(positionFooter).resize(positionFooter);
	//
	if( navigator.userAgent.match(/Android/) ||
		navigator.userAgent.match(/webOS/) ||
		navigator.userAgent.match(/iPhone/) ||
		navigator.userAgent.match(/iPod/) ||
		navigator.userAgent.match(/iPad/) ||
		navigator.userAgent.match(/BlackBerry/)
	){
		$("#footer_bg").css({position: "relative",float:"left"});
	}

});

/*function positionFooter(){
	$("#footer_bg").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#footer_bg").height())+"px"})	
}*/

function scrolling(e, target, elm, items, pos)
{
	$('#mensen_container .next').fadeTo('fast', 1);
	$('#mensen_container .prev').fadeTo('fast', 1);
	if (pos+3 >= items.length-1){
		$('#mensen_container .next').fadeTo('fast', 0.25);
	}
    if (pos == 0){
        $('#mensen_container .prev').fadeTo('fast' , 0.25);
    }

	
}

function mensenShowInfo(e) {
	var a = $(e.currentTarget);
	var div = a.children("div");
	a.unbind();
	
	a.mouseleave(function()
		{
			div.hide();
			a.unbind();
			a.mouseenter(mensenShowInfo);
		});
	div.show('slide', {direction:"right"}, 150, function()
		{	
			a.mouseleave(mensenHideInfo);
		});
	

}
function mensenHideInfo(e) {
	var a = $(e.currentTarget);
	var div = a.children("div");
	a.unbind();
	
	div.hide('slide', {direction:"right"}, 300, function()
		{
			a.mouseenter(mensenShowInfo);
		});
	
}



function buttonOver(e) {
	var a = $(e.currentTarget);
	a.unbind();
	
	a.addClass('nav_over');
	a.mouseleave(buttonOut);
	

}
function buttonOut(e) {
	var a = $(e.currentTarget);
	a.unbind();

	a.removeClass('nav_over');
	a.mouseenter(buttonOver);
	
}


