var initBackGround = function (imageid) {
   //note: may need to handle larger images
   var i = $("#bimage");
   var width_height_prop = i.width() / i.height(); //the image's w/h proportion
    var counter = 0;
   function adjust () {
       var bwidth = window.innerWidth;
       var bheight = window.innerHeight;

//       console.log(i.style.width + " : " + i.style.height);
//       console.log(.width() + " : " + i.style.height);
       if (bwidth  > width_height_prop * bheight) {
                     //browser viewport proportionally wider - adjust for the width
                     i.css({'width' : bwidth + "px", 'height' : bwidth / width_height_prop + "px"});
                 } else {
                       i.css({'height'  : bheight + "px", 'width'  : bheight * width_height_prop + "px"});
                     }
       i.show();
   };

   return {
       adjust : adjust
   }
};

$(document).ready(function() {
//    var backimage = $("#bimage");
    //adjust  the image according to the screen settings
    var bg = initBackGround('bimage');
        bg.adjust();
//     backimage.show();
          $("#content").fadeIn(3000);
    $(window).resize(function() {
        bg.adjust();
    });
    }
)
