﻿var testpage = "default.aspx";
function SendAjax(url, target) {
    $("#" + target).html("<img src='/image/Loading.gif'/>");
    
    $.post(url, null, function (responsexx) {
        $("#" + target).html(responsexx);
        $.cleanup;
        CollectGarbage();
    });
}
//延时涵数
function cnWait (second){   
      var startTime,endTimes,s;    
      var d=new Date();    
      startTime=d.getTime();    
      while(true){   
      d=new Date();   
      endTime=d.getTime();   
      s = (endTime-startTime)/1000;   
      if (s >= second)   
          break;   
      }   
}  
 
//扩展jquery插件,增加面版与图片集按指定宽度自动缩放
jQuery.fn.extend({
    Auto_Panel_Add: function (url, target) {
        SendAjax(url, target);
    },
    Auto_Check: function (o) {//设置所有check为o-true,false,例：$("#chk input[type=checkbox]").Auto_Check(true);
        return this.each(function () { this.checked = o; });
    },
    Auto_Images_checkSize: function chimg(target, ImgSizeWidth, lengthShellJS) {
        //效果还可以 (^_^)
        var v = $("#" + target).html();
        var lj = 7;
        if (lengthShellJS != null) { lj = lengthShellJS; }
       // cnWait(1); //延时一秒
        if (v.length > lengthShellJS) {//7为target默认的内容长度 load...
            $("#" + target + " img").each(function (i) {
                if ($(this).width() > ImgSizeWidth) {
                    var h = ImgSizeWidth / $(this).width();
                    h = $(this).height() * h; //
                    $(this).css("max-width", ImgSizeWidth + "px").width(ImgSizeWidth).height(h);
                }
                window.clearInterval(iid);
                iid = 0;
            });
        }
        else {

            var iid = window.setInterval("chimg('" + target + "','" + ImgSizeWidth + "')", 3000);
        }
    }
});
