﻿$(document).ready(function() {
  $(".MediumThumb").click(function() {
    showmore = $(this).attr("showmore");
    if(showmore)
    {
      navTo(showmore);
      return;
    }
  
    $(".LargeThumb").hide();
    $(".FullHtml").hide();
    $(".SmallThumb").hide();

    $(".LargeThumb[ID='" + this.id + "']").show();
    $(".LargeThumb[ID='" + this.id + "']").find(".LargeThumbView").hide();
    $(".LargeThumb[ID='" + this.id + "']").find(".LargeThumbView:first").show();

    $(".FullHtml[ID='" + this.id + "']").show();
    $(".SmallThumb[ID='" + this.id + "']").show();
    $(".MediumThumb").removeClass("selected");
    $(this).addClass("selected");
  });
  $(".MediumThumb:first").addClass("selected");
  $(".SmallThumbView").click(function() {
    $(".LargeThumbView").hide();
    $(".LargeThumbView[ID='LT" + this.id + "']").show();

  });

//  if ($(".LoadImage:first").length > 0)
//    setTimeout(LoadImages, 1000);

});
var loadingCount = 0;

function LoadImages() {

  $(".LoadImage").each(function(index, el) {
    el = $(el);
    if (loadingCount < 10) {
      var ImgSrc = el.attr('ImgSrc');

      el.removeAttr('ImgSrc');
      el.removeClass('LoadImage');
      loadingCount++;
      el.attr('src', ImgSrc).load(function() {
        loadingCount--;
        if (loadingCount < 10)
          setTimeout(LoadImages,300);
      });

      if (loadingCount >= 10)
        return false;

    }
  });

}