﻿function resizeButtons(buttonClassName) {
    var temp = 0;
    $(document).ready(function() {
        $(buttonClassName + '[resize!=false]').each(function() {
            if (this.scrollWidth > temp) {
                temp = this.scrollWidth;
            }
            if (this.scrollWidth == undefined) {
                var mydiv = document.getElementById(buttonClassName);
                var curr_width = parseInt(mydiv.style.width); // removes the "px" at the end
                if (curr_width > temp) {
                    temp = curr_width;
                }
            }
        });

        $(buttonClassName + '[resize!=false]').each(function() {
            this.style.width = temp + 'px';
        });
        
        $(buttonClassName + '[resize!=true]').each(function() {
            temp = this.scrollWidth;
            if (this.scrollWidth == undefined) {
                var mydiv = document.getElementById(buttonClassName);
                var curr_width = parseInt(mydiv.style.width); // removes the "px" at the end
                if (curr_width > temp) {
                    temp = curr_width;
                }
            }
            this.style.width = temp + 'px';
        });
    });
}

function initResizeButtons() {
    resizeButtons(".btnWhiteDiv");
    resizeButtons(".btnOrangeDiv");
    resizeButtons(".btnOrangeLineDiv");
}

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(initResizeButtons);
