//弹出窗口
function pop1(url,x,y,status){
  l=(screen.width/2)-(x/2);
  t=(screen.height/2)-(y/2);
  s="scrollbars="+status+",toolbar=no,location=no,status=no,menubar=no,resizable=yes";
  s+=" width=" + x + ", height=" + y + ", left=" + l + ", top=" + t;
  MRV=window.open(url,"",s);
}
function pop(url) {
      var winWidth = 600;// screen.availWidth - 10;
      var winHeight = 500;//screen.availHeight - 20;
      l=(screen.width/2)-(winWidth/2);
      t=(screen.height/2)-(winHeight/2);
      s="scrollbars=yes,toolbar=no,location=no,status=yes,menubar=no,resizable=no";
      s+=" width="+winWidth+" height="+winHeight + ", left=" + l + ", top=" + t;
      MRV=window.open(url,"",s);
}
//弹出窗口
function pop(url,x,y,status){
  l=(screen.width/2)-(x/2);
  t=(screen.height/2)-(y/2);
  s="scrollbars="+status+",toolbar=no,location=no,status=no,menubar=no,resizable=yes";
  s+=" width=" + x + ", height=" + y + ", left=" + l + ", top=" + t;
  MRV=window.open(url,"",s);
}
//关闭窗口
function shutwin(){
  window.close();
  opener.focus();
  opener.location.reload();
  return;
}
//除去字符串头和尾的空格
String.prototype.Trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

var newid ; 
function OpenWindow(name,url,x,y,w,h,yn)
{
 var query;
  
  tools = 'toobar=no,location=no,directories=no,status=0,scrollbars='+yn+',menubar=0,resizable=no,copyhistory=no,width='+w+',height='+h+',left='+x+',top='+y;
  if(newid)
  {
     if(!newid.closed){
          // newid.focus();
	  //}else{
	  newid.close();   
     }
     newid=window.open(url,name,'toobar=no,'+tools); 
			//newid.moveTo(300,200);
  }else{
            
    //query=window.formz.elements[ftext].value
    newid=window.open(url,name,'toobar=no,'+tools);
  }
}
//弹出新窗在中间位置
function popcenter(url,w,h){
        x=w;
        y=h;
        l=(screen.width/2)-(x/2);
        t=(screen.height/2)-(y/2);
        s="scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no";
        s+=" width=" + x + ", height=" + y + ", left=" + l + ", top=" + t;
        MRV=window.open(url,"",s);
}

//弹出新窗，窗口位置为鼠标点击处。
function openwinevt(evt,w,h,jspfile)
{
   var left  = evt.screenX;
   var top   = evt.screenY;
   var wlen  = parseInt(left)+parseInt(w);
   var hlen  = parseInt(top)+parseInt(h);
   if(wlen > screen.width){ 
       left  = screen.width-w-10;
   }
   if(hlen > screen.height){
       top   = screen.height-h-55;
   }
   OpenWindow("selwin",jspfile,left,top,w,h,"no");
}
//弹出新窗，其窗口位置距屏幕的顶端为0，右边为 10
function openwin1(name,urll,w,h,yn)
{       x=w;
        y=h;
	l=(screen.width/2)-(x/2);
        t=(screen.height/2)-(y/2);
	
	OpenWindow(name,urll,l,t,w,h,yn);
}
//弹出新窗，但附带提交（submit） 的动作。其窗口位置距屏幕的顶端为0，右边为 10
function openwinsub(name,urll,w,h,yn,blankhtmlpath)
{
	x=w;
    y=h;
	l=(screen.width/2)-(x/2);
    t=(screen.height/2)-(y/2);
        
	OpenWindow(name,blankhtmlpath,l,t,w,h,yn);
	subtarget(urll,name);
}

//功能同 openwinsub() 不同之处为：可以自已定义 "blank.htm" 这个页面
function openwinLoading(loadname,name,urll,w,h,yn)
{
	l = screen.width-w-10;
        t = 0;
	OpenWindow(name,loadname,l,t,w,h,yn);
	subtarget(urll,name);
}
//功能同 openwinsub() 不同之处为：可以自已定义 "blank.htm" 这个页面
function openNewwin(name,urll,w,h,yn)
{
	x=w;
    y=h;
	l=(screen.width/2)-(x/2);
    t=(screen.height/2)-(y/2);
        
	OpenWindow1(name,"../include/blank.html",l,t,w,h,yn);
	subtarget(urll,name);
}
function OpenWindow1(name,url,x,y,w,h,yn)
{
 var query;
  
  tools = 'toobar=no,location=no,directories=no,status=0,scrollbars='+yn+',menubar=0,resizable=yes,copyhistory=no,width='+w+',height='+h+',left='+x+',top='+y;
  if(newid)
  {
     if(!newid.closed){
          // newid.focus();
	  //}else{
	  newid.close();   
     }
     newid=window.open(url,name,'toobar=no,'+tools); 
			//newid.moveTo(300,200);
  }else{
            
    //query=window.formz.elements[ftext].value
    newid=window.open(url,name,'toobar=no,'+tools);
  }
}

