// JavaScript Document
$(document).ready(function () {
	
	window.setInterval('scroller()',50);

  $('.inleiding').each(function() {
   objMaxHeight($(this), 50, true, false);
  });

  $('.inleiding').css('overflow', 'hidden');

	$('.stnd').blur(function() {
		if($(this).val()==''){
			$(this).val($(this).attr('alt'));
		}
	});
	$('.stnd').focus(function() {
		if($(this).val()==$(this).attr('alt')){
			$(this).val('');
		}
	});
	$('.stnd').each(function(){
		if($(this).val()==''){
			$(this).val($(this).attr('alt'));
		}
	});
	
	$('li.hassub').mouseenter(
		function(){
			var id = $(this).attr('id').replace('main', 'sub');
			var h = ($(this).attr('value')*24);
			$('#submenuBg').css('height', h+'px');
			$('#submenuBg').show();
			//$('span#'+id).show();
		}).mouseleave(
		function(){
			var id = $(this).attr('id').replace('main', 'sub');
			$('#submenuBg').hide();
			//$('span#'+id).hide();
		}
		
	);
	
	  $(".popup").fancybox({
			'overlayShow':	true,
			'overlayOpacity':0.5,
			'zoomSpeedIn':	500, 
			'zoomSpeedOut':	500
	  });

});

function objMaxHeight(obj, val, dots, frontpage) {
 var startLen = $(obj).html().length;
 var meer = '... <span class="bold wit">meer &gt;</span>';
 
 while ($(obj).height() > val) {
  $(obj).html( $(obj).html().substr(0, $(obj).html().length-5) );
 }
 
 if (frontpage) {
  $(obj).html( $(obj).html().substr(0, $(obj).html().length-2) + meer );
  while ($(obj).height() > val) {
   $(obj).html( $(obj).html().substr(0, $(obj).html().length-2-meer.length) + meer );
  }
 } else if (dots && startLen > $(obj).html().length) {
  $(obj).html( $(obj).html().substr(0, $(obj).html().length-3) + '...' );
 }
 
 $(obj).css('height', val+'px');
}

function scroller(){
	var position = parseInt(document.getElementById('scrollbar').style.backgroundPosition);
	position++;
	document.getElementById('scrollbar').style.backgroundPosition=(position)+'px';
}

function toggleSubcat(id){
	$('.togglesubcat').each(function(){
		if($(this).attr('id')!='cat'+id){
			$(this).hide();
		}
	 });
	$('#cat'+id).toggle();
}
