var w_mainw
var w_submainw
var w_choosew
var w_showw
var w_previeww
var w_image
var w_tool
var w_remind      //提醒窗口
var w_accessoryw   //附件窗口

var screenwidth
var screenheight

screenwidth = screen.width     //屏幕宽度
screenheight = screen.height   //屏幕高度

//装载页面进度过程，2003-8-14 by C.N.
var loadingprocess=""
  loadingprocess+="<table height=80% width=100%>"
  loadingprocess+="<tr><td align=center valign=bottom height=50%><img border=0 align=absmiddle src='../images/log.gif' WIDTH=16 HEIGHT=16>&nbsp;<font color='#000000'><b>正在装载页面请稍等......</b></font></td></tr>"
  loadingprocess+="<tr><td id=ProcessTd align=center valign=top height=50%>&nbsp;</td></tr></table>"


function wxf_openmainwin(sUrl,iWidth,iHeight,sResize)
{
  //关闭窗口
  if (w_mainw)
  {
	 try{if(w_mainw.w_submainw)w_mainw.w_submainw.close()}catch(e){}
     w_mainw.close()
  }

  //如果可调整大小
  if(sResize=="yes")
  {
    iWidth = screenwidth/800*iWidth
    iHeight = screenheight/600*iHeight
    l = (screenwidth - iWidth)/2-5
    t = (screenheight - iHeight)/2-20
  }
  else
  {
    l = (screen.width - iWidth)/2-5
    t = (screen.height- iHeight)/2-20
    sResize = "no"
  }

  w_mainw = window.open("","w_mainw","resizable=" + sResize + ",width="+iWidth+",height="+iHeight+",left="+l+",top="+t)
  w_mainw.document.write(loadingprocess)
  
  if (sUrl!="")
  {
	  w_mainw.document.location.href = sUrl
  }
}

function wxf_opensubwin(sUrl,iWidth,iHeight,sResize)
{
  //关闭窗口
  if (w_submainw)
  {
     w_submainw.close()
  }
  
  //如果可调整大小
  if(sResize=="yes")
  {
    iWidth = screenwidth/800*iWidth
    iHeight = screenheight/600*iHeight
    l = (screenwidth - iWidth)/2-5
    t = (screenheight - iHeight)/2-20
  }
  else
  {
    l = (screen.width - iWidth)/2-5
    t = (screen.height- iHeight)/2-20
    sResize = "no"
  }

  w_submainw = window.open("","w_submainw","resizable=" + sResize + ",width="+iWidth+",height="+iHeight+",left="+l+",top="+t)
  w_submainw.document.write(loadingprocess)
  
  if (sUrl!="")
  {
	  w_submainw.document.location.href = sUrl
  }
}

function wxf_openchoosewin(sUrl,iWidth,iHeight,sResize)
{
  //关闭窗口
  if (w_choosew)
  {
     w_choosew.close()
  }

  //如果可调整大小
  if(sResize=="yes")
  {
    iWidth = screenwidth/800*iWidth
    iHeight = screenheight/600*iHeight
    l = (screenwidth - iWidth)/2-5
    t = (screenheight - iHeight)/2-20
  }
  else
  {
    l = (screen.width - iWidth)/2-5
    t = (screen.height- iHeight)/2-20
    sResize = "no"
  }

  w_choosew = window.open(sUrl,"w_choosew","resizable=" + sResize + ",width="+iWidth+",height="+iHeight+",left="+l+",top="+t)
}

function wxf_openshowwin(sUrl,iWidth,iHeight,sResize)
{
  //关闭窗口
  if (w_showw)
  {
     w_showw.close()
  }

  //如果可调整大小
  if(sResize=="yes")
  {
    iWidth = screenwidth/800*iWidth
    iHeight = screenheight/600*iHeight
    l = (screenwidth - iWidth)/2-5
    t = (screenheight - iHeight)/2-20
  }
  else
  {
    l = (screen.width - iWidth)/2-5
    t = (screen.height- iHeight)/2-20
    sResize = "no"
  }

  w_showw = window.open(sUrl,"w_showw","resizable=" + sResize + ",width="+iWidth+",height="+iHeight+",left="+l+",top="+t)
}

