(function($) {
	
 // $.fn.pna = function(q,w,e) {
 //   var element = $(this);
 //   new jQuery.pna(element, q, w, e);
 //   return this;
 //	};

 $.countJSON = 0;
 
  $.getJSON.progress = function() {
    $.countJSON++;
    if(!$("#loading").html())
      $("body").prepend('<div id="loading" style="display: none; opacity: 0.5; width: 100%; height: 100%; background-color: gray; position: absolute; z-index: 1000; top:0px;left:0px;"><div   style="z-index: 1000; position: absolute;  top:50%; left:50%;"><img  src="http://gate.ptsonline.ru/i/progress.gif" /></div><div class="ptsProgressClose" style="float:right;margin:10px;">X</div></div> ');
    $("#loading").show();
  
    var callback;
    function callback_wrapper(callback_data) {
      callback(callback_data);
      $.countJSON--;
    }
  
    function check_inter() {
      if($.countJSON == 0) {
        $("#loading").hide(); 
        clearInterval(interval);
      } 
    }
  
    url = arguments[0];
    if(typeof(arguments[1]) != 'function') var data = arguments[1];
    else callback = arguments[1];
    if(arguments[2]) callback = arguments[2];
    $.getJSON(url, data, callback_wrapper);

    var interval = setInterval(check_inter,1000);

  };
  
})(jQuery); 

(function($) {
	
  $.countGET = 0;
 
  $.get.progress = function() {
    $.countGET++;
    if(!$("#loading").html())
      $("body").prepend('<div id="loading" style="display: none; opacity: 0.5; width: 100%; height: 100%; background-color: gray; position: absolute; z-index: 1000; top:0px;left:0px;"><div   style="z-index: 1000; position: absolute;  top:50%; left:50%;"><img  src="http://gate.ptsonline.ru/i/progress.gif" /></div><div class="ptsProgressClose" style="float:right;margin:10px;">X</div></div> ');
    $("#loading").show();
  
    var callback;
    function callback_wrapper1(callback_data) {
      callback(callback_data);
      $.countGET--;
    }
  
    function check_inter1() {
      if($.countGET == 0) {
        $("#loading").hide(); 
        clearInterval(interval1);
      } 
    }
  
    url = arguments[0];
    if(typeof(arguments[1]) != 'function') var data = arguments[1];
    else callback = arguments[1];
    if(arguments[2]) callback = arguments[2];
    $.get(url, data, callback_wrapper1);

    var interval1 = setInterval(check_inter1,1000);

  };
  
})(jQuery); 
