var $j = jQuery.noConflict();

jQuery(document).ready(function() { //Start code ******************************************

    var prefix = window.location.protocol
    if (prefix == "https:") {
        var imageServer = "https://images.golfbreaks.com/customimage.aspx?format="
    }
    else {
        var imageServer = "http://images.golfbreaks.com/customimage.aspx?format="
    };

    var elements = $j(".customBackground");

    $j(elements).each(function() {
        var element = $j(this);
        var classNames = $j(element).attr("class").split(" ");

        var customBackground = "";
        for (j = 0; j < classNames.length; j++) {
            if (classNames[j] == "customBackground" && (j + 1) < classNames.length) {
                customBackground = classNames[j + 1];
                break;
            }
        };

        if (customBackground != "") {
            // Get the height and width of the element
            var width = $j(this).attr("offsetWidth");
            var height = $j(this).attr("offsetHeight");

            // Set the custom background image of the element
            var backgroundImage = imageServer + customBackground + "&width=" + width + "&height=" + height;
            $j(element).css("backgroundImage", "url(" + backgroundImage + ")");
        };

    });
});