﻿$(document).ready(function() {

    $(".block img").each(function() {

        if ($(this).parent().hasClass('block')) {
            $(this).load(function() {
                if ($(this).height() > 140) {
                    var height = 155;
                    var hasLink = $(this).parent().parent().has('.link a');
                    var hasHeader = $(this).parent().has('h2');

                    if (hasLink && hasHeader) height = 138;
                    if (!hasLink && !hasHeader) height = 185;

                    $(this).css('height', height + 'px');
                }
            });
        }
    });

    var slideshowHeight = 0;
    $(".slideshow img").each(function() {
        $(this).load(function() {
            if ($(this).height() > slideshowHeight) {
                slideshowHeight = $(this).height();
                $(".slideshow").css("height", slideshowHeight + "px");
            }
        });
    });

});