function wxf_opentoolwin(sUrl,iWidth,iHeight)
{
  //关闭窗口
  if (w_tool)
  {
     w_tool.close()
  }
  l = (screen.width - iWidth)/2-5
  t = (screen.height- iHeight)/2-20
  w_tool=window.open(sUrl,"w_tool","resizable=yes,width="+iWidth+",height="+iHeight+",left="+l+",top="+t+",scrollbars=yes,resizable=yes")
}

function wxf_openpreviewwin(sUrl,iWidth,iHeight)
{
  //关闭窗口
  if (w_previeww)
  {
     w_previeww.close()
  }
  l = (screen.width - iWidth)/2-5
  t = (screen.height- iHeight)/2-20
 
  w_previeww=window.open("","w_previeww","resizable=yes,width="+iWidth+",height="+iHeight+",left="+l+",top="+t+",scrollbars=yes,resizable=yes")
  w_previeww.document.write(loadingprocess)
  
  if (sUrl!="")
  {
	  w_previeww.document.location.href = sUrl
  }
}

function wxf_openimagewin(sUrl,iWidth,iHeight)
{
  //关闭窗口
  if (w_image)
  {
     w_image.close()
  }
  l = (screen.width - iWidth)/2-5
  t = (screen.height- iHeight)/2-20
  w_image=window.open(sUrl,"w_image","resizable=yes,width="+iWidth+",height="+iHeight+",left="+l+",top="+t+",scrollbars=yes,resizable=yes")
}

function wxf_openremindwin(sUrl,iWidth,iHeight)
{
  //关闭窗口
  if (w_remind)
  {
     w_remind.close()
  }
  l = (screenwidth  - iWidth)/2-5
  t = (screenheight - iHeight)/2-20
  w_remind=window.open(sUrl,"w_remind","resizable=yes,width="+iWidth+",height="+iHeight+",left="+l+",top="+t+",scrollbars=no,resizable=no")
}

//显示附件的窗口函数,默认带有滚动条
function wxf_openaccessorywin(sUrl,iWidth,iHeight,sResize)
{
  //关闭窗口
  if (w_accessoryw)
  {
     w_accessoryw.close()
  }
  //如果可调整大小
  if(sResize=="yes")
  {
    iWidth = screenwidth/800*iWidth
    iHeight = screenheight/600*iHeight
    l = (screenwidth - iWidth)/2-5
    t = (screenheight - iHeight)/2-20
  }
  else
  {
    l = (screen.width - iWidth)/2-5
    t = (screen.height- iHeight)/2-20
    sResize = "no"
  }

  w_accessoryw = window.open(sUrl,"w_accessoryw","scrollbars=yes,resizable=" + sResize + ",width="+iWidth+",height="+iHeight+",left="+l+",top="+t)
}

function wxf_openmodalwin(sUrl,iWidth,iHeight)
{
  return window.showModalDialog(sUrl,"","dialogheight:" + iHeight + "px;dialogwidth:" + iWidth + "px;status:no;scroll:no")
}

//隐藏查询条件
function f_condition(th)
{
  if(document.all.condition.style.display=='none')
  {
    try
    {
      //document.all.condition.style.display="block"
      //th.parentElement.parentElement.style.visibility="visible"
    }
    catch(e){}
    document.all.condition.style.display="block"
    th.src = "../images/up.gif"
    th.title="折叠查询条件"
  }
  else
  {
    document.all.condition.style.display="none"
    try
    {
      //th.parentElement.parentElement.style.visibility="hidden"
      //th.parentElement.style.visibility="visible"
    }
    catch(e){}
    th.src = "../images/down.gif"
    th.title="展开查询条件"
  }
}

//去除右键
//document.oncontextmenu=new Function("event.returnValue=false;")

