$(document).ready(function() {
  wwwGidsInit();
});

/**
* Resizes pictures in afbeeldinghouder to correct format
*/
$(window).load(function(){
$(".afbeeldinghouder img").each(function(){
 if($(this).width() > 207 && $(this).height() > 207){
 if($(this).height() >= $(this).width()){
 $(this).height("207px");
 } else{
 $(this).width("207px");
 }
 }
 else if($(this).width() > 207 && $(this).height() < 207){
 $(this).width("270px");
 }
 else if($(this).width() < 207 && $(this).height() > 207){
 $(this).height("270px");
 }
 });

});

var wwwGidsMargin = 25;
wwwGidsInit = function() {
  // div => 'organisatiegidsPopup'
  $('DIV.organisatiegidsPopup').each(function() {
      $(this).hide();
      $(this).hover(function(e) {
          $(this).stop().show().css({ opacity: "" });
        }, function() {
          $(this).stop().css({ opacity: 0 }).hide();
        });
    }
  );

  // a => 'organisatiegids'
  $('a.organisatiegids').each(function() {
      var curHref = this.href.substring(this.href.indexOf('#'));
      $(this).css('cursor', 'help');
      $(this).hover(function(e) {
        $(this).stop();
        $(curHref).css({
          position: 'absolute',
          top: this.offsetTop + wwwGidsMargin,
          left: this.offsetLeft + wwwGidsMargin
        });
        $(curHref).show().css({ opacity: "" });
        // Rss knop fix
        $("a.rss").css("zIndex", -99);
      }, function() {
        $(this).stop();
        $(curHref).animate({ "opacity": 0 }, 'slow', function() {
          $(this).hide();
          // Rss knop fix
          $("a.rss").css("zIndex", 0);
        });
      });
    }
  );
};

