$(document).ready(function () {
    $("ul.menu > li").mouseover(function () {
        var submenu = $(this).find("ul.submenu");
        if (submenu.length != 0) {
            if (submenu.is(":visible")) {
                return false;
            }
            else {
                $(this).addClass("subhover");
                submenu.slideDown(400).show();
            }
        }
        return false;
    }).mouseleave(function () {
        $(this).find("ul.submenu").slideUp('fast');
        $(this).removeClass("subhover");
        return false;
    });


});

jQuery(window).load(function () {
    //For 2 colums  template calculate width of box to fit place left from image
    var parent = $(".two-column-content");
    if (parent.length != 0) {
        var imageBox = $(".two-column-content .image-box");
        if (imageBox.length != 0) {
            var image = imageBox.find("img");
            if (image.length != 0) {
                imageBox.css("width", image.width());
                var freeTextBox = $('.free-text-area-box');
                var diff = freeTextBox.outerWidth(true) - freeTextBox.width();
                freeTextBox.css("width", parent.width() - imageBox.outerWidth(true) - diff);
            }

            if ($('.image-slideshow-left img').length <= 1) {
                $('.image-slideshow-left img').css('display', 'block');
            }
            else {
                $('.image-slideshow-left').cycle({
                    delay: 1500,
                    timeout: 3000
                });
            }

            if ($('.image-slideshow-right img').length <= 1) {
                $('.image-slideshow-right img').css('display', 'block');
            }
            else {
                $('.image-slideshow-right').cycle({
                    timeout: 3000
                });
            }
        }
    }
});
