         $(document).ready(function ()
             {
                 $( "#theme_button").click( function()
                     {
                         theme_set( theme_toggle( theme_get()));
                 });                   

                 
                 function theme_get()
                 {
                     return( $( "html").attr( "data-bs-theme"));
                 }

                 
                 function theme_set( theme)
                 {
                     if( theme == "light")
                     {
                         $( "#bg_image_div"   ).removeClass(  "colors-invert");                  
                         $( "#theme_icon_sun" ).removeClass( "d-none");
                         $( "#theme_icon_moon").addClass(    "d-none");                  
                     }
                     else
                     {
                         $( "#bg_image_div"   ).addClass(    "colors-invert");                  
                         $( "#theme_icon_sun" ).addClass(    "d-none");
                         $( "#theme_icon_moon").removeClass( "d-none");                  
                     }

                     $( "html").attr( "data-bs-theme", theme);
                     localStorage.setItem( "theme", theme);
                 }

                 
                 function theme_toggle( theme)
                 {
                     return( theme == "light" ? "dark" : "light");
                 }

                 
                 function theme_init()
                 {
                     if( $( "html").attr( "data-bs-theme") == "auto")
                     {
                         theme = localStorage.getItem( "theme");

                         if( ( theme == null) || ( theme != "dark"))
                         {
                             theme = "light"
                         }
                     }
                     else
                     {
                         theme = $( "html").attr( "data-bs-theme");
                     }

                     theme_set( theme);
                 }

                 
                 theme_init();
                 
                 //          alert("data-bs-theme: " + $("html").attr("data-bs-theme"));
         });
