$( document ).ready(function(){

  /*
   * Submenu
   */
  var timer;
  $( '.villadm' ).hover(function(){
    clearTimeout( timer );
    $( '.villadm' ).addClass('h');
    $( '#dropdown' ).show();
  },function(){
    timer = setTimeout("hideMenu()",300);
  });
  $( '#dropdown a' ).hover(function(){
    clearTimeout( timer );
    $( '.villadm' ).addClass('h');
  },function(){
    timer = setTimeout("hideMenu()",300);
  });

  /*
   * H2 Koppen
   */
  $('h2').Heading();

  /*
   * Portfolio click ( ie7 & 8 fix for bubbles )
   */
  $('#portfolio li a img').click(function(e) {
      $(this).parent().click();
  }); 
});

/**
 * om de dropdown te verstoppen
 */
function hideMenu() {
  $( '.villadm' ).removeClass('h');
  $( '#dropdown' ).hide();
}

/*
 * Heading replacement class
 */
(function($){
  $.fn.Heading = function(options) {
    var defaults = {
      url: 'assets/h2/'
    };
    var options = $.extend(defaults, options);
    return this.each(function() {
      $(this).css('visitbility','hidden');
      var heading = $(this);
      var text = heading.html().replace('<SPAN><!-- --></SPAN>','').replace('<span><!-- --></span>','');
      var img = "<span><!-- --></span><img class='replacement' src='" + options.url + escape( text ) + ".png' alt='' title='' />";
      heading.html( img );
      $(this).css('visibility','visible');
    });
  }
})(jQuery);
