﻿jQuery(document).ready(function ()
{
    // Makes .main_content wider when there's no submenu
    var boolLeftMenu = jQuery('.left_menu').length > 0;
    if (!boolLeftMenu)
    {
        jQuery('.main_content').addClass("main_content_wide");
    }

    // Listen for the return key on searchbox, and make it sumit
    jQuery('.search_box').keypress(function (event)
    {
        if (event.which == 13)
        {
            event.preventDefault();
            jQuery('.search_button').click();
        }
    });
});


//Document load won't be called untill all elements are fully loaded.
// This is important for calculations with image dimensions.
jQuery(window).load(function ()
{
    CenterImages();
});

//Center theme block Image and Text
function CenterImages()
{
    //Get Objects
    var commercial_block = jQuery(".commercial_block");
    var scientific_block = jQuery(".scientific_block");
    var technology_block = jQuery(".technology_block");
    var commercialImage = jQuery(".commercial_block .theme_block_image");
    var scientificImage = jQuery(".scientific_block .theme_block_image");
    var technologyImage = jQuery(".technology_block .theme_block_image");

    //Center images
    commercialImage.css("margin-top", (commercial_block.height() - commercialImage.height()) / 2);
    scientificImage.css("margin-top", (scientific_block.height() - scientificImage.height()) / 2);
    technologyImage.css("margin-top", (technology_block.height() - technologyImage.height()) / 2);
}
