
 
 //以下为查询年月日下拉框  
 function CMonth(){
    var YYvalue = document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value;
     if (YYvalue == ""){ 
       var e = document.form1.MM.value="";document.form1.MM.disabled=true;
     }else{
        document.form1.MM.disabled=false;
     }
 }
 function ShowModel2(url, strWidth, strHeight, strScroll) {  //指定大小和滚动条    
     var arg = "dialogHeight:" + strHeight + "px;dialogWidth:" + strWidth + "px;center:yes;resizable:yes;help:no;scroll:" + strScroll + ";unadorned:no";
     window.showModalDialog(url, '', arg);
 }
function ShowModel(url){  //弹出模式窗口，大小根据客户端屏幕大小调整    
    var arg="dialogHeight:800px;dialogWidth:820px;center:yes;resizable:yes;help:no;scroll:yes;unadorned:no";
    window.showModalDialog(url,'',arg);
}
function ShowModeless(url){       //弹出非模式窗口，大小根据客户端屏幕大小调整
		   var arg="dialogHeight:"+(screen.height-20)+"px;dialogWidth:"+(screen.width-60)+"px;center:yes;resizable:yes;help:no;scroll:yes;unadorned:no";
		   window.showModelessDialog(url,'',arg);         
		}
function ShowModeless(url,strWidth,strHeight,strScroll){  //指定大小和滚动条    
    var arg="dialogHeight:"+strHeight+"px;dialogWidth:"+strWidth+"px;center:yes;resizable:yes;help:no;scroll:"+strScroll+";unadorned:no";
    window.showModelessDialog(url,'',arg);
}
//按钮特效
function Waiting(id){
	var divL=document.getElementById("divL");
	var divX=event.x-5;
	var divY=event.y+5;
	id.disabled=true;         //变灰
	divL.style.left=divX+"px";
	divL.style.top=divY+"px";
	divL.style.display=""; 
	__doPostBack(id.name,"");
}
//=======================================================================================
//客户端数据验证
var numb = '0123456789';
  var dnum = '0123456789.';
function checkVal(num,dec,date,req){                  //参数为checkVal([document.form1.arg1],[document.form1.arg2],[document.form1.arg3])等等
    for(var i=0;i<num.length;i++){
        if(typeof(num[i])=='undefined'){    
			alert('页面不存在此控件，请确认控件名是否有误:'+num[i]);
			return false;
        }
        if(!isNum(num[i].value,numb)){               //验证整数
             num[i].style.border="solid 1px red";
             alert("必须为整数格式");
             if(num[i].disabled==false){    
               num[i].focus();
             }
             return false;
        }
        num[i].style.border="solid 1px gray";
    }
    for(var i=0;i<dec.length;i++){                    //验证小数
        if(typeof(dec[i])=='undefined'){    
			alert('页面不存在此控件，请确认控件名是否有误'+dec[i]);
			return false;
        }
        if(!isDec(dec[i].value,dnum)){               
             dec[i].style.border="solid 1px red";
             alert("必须为数字格式");
             if(dec[i].disabled==false){    
               dec[i].focus();
             }
             return false;
        }
        dec[i].style.border="solid 1px gray";
    }
	for(var i=0;i<date.length;i++){               //验证日期
	     if(typeof(date[i])=='undefined'){    
			alert('页面不存在此控件，请确认控件名是否有误'+date[i]);
			return false;
         }
		if(!isDate(date[i].value)){
		  date[i].style.border="solid 1px red";
		  alert("必须为日期格式(yyyy-mm-dd)");
		  if(date[i].disabled==false){ 
		    date[i].focus();
		  } 
		  return false;
		}
		date[i].style.border="solid 1px gray";
	  }  
	  for(var i=0;i<req.length;i++){               //验证日期
	     if(typeof(req[i])=='undefined'){    
			alert('页面不存在此控件，请确认控件名是否有误'+req[i]);
			return false;
         }
		if(req[i].value==''||req[i].value.replace(/   /g,'')==''||req[i].value=='undefined'){
		  req[i].style.border="solid 1px red";
		  alert("输入框为必填项");
		  if(req[i].disabled==false){ 
		    req[i].focus();
		  } 
		  return false;
		}
		req[i].style.border="solid 1px gray";
	  }  
	  return true;
	  
   }
	function isNum(param,numb) {             //检验是否为数字
		if (param == "") return true;
		for (i=0; i<param.length; i++) {
		   if (numb.indexOf(param.charAt(i),0) == -1) return false;
		}
		return true;
	}
	function checkNum(str)
	{return str.match(/D/)==null}
	
    function isDec(param,dnum) {             //检验是否为浮点数
        if (param =="") return true;
        for (i=0; i<param.length; i++) {
          if (dnum.indexOf(param.charAt(i),0)== -1) return false;
        }
        return true;
    }
    function isDate(param){                 //检验是否为日期yyyy-mm-dd
        if (param =="") return true;
          var arr=new Array();
          arr=param.split("-");
          var dt = new Date(arr[1]+"/"+arr[2]+"/"+arr[0]);
          if(dt.getDate()!=arr[2]){
             return false;
          }
          else if(dt.getMonth()!=arr[1]-1){
            return false;
          }
          else if(dt.getFullYear()!=arr[0]){
            return false;
          }
          return true;
      }

      //为string添加Trim 调用方法  str.Trim()  清除空格
      function String.prototype.Trim() { return this.replace(/\ /g, ""); }
      function String.prototype.Ltrim() { return this.replace(/(^\s*)/g, ""); }
      function String.prototype.Rtrim() { return this.replace(/(\s*$)/g, ""); }
    
//==========================================================================================================
//隐藏机构图
  function hidTree(){                               //点击TREE图标
		      var td1=document.getElementById('img1');
		      var tdLine1=document.getElementById("tdLine1");
		      var tdTree=document.frames["main"].window.document.getElementById("tdTree");
		      if(tdTree!=null){
		         if(tdTree.style.display=="none"){
		            tdTree.style.display="";
		            tdLine1.style.backgroundColor="#c3e8f7";
		            td1.src="Images/w_unit2.gif";
		         }
		         else{
		            tdTree.style.display="none";
		            tdLine1.style.background="#2eadcd";
		            td1.src="Images/w_unit.gif";
		         }
		         
		      }
		    }
		    function initTree(){                               //点击TREE图标		      
		      var td1=document.getElementById('img1');   
		      var tdLine1=document.getElementById("tdLine1");
		      var tdTree=document.frames["main"].window.document.getElementById("tdTree");
		      if(tdTree!=null){
		         if(tdTree.style.display=="none"){ 
		            tdLine1.style.background="#";
		            td1.src="Images/w_unit.gif";
		         }
		         else{		            
		            tdLine1.style.background="#c3e8f7";
		            td1.src="Images/w_unit2.gif";
		         }
		         
		      }else{
		            tdLine1.style.background="#2eadcd";
		           td1.src="Images/w_unit.gif";
		      }
		    }  
		   