//弹出新窗，但没有提交的动作。
function openwin(name,urll,left,top,w,h,yn)
{       
	OpenWindow(name,urll,left,top,w,h,yn);
}
//弹出新窗，但附带提交（submit） 的动作。
function openwin2(name,urll,left,top,w,h,yn)
{
	
	OpenWindow(name,"../include/blank.html",left,top,w,h,yn);
	subtarget(urll,name);
}
//分页按钮的提交
function sub(pbtn,name)
{
        document.pagerform.pbtn.value = pbtn;
        subnative1(name);
}
//设置 分页button 按钮提交时的 form 参数 （为本页）
function subnative1(filename)
{
    document.pagerform.action = filename;
	document.pagerform.method = "post";
	document.pagerform.target = "_self";
	document.pagerform.submit();
}
//设置 button 按钮提交时的 form 参数 （为本页）
function subnative(filename)
{
      	document.forms[0].action = filename;
	document.forms[0].method = "post";
	document.forms[0].target = "_self";
	document.forms[0].submit();
}

//设置 button 按钮提交时的 form 参数,action 为页面所设（为本页）
function subself()
{
	document.forms[0].method = "post";
	document.forms[0].target = "_self";
	document.forms[0].submit();
}

//设置 button 按钮提交时的 form 参数 （可根据参数 targetvalue 设置）
function subtarget(filename,targetvalue)
{

    document.forms[0].action = filename;
	document.forms[0].method = "post";
	document.forms[0].target = targetvalue;
	document.forms[0].submit();
}

function subopener(filepage)
{
	document.forms[0].action = filepage;
	document.forms[0].method = "post";
	document.forms[0].target = self.opener.name;
	document.forms[0].submit();
	
}
//--------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------//
//--------------------是和上面几个方法一一对应，可以设置提交的Form目标------------//


//分页按钮的提交
function subForm1(formIndex,pbtn,name)
{
        document.forms[formIndex].pbtn.value = pbtn;
        subnativeForm1(formIndex,name);
}
//PageInfo分页按钮的提交
function subForm_pageInfo(formIndex,curPage,name)
{
        //document.forms[formIndex].curPage.value = curPage;
        document.pagerform.curPage.value = curPage;
        subnativeForm(formIndex,name);
}

//设置 button 按钮提交时的 form 参数 （为本页）
function subnativeForm1(formIndex,filename)
{
      	document.forms[formIndex].action = filename;
	document.forms[formIndex].method = "post";
	document.forms[formIndex].target = "_self";
	document.forms[formIndex].submit();
}

//分页按钮的提交
function subForm(formIndex,pbtn,name)
{
        //document.forms[formIndex].pbtn.value = pbtn;
        //subnativeForm(formIndex,name);
        
        document.pagerform.pbtn.value = pbtn;
        subnativeForm(formIndex,name);
}

//设置 button 按钮提交时的 form 参数 （为本页）
function subnativeForm(formIndex,filename)
{
    document.pagerform.action = filename;
	document.pagerform.method = "post";
	document.pagerform.target = "_self";
	document.pagerform.submit();
}

//设置 button 按钮提交时的 form 参数,action 为页面所设（为本页）
function subselfForm(formIndex)
{
	document.forms[formIndex].method = "post";
	document.forms[formIndex].target = "_self";
	document.forms[formIndex].submit();
}

//设置 button 按钮提交时的 form 参数 （可根据参数 targetvalue 设置）
function subtargetForm(formIndex,filename,targetvalue)
{

      	document.forms[formIndex].action = filename;
	document.forms[formIndex].method = "post";
	document.forms[formIndex].target = targetvalue;
	document.forms[formIndex].submit();
}

function subopenerForm(formIndex,filepage)
{
	document.forms[formIndex].action = filepage;
	document.forms[formIndex].method = "post";
	document.forms[formIndex].target = self.opener.name;
	document.forms[formIndex].submit();
}
//----------------------------------------------------------------------



//关闭本窗口,聚焦父窗口,刷新父窗口,此刷新方法不同于下
//下面的方法，该方法可以刷新后不会弹出 "重试" 提示框
function openerflash()
{
	if(self.opener != null)
	{
		
		self.close();
                self.opener.focus();
                self.opener.location.replace(self.opener.location.href);
	}
}

//关闭本窗口,聚焦父窗口,刷新父窗口,此刷新方法不同于下
//下面的方法，该方法可以刷新后不会弹出 "重试" 提示框
function openerflash(openerPage)
{
	if(self.opener != null)
	{
		
		self.close();
                self.opener.focus();
                self.opener.location.replace(openerPage);
	}
}