//将表单输入中的回车键置换为Tab键
function wxf_keydown()
{ 
  if (event.keyCode==13 && (event.srcElement.type=="text" ||event.srcElement.type=="password"|| event.srcElement.type=="select-one" || event.srcElement.type=="checkbox") )
  {
   event.keyCode=9
  }
  try
  {
    if(event.keyCode==38)
    {
      if(iPosition==1)
      {
       f_choose(document.all.jerker[document.all.jerker.length-1])
      }
      else
      {
       f_choose(document.all.jerker[iPosition-1])
      }
    }
    if(event.keyCode==40)
    {
      if(iPosition==document.all.jerker.length-1)
      {
        f_choose(document.all.jerker[1])
      }
      else
      {
        f_choose(document.all.jerker[iPosition+1])
      }
    }
  }
  catch(e){}
  
  //屏蔽Ctrl+N键
  //if(event.ctrlKey ==true || event.keyCode ==93 || event.shiftKey ==true)
  //{
  //  return false;
  //}
}
document.onkeydown=wxf_keydown

//获取浏览器的版本号(主版本号.子版本号)
//0~99为IE   100~199为Netscape
function wxf_browserversion()
{
  var w,m,s

  if(navigator.appVersion.indexOf("MSIE")!=-1)//判断是否为IE
  {
    w=0
    m=parseInt(navigator.appVersion.charAt(parseInt(navigator.appVersion.indexOf("MSIE"))+5))
    s=parseInt(navigator.appVersion.charAt(parseInt(navigator.appVersion.indexOf("MSIE"))+7))
  }
  else
  {
    w=1
    m=parseInt(navigator.appVersion.charAt(parseInt(navigator.appVersion.indexOf("MSIE"))+9))
    s=parseInt(navigator.appVersion.charAt(parseInt(navigator.appVersion.indexOf("MSIE"))+11))
  }
  return w*100+m*10+s
}

function wxf_baseinfo(sGedNo,sMduNo,sMduName,sFunNo,sFunName,sFldName,sType)
{
  wxf_openchoosewin("../lib/WxBaseInfo.aspx?GedNo="+sGedNo+"&MduNo="+sMduNo+"&MduName="+sMduName+"&FunNo="+sFunNo+"&FunName="+sFunName+"&FldName="+sFldName+"&Type="+sType,550,400)
  return false
}

//上传图片
//2002.7.10  YYG
function wxf_uploadimage(imagepath,imagepathname)
{
  wxf_openimagewin("../lib/WxImageUp.aspx?path="+imagepath+"&pathname="+imagepathname,400,400)
}

function wxf_chooseimage(imagepath,imagepathname,obj)
{
  var sImgFile
  sImgFile = window.showModalDialog("../lib/WxImageUp.aspx?choose=1&path=" + imagepath +"&pathname="+imagepathname,"","dialogheight:400px;dialogwidth:400px;status:no;scroll:no")
  if(typeof(sImgFile)=="undefined")
  {
    return false
  }
  obj.value = sImgFile
}

//显示图片
//2002.7.26  YYG
function wxf_showimage(imagename)
{
   wxf_openimagewin('../lib/WxShowImage.aspx',400,400)
}

//打印报表
function wxf_print()
{
  wxf_openchoosewin("",280, 150)
  try
  {
    Form2.PrnSql.value = document.frames('myframe').document.all.QuerySql.value
    Form2.OrderSql.value = document.frames('myframe').document.all.OrderSql.value
  }
  catch(e){}
  Form2.action       = "../lib/WxPrint.aspx"
  Form2.target       = "w_choosew"
  Form2.submit()
}

//单据定义
//单据定义
function wxf_billdefine(sBilNo,sBstClsNo,sBstClsName)
{
  if(typeof(sBstClsNo)=="undefined")
  {
    sBstClsNo=""
  }
  if(typeof(sBstClsName)=="undefined")
  {
    sBstClsName=""
  }
  wxf_openpreviewwin('../Common/WxBillDefine.aspx?BilNo='+sBilNo+'&BstClsNo='+sBstClsNo+'&BstClsName='+sBstClsName,740,520)
}

var bModified = false         //为了支持修改退出检测，记录当前录入界面是否修改
var bModifiedChecked = true   //标记当前页面是否需要进行退出检查

function wxf_alertsuccess(sAlert)
{
   try
   {
     parent.bModified = false
   }
   catch(e){}
   alert(sAlert)
}

function wxf_alertfail(sAlert)
{
   try
   {
     parent.bModified = false
   }
   catch(e){}
   alert(sAlert)
}
