﻿
function GetInsusDataListValue(CtrlName){
  InsusWindow("../PopUp/InsusDataList.aspx",CtrlName);
}   

function InsusWindow(sPath,CtrlName)
{
    ChildWindow = window.open(sPath +"?rtn=" + CtrlName, "PopUpList", screenParam(350,300));
}

//检查窗口是否关闭
function CheckWindow(){   
    ChildWindow.close(); 
}

//打开新窗口
function GetNewWindow(strNewWindowPath, strParameterValue, iWidth, iHeight){
    window.open(strNewWindowPath + "?ID=" + strParameterValue , "PopUpWindow", screenParam(iWidth,iHeight));
}

//关闭窗口方法
function Close(){
    window.close ();
}

function CloseWindow()
{ 
    window.opener=null;
    window.open("","_self");
    window.close(); 
}

//新窗口参数
function screenParam(iWidth,iHeight)
{
    return "width=" + iWidth + ",height=" + iHeight +",top=" + (screen.height-iHeight)/2 + ",left=" + (screen.width-iWidth)/2 + ",menubar=no,toolbars=no,location=no,directories=no,scrollbars=no,status=no,resizable=no";
}

//取得日期
function GetDate(CtrlName,PrefixPath){
    ChildWindow = window.open(PrefixPath + "Commonality/PopUpCalendar.aspx?rtn=" + CtrlName, "PopUpCalendar", screenParam(180,205));
} 	

function OpenFullSizeWindow(theURL,winName,features) {
  var aNewWin, sBaseCmd;
  // 弹出窗口外观参数
  sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,";
  // 调用是否来自 checkImg 
  if (features == null || features == ""){
    // 创建图像对象
    imgObj = new Image();
    // 设置图像源
    imgObj.src = theURL;
    // 开始获取图像大小
    checkImg(theURL, winName)
  }
  else{
    // 打开窗口
    aNewWin = window.open(theURL,winName, sBaseCmd + features);
    // 聚焦窗口
    aNewWin.focus();
  }
}

var imgObj;
function checkImg(theURL,winName){
  // 对象是否已创建
  if (typeof(imgObj) == "object"){
    // 是否已取得了图像的高度和宽度
    if ((imgObj.width != 0) && (imgObj.height != 0))
      // 根据取得的图像高度和宽度设置弹出窗口的高度与宽度，并打开该窗口
      // 其中的增量 20 和 30 是设置的窗口边框与图片间的间隔量
      OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30));
    else
      // 因为通过 Image 对象动态装载图片，不可能立即得到图片的宽度和高度，所以每隔100毫秒重复调用检查
      setTimeout("checkImg('" + theURL + "','" + winName + "')", 100)
  }
}