﻿(function ($) {
    bgphoto = function () {
        var m_PhotoIndex = 0;
        $('.content_big_photo_left').corner("20px left");
        $('.content_big_photo_right').corner("20px right");
        $('.breadcrumbs').css("margin-top", "0px");
        //next 2 functions not dry
        $('.a_item_photo_colorbox').click(function (event) {
            event.preventDefault();
            $('.mobile_large_image').attr("src", $(this).attr('href'));
            $('.big_photo').attr("src", $(this).attr('href'));

            m_PhotoIndex = $(this).parent().index();
            $('.a_item_photo_colorbox').colorbox({ transition: "none", width: "75%", height: "75%" });
        });

        $('.a_item_photo').click(function (event) {
            event.preventDefault();
            $('.mobile_large_image').attr("src", $(this).attr('href'));
            $('.big_photo').attr("src", $(this).attr('href'));

            m_PhotoIndex = $(this).parent().index();
        });

        $('.big_photo_next').click(function () {
            m_PhotoIndex++;
            if ($('.item_photo_wide_lazy').size() == m_PhotoIndex)
                m_PhotoIndex = 0;

            $('.big_photo').attr("src", $($('.item_photo_wide_lazy').get(m_PhotoIndex)).attr("src").replace("/low/", "/med/"));
        });

        $('.big_photo_previous').click(function () {
            m_PhotoIndex--;
            if (m_PhotoIndex == -1)
                m_PhotoIndex = $('.item_photo_wide_lazy').size() - 1;
            $('.big_photo').attr("src", $($('.item_photo_wide_lazy').get(m_PhotoIndex)).attr("src").replace("/low/", "/med/"));
        });
    };
})(jQuery);

