var BgHtml = new function()
{
   this.Html = [];

   this.Store = function(ref, html)
      {
         this.Html[this.ConvertRefToKey(ref)] = html;
      };

   this.Get = function(ref)
      {
         return this.Html[this.ConvertRefToKey(ref)];      
      };

   this.ConvertRefToKey = function(ref)
      {
         return ref.replace(/[^\w]/g, '')
      },

   this.Store.bind(this);
   this.Get.bind(this);
};

var BgAjax = 
{
   StorePassageHtml: function (ref)
      {
         $.ajax({
               url: '/bible/kjv.php?ref=' + ref,
               success: function(data)
                  {
                     BgHtml.Store(ref, data);
                  }
            });
      },
   GetPassageHtml: function(ref)
      {
         return BgHtml.Get(ref);
      }
};


