﻿MediaGridTabContainer = function(rootElementID) {
  this.ctx = $('#'+rootElementID)[0];
  this.wireUpSpinner();
};

MediaGridTabContainer.prototype = {
  ctx: null,  // jQuery search context
  wireUpSpinner: function() {
    $('#AjaxSpinner').hide(); // initial state    
    if(!Gallery) {      
      setTimeout(this.wireUpSpinner, 150); // child objects not born yet...
    }
    else {
      Gallery.onAjaxStart = function() { $('#AjaxSpinner').show(); }
      Gallery.onAjaxEnd = function() { $('#AjaxSpinner').hide(); }    
    }
  },
  
  incrementViewCount: function(id) {
    var span = $('#NumberOfViews_'+id, this.ctx);
    var x = parseInt(span.text().replace(/[^\d]/g,''));
    span.text('Views: ' + (++x));
  }
};