function RoundCorners(CSSSelector, Color){
    if(!Color){
        Color = "#ffffff";
    }
    jQuery.each(
        jQuery(CSSSelector),
        function(){
            var Width = jQuery(this).width(), Height = jQuery(this).height();
            jQuery(this)
                .css("position", "relative")
                .html(
                //TL
                    '<div class="Rounded50" style="left: 0px; top: 1px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: 0px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: 1px; top: 0px; background-color: ' + Color + '" />' +
                //TR
                    '<div class="Rounded50" style="left: ' + (Width - 2) + 'px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: ' + (Width - 1) + 'px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: ' + (Width - 1) + 'px; top: 1px; background-color: ' + Color + '" />' +
                //BR
                    '<div class="Rounded50" style="left: ' + (Width - 1) + 'px; top: ' + (Height - 2) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: ' + (Width - 1) + 'px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: ' + (Width - 2) + 'px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                //BL
                    '<div class="Rounded50" style="left: 1px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: 0px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: 0px; top: ' + (Height - 2) + 'px; background-color: ' + Color + '" />'
                );
        }
    );
}



jQuery("document").ready(
    function(){
        RoundCorners("div.Community div.ImageContainer");
        
        RoundCorners("div#CommunityPicture");
        
        RoundCorners("div.Thumb", "#b2bd92");
        
        
        //ATTACH THE COMMUNITY THUMB CLICK EVENT
        jQuery("div.Thumb").click(
            function(){
                jQuery("div.ThumbShadow").removeClass("ThumbActive");
                jQuery("div.Thumb").removeClass("ThumbCorners");
                RoundCorners("div.Thumb");
                jQuery(this).parents("div.ThumbShadow").addClass("ThumbActive");
                jQuery(this).addClass("ThumbCorners");
                RoundCorners("div.ThumbCorners", "#b2bd92");
                jQuery("div#CommunityPicture").css("backgroundImage", "url(" + jQuery(this).attr("tag") + ")");
            }
        );
    }
);
