// JavaScript Document

gLoadSpinnerUrl = 'images/progress.gif';


gFailImage = 'images/progress.gif';

function LoadThisImage(loader, pCallback){
   image_src = loader.attr('src');
   img = $(new Image());
   img.hide();

   img.load(function() {
      cb_js = loader.get(0).getAttribute('onload');
      onload_cb = function(){
	 eval(cb_js);
      }

      loader.html(this);
      loader.removeClass('loadable-image');
      loader.removeAttr('src');
      loader.removeAttr('onload');
      $(this).show();
      if (onload_cb){
	 onload_cb($(this));
      }
      if (pCallback){
	 cb = pCallback;
	 cb($(this));
      }
   })
   .error(function() { $(this).attr('src', gFailImage).show(); })
   .attr('src', image_src)
   .fadeIn('normal');

   //alert(img.attr('src') + ' loading/loaded');
}

function LoadImage(pSelector, pCallback){
   var loader = $(pSelector);
   loader.html('<img src="' + gLoadSpinnerUrl + '"/>');

   LoadThisImage(loader, pCallback);
}

function LoadAllImages(){
   $('.loadable-image').each(function(){
      var loader = $(this);
      loader.html('<img style=\"border:0px; padding-left:60px; padding-top:39px;\" src="' + gLoadSpinnerUrl + '"/>');

      //Load images asynchronously
      setTimeout(function() { LoadThisImage(loader); }, 10);
      //LoadThisImage(loader);
   });
}

function LoadAllImagesTwo(){
   $('.loadable-image').each(function(){
      var loader = $(this);
      loader.html('<img style=\"border:0px; padding-left:56px; padding-top:35px;\" src="' + gLoadSpinnerUrl + '"/>');

      //Load images asynchronously
      setTimeout(function() { LoadThisImage(loader); }, 10);
      //LoadThisImage(loader);
   });
}
function LoadAllImagesThree(){
	//alert('here');
   $('.loadable-image').each(function(){
      var loader = $(this);
      loader.html('<img style=\"border:0px; padding-left:390px; padding-top:188px;\" src="' + gLoadSpinnerUrl + '"/>');


      //Load images asynchronously
      setTimeout(function() { LoadThisImage(loader); }, 10);
      //LoadThisImage(loader);
   });
}
