$(document).ready(function(){

  $('.query').focus(function(){
    if($(this).val() == 'zoeken'){
      $(this).val('');
    }
  });
  $('.query').blur(function(){
    if($(this).val() == ''){
      $(this).val('zoeken');
    }
  });
  $('.item-kaart').live('click', function(){
	 $(this).parent().find('.item-kaart-tooltip').fadeIn('fast');
  });
  
  $('body').click(function(){
	$('.item-kaart-tooltip').fadeOut('fast');
  });
  
  $('input[type="checkbox"]').coolCheckbox();

  $('select').selectbox();

  if($('#slideshow').length > 0){
    $('#slideshow').cycle({
      fx: 'fade',
      timeout: 11000
    });
  }

  $('.news-image-link').fancybox();

  $('.reageer_link').fancybox({
    'transitionIn'  : 'fade',
    'transitionOut' : 'fade',
    'speedIn'   : 150,
    'speedOut'    : 150,
    'overlayShow': false
  });
  
  $('.item-image-link').fancybox({
    'transitionIn'  : 'fade',
    'transitionOut' : 'fade',
    'speedIn'   : 150,
    'speedOut'    : 150,
    'overlayShow': false
  });
  
  $('a[rel=lightbox]').fancybox({
    'transitionIn'  : 'fade',
    'transitionOut' : 'fade',
    'speedIn'   : 150,
    'speedOut'    : 150,
    'overlayShow': false
  });
  
//  $('.text').each(function(){
//    var t = $(this).html();
//    t = t.replace(/'s-Hertogenbosch/g, '<span style="white-space: nowrap;">\'s-Hertogenbosch</span>');
//    $(this).html(t);
//  });
  
  $('.lotnummer').mask("?99999999");
  $('#hit_leeftijd').mask("?9999999");
  $('#hit_aantal_personen').mask("?9999999");
  $('#hit_inkomen').mask("?9999999");
  
  $('#inschrijving_brjaarinkomen').mask("?9999999");
  $('#inschrijving_ma_brjaarinkomen').mask("?9999999");
  $('.digonly').mask("?9999999");
  
  $('.faq .question').click(function(){
    $('.answer').slideUp('fast');
    $(this).parent().find('.answer').slideToggle('fast');
  })
  
  $('a[rel=adminlink]').click(function(){
    $('#admin-iframe').find('iframe').attr('src', $(this).attr('href'));
    $('#overlay').show();
    $('#admin-iframe').show();
    $('html').css({ overflow: 'hidden' });
    return false;
  });
  $('#close-admin-iframe').click(function(){
    $('#admin-iframe').hide();
    $('html').css({ overflow: 'auto' });
    location.reload(true);
    return false;
  })
  
});

function scrollToId(id){
  $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

