$(document).ready(function() {
    
    $("img[src$='png']").each(function () {
        $(this).addClass('png');
    });

    $('.content_logo_border').each(function () {
        $(this).mouseenter(function () {

            var style = $(this).prev().children().attr('style');
            if (style)
            {
                var matches = style.match(/src="(.*?)"/);

                if (matches)
                {
                    $('.zoom_content_logo_image > img:first').attr('src', matches[1]);
                    $('.zoom_content_logo_image > img:first').addClass('png');
                }
            }
        else
        {
            $('.zoom_content_logo_image > img:first').attr('src', $(this).prev().children().attr('src'));
        }

            var height = $(this).prev().children().attr('height');
            var width = $(this).prev().children().attr('width');

            if (width > height)
            {
                height = height/width * 191;
                width = 191;
            }
            else
            {
                width = width/height * 196;
                height = 196;
            }

            $('.zoom_content_logo_image > img:first').attr('width', width);
            $('.zoom_content_logo_image > img:first').attr('height', height);

            $('#zoom').fadeIn(300);
        });

        $(this).mousemove(function (e) {
            $('#zoom').css("top", (e.pageY  + 20) + "px");
            $('#zoom').css("left", (e.pageX + 20) + "px");
        });

        $(this).mouseout(function () {
            $('#zoom').fadeOut(300);
        });
    });

    $('.details_content').each(function () {
        var detailsContent = $(this);
        
        $(this).css('display', 'none');
        $(this).prev().css('cursor', 'pointer');
        $(this).prev().addClass('details_hover');
        $(this).prev().click(function () {
            $(this).next().toggleFade({
                speedIn: 300,
                speedOut: 300,
                before: function () {
                    if (this.isHidden)
                    {
                        $(detailsContent).prev().addClass('details_active');
                    }
                    else
                    {
                        $(detailsContent).prev().removeClass('details_active');
                    }
                }
            });

        });
    });

    if ($('.ccmsBlockType4').size() > 1)
    {
        $('.ccmsBlockType4:eq(0) > .details_content').each(function () {
            $(this).css('display', 'block');
            $(this).prev().addClass('details_active');
        });
    }
    
    slideshowInit({startString: startString, stopString: stopString, boxes: boxes});
});