//关闭本窗口,聚焦父窗口,刷新父窗口
function winclose()
{
 if(self.opener != null)
 {
   self.opener.location.reload(1);
   self.opener.focus();
 } 
 self.close();
}

//关闭本窗口,聚焦父窗口,但不刷新父窗口
function wincloseno()
{
 if(self.opener != null)
 {
   self.opener.focus();
 }
 self.close();
}


//屏蔽对按钮的双击
function show() 
{
  cover.style.visibility="visible";
}
//修改，报送，删除等的提示
function prompt(actionpage,alerts)
{
  if(confirm(alerts))
  {
	//openwin2('id',name,'330','240','1','1','no'); 
	subnative(actionpage);
	return true;
  }else{
       return false;
  }
}
//删除时的提示
function del_prompt(jspname)
{
   if(prompt(jspname,"您确定真的要删除吗？"))
   {
   	return true;
   }else{
        return false;
   }
}
//确认时的提示
function sub_prompt(jspname)
{
   if(prompt(jspname,"您确定真的要确认吗？"))
   {
   	return true;
   }else{
        return false;
   }
}

//删除提示
function delprompt()
{
   if(confirm("您确认真的要删除吗？"))
  {	
	return true;
  }else{
       return false;
  }   
}
//全选
function CheckAll(form)
{
  
   tt = form.elements.length;
   for(i= 0;i<tt;i++)
   {
     form.elements[i].checked = true;
   }
}
//不选
function NoCheckAll(form)
{
  
   tt = form.elements.length;
   for(i= 0;i<tt;i++)
   {
     form.elements[i].checked = false;
   }
}
//不能不选且只能选一
function CheckSel(form)
{
   tt = form.elements.length;
   hh = 0;
   for(i= 0;i<tt;i++)
   {
     if(form.elements[i].type == "checkbox" || form.elements[i].type == "radio")
     {
      if(form.elements[i].checked)
      {
      	hh++;     	
      }
     }
   }
   if(hh == 0){
   	alert("请您选择一行！");
   	return false;
   }else if(hh >1){
   	alert("对不起，只能选择一行！");
        return false;
   }else{
        return true;
   }
}
//可以多选，但不能不选
function CheckSend(form)
{
   tt = form.elements.length;
   hh = 0;
   for(i= 0;i<tt;i++)
   {
     if(form.elements[i].type == "checkbox" ||form.elements[i].type == "radio")
     {
      if(form.elements[i].checked)
      {
      	hh++;     	
      }
     }
   }
   if(hh == 0){
   	alert("请您先选择！");
   	return false;
   }else{
        return true;
   }
}

function checknumber(e)
{
   var charCode = (navigator.appName == "Netscape")?e.which:e.keyCode
   status = charCode
   if(charCode>31 && (charCode <48 || charCode>57))
   {
     alert("请输入数字！");
     return false;
   }else{
     return true;
   }
}

//为选择一选择框时的动作
function subOtherPage(pbtn)
{
     document.forms[0].pbtn.value = pbtn;
     subself();
     return true;
 
}


//定时关闭
function closeit() { 
setTimeout("self.close()",5000) //毫秒 
} 
//用于判断要删除的细目是否为零
function CheckZero()
{
   tt = document.funform.elements.length;
   hh = 0;
   for(i= 0,j=0;i<tt;i++)
   {
     if(document.funform.elements[i].type == "checkbox" || document.funform.elements[i].type == "radio")
     {
      if(document.funform.elements[i].checked)
      {
        var textname   = "text"+j;
        var textvalue  = eval("window.document.funform." + textname+".value");
               
        if(textvalue == 0)
        {
          alert("物资细目不能为零！");
          return false;
        }
      }
      j++;
     }
   }
   return true;
}
//打印所用的函数
function beforeprint() {
  pagectrl.className = 'pagectrloff';
}
function afterprint() {
  pagectrl.className = 'pagectrlon';
}
//截取小数点后 len 位
function cutpoint(pointvalue,len)
{
  
  var getvalue = pointvalue;
  pointvalue   = ""+pointvalue;
  var modulus  = "";//用于四舍五入的数
  for(i=0;i<len;i++)
  {
  	 modulus = modulus+"0";
  }
  modulus = parseFloat("0."+modulus+"5");
  if(pointvalue != "")
  {
     if(pointvalue.indexOf(".") >0)
     {
       var value_arr = pointvalue.split(".");
       if(value_arr[1].length > len)
       {
          newpointvalue =""+(parseFloat(pointvalue)+modulus);
          endnum = newpointvalue.indexOf(".")+parseInt(len)+1;
          getvalue = newpointvalue.substring(0,endnum);
          
       }
     }
  }

  return getvalue;
}

//删除前的判断
function checkDel(selValue)
{
  if(selValue == "")
  {
    alert("请选择要删除的项！");
    return false;
  }else{
    if(!confirm('确定要删除吗？'))
    return false;
  }
  return true;
}