function divsHeight() 
{
//   var heights = [];
// 
//   // Hoogtes
//   heights[0] = document.getElementById('block1');
//   heights[1] = document.getElementById('block2');
//   heights[2] = document.getElementById('block3');
//   
//   var max = 0;
//   
//   for(var i = 0; i < heights.length; i++)
//   {
//     if(heights[i]&&heights[i].offsetHeight > max)
//     {
//       max = heights[i].offsetHeight;
//     }
//   }
//   max = max - 5;
//   // Set hoogte
//   for(var x = 0; x < heights.length; x++)
//   {
//     heights[x].style.height = max + "px";
//   }
  
  
  // in jQuery:
  
  var heights = $('#block1, #block2, #block3');
  var max = 0;
  heights.each(function(i){
  	if(max < $(this).height()) max = $(this).height();
  });
  heights.height(max);
  
}

$(window).bind('load resize', divsHeight);

// Kies of je postcode of plaats wil zoeken
function togglePostcode()
{
	$('#zoekpostcode').show();
	$('#zoekplaats').hide();
}

function togglePlaats()
{
	$('#zoekpostcode').hide();
	$('#zoekplaats').show();
}

  
function checkValue(lmn, focus, password){
	if(focus){
		if(lmn.value==lmn.alt){
			lmn.value = "";
			$(lmn).removeClass('dimmed');
		}
		if(password)changeType(lmn, 'password').focus();
	}else{
		if(lmn.value==""){
			if(password)lmn = changeType(lmn,'text');
			lmn.value = lmn.alt;
			$(lmn).addClass('dimmed');
		}
	}
}
function changeType(lmn,type){
	try{
		lmn.type = type;
		return lmn;
	}catch(err){
		var n = $(lmn).attr('name')
		var f = lmn.onfocus;
		var b = lmn.onblur;
		
		var newinput = $('<input type="'+type+'" name="'+n+'" class="'+$(lmn).attr('class')+'" onfocus="checkValue(this,true,true)" onblur="checkValue(this,false,true)" />')
		newinput.attr({
			alt:$(lmn).attr('alt')
		})
		newinput.bind('focus',f);
		newinput.bind('blur',b);
	
		$(lmn).replaceWith(newinput[0]);
		return newinput[0];
	}
}
function copyFormItems(formArrayName, srcArray, destArray){
	$(srcArray).each(function(i){
		var s = $('input[name='+formArrayName+'['+this+']]');
		var d = $('input[name='+formArrayName+'['+destArray[i]+']]');
		if(s.length==1==d.length) d[0].value = s[0].value;
	})
}

// handle LinkToTop button
var topperID;
var _doTopperPositioning = true;
function doTopperPositioning(bool){
	_doTopperPositioning = bool;
}
$(window).bind('load',function(){
	if($(document).height()>$(window).height()){
		//$('#topper').show().css({opacity:0,top:$(window).height()+80});
	}
})
$(window).bind('load  resize scroll',function(){
	clearTimeout(topperID);
	topperID = setTimeout("setTopper()",400);
});

function setTopper(){
	if(_doTopperPositioning){
		doTopperPositioning(false)
		var h =  $(document).scrollTop();
		if( h!=0){
			h += $(window).height() -80;
			$('#topper').fadeIn(200).animate({top:h},500,'swing',function(){doTopperPositioning(true)})
		}else{
			$('#topper').fadeOut(100, function(){doTopperPositioning(true)})
			//doTopperPositioning(true)
		}
	}
}
$(window).bind('load',function(){
})

