﻿$(document).ready(function () {

    var $els = $(".productSelection_Text").equalizeCols();

    function imageresize() {

        var contentwidth = $('#content').width();
        var contentheight = $('#content').height();
        if (contentwidth > contentheight) {

            if (contentwidth <= 1000) {
                contentwidth = 1000;
            }
            else if (contentwidth > 1000) {
                var decimalNumber = (contentwidth - 1000) / 100;
                var contentwidth = 1000 + Math.ceil(decimalNumber) * 100;
                if (contentwidth >= 2100) {
                    contentwidth = 2100
                }

            }

            var sourceUrl = "Media/Interface/ProductSelection/Background/Product_Background_" + contentwidth + ".jpg"
        }
        else {
            if (contentheight <= 600) {
                contentheight = 600;
            }
            else if (contentheight > 600) {
                var decimalNumber = (contentheight - 1000) / 100;
                var contentheight = 1000 + Math.ceil(decimalNumber) * 100;
                if (contentheight >= 1700) {
                    contentheight = 1700
                }

            }
            contentheight = contentheight + 300;
            var sourceUrl = "Media/Interface/ProductSelection/Background/Product_Background_Vert_" + contentheight + ".jpg"
        }
        $('#content').css('backgroundImage', 'url(' + sourceUrl + ')');

    }

    imageresize(); //Triggers when document first loads    

    $(window).bind("resize", function () {//Adjusts image when browser resized
        imageresize();
    });

});

