//居中Windows

  



//验证控件是否有效



 function CheckButton(Me)
	    {
	     if (Me.disabled==true)
	     {
	       return false
	      }
	      
	      
	       for (var i=0;i<window.document.Form1.elements.length;i++)
	     {
	     
	            var e = window.document.Form1.elements[i];

													
							if (e.type == 'text')
							{
							  if (e.maxLength>0) 
							   {
							   var Str =e.value.replace(/[^\x00-\xff]/g,'**').length;
									if (Str>e.maxLength)
									{
									   window.alert('输入的字符超过指定长度，需核对。');
									   e.select();
									    return false
									}
							   }
							   
							}
												
						
						
	     }
	      
	      
	      
	    }
	function CheckButtonMy(Me)
	    {
	     if (Me.disabled==true)
	     {
	       return false
	      }
	      
	      
	      
	       for (var i=0;i<window.document.Form1.elements.length;i++)
	     {
	     
	            var e = window.document.Form1.elements[i];

													
							if (e.type == 'text')
							{
							  if (e.maxLength>0) 
							   {
							   var Str =e.value.replace(/[^\x00-\xff]/g,'**').length;
									if (Str>e.maxLength)
									{
									   window.alert('输入的字符超过指定长度，需核对。');
									   e.select();
									   return false
									}
							   }
							   
							}
												
						
						
	     }
	      
	      
	    }    

//刷新筐架结构内的页面
function framelocation(url,Parameters,framesname)

		{

			if (Parameters.leng==0)
			{parent.frames[framesname].location.href =url;}
			else
			{parent.frames[framesname].location.href =url +'?'+ Parameters;} 
		}

	    
	    
//删除询问    
	function Delenquire(Me)
	{
	 if (Me.disabled==true)
	     {
	       return false
	      }
	var count;  
	count=0;
	
	for (var i=0;i<window.document.Form1.elements.length;i++)
	     {
	     
	            var e = window.document.Form1.elements[i];

													
							if (e.type == 'checkbox')
							{
							  if  (e.checked==true && e.name!='AllSelect') 
							   { count++ }
							}
								
	     } 
	 if (count>0)    
	  {return window.confirm("确定要删除所选项吗？")}
	 else 
	  {return false}
	}
	
	
	//还原询问    
	function Recovery(Me)
	{
	 if (Me.disabled==true)
	     {
	       return false
	      }
	var count;  
	count=0;
	
	for (var i=0;i<window.document.Form1.elements.length;i++)
	     {
	     
	            var e = window.document.Form1.elements[i];

													
							if (e.type == 'checkbox')
							{
							  if  (e.checked==true && e.name!='AllSelect') 
							   { count++ }
							}
								
	     } 
	 if (count>0)    
	  {return window.confirm("确定要恢复所选项吗？")}
	 else 
	  {return false}
	}
	
	
//打开一个窗口

// '参数: url 地址
//        Parameters 参数
  function OpenWindowN(url,Parameters)
  {
  if (Parameters.leng==0)
   {window.open(url);}
   else
   {window.open(url +'?'+ Parameters)} 
  }

//窗体居中
function LoadMove()
		      {
		         window.moveTo(Math.round((screen.Width - window.document.body.clientWidth )/2),Math.round((screen.height - window.document.body.clientHeight-160)/2) );
		      }
  
  
//打开一个窗口

// '参数: url 地址
//        Parameters 参数 并加验证
   function OpenWindowY(Me,url,Parameters)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
  if (Parameters.leng==0)
   { win=window.open(url);}
   else
   { win=window.open(url +'?'+ Parameters)} 
   
  // win.moveTo(Math.round((screen.Width - WinWidth)/2),Math.round((screen.Height - WinHeight)/2) + 20);
  // win.location = Url

   
   
   
   
  }
  	
//打开一个有样式的窗口

// '参数: url 地址
//        Parameters 参数 并加验证 再加宽度和高度，并居中

 function OpenWindowS(Me,url,Parameters,Width,Height)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
  var Ys="toolbar=no,location=no,directions=no,status=no,revisable=no,width=" + Width + " height=" + Height	      
  if (Parameters.leng==0)
   {win=window.open(url,'',Ys);}
   else
   {win=window.open(url +'?'+ Parameters,'',Ys)} 
    win.moveTo(Math.round((screen.Width - Width)/2),Math.round((screen.Height - Height)/2) + 20);
  } 	
  
  
  
  	
  //大课表打开一个模式窗口	
  var JWwin;
  
  function DKBOpenWindowS(url,Parameters,Width,Height)
  {
     if (JWwin  != null )
     { 
       if (JWwin.closed != true)
        {
         JWwin.location.search=Parameters;
         JWwin.focus();
         return false
         }
      }
		var Ys="toolbar=no,location=no,directions=no,status=no,revisable=no,width=" + Width + " height=" + Height	      
		JWwin=window.open(url +'?'+ Parameters,'',Ys,JWwin);
		JWwin.moveTo(Math.round((screen.Width - Width)/2),Math.round((screen.Height - Height)/2) + 20);

  } 	
  
  
  
  //打开一个模式窗口
  // '参数: Me 当前控件
  //'       url 地址包括地址参数
  //        Parameters 打开窗口的样式 dialogWidth:700px;dialogHeight:500px;center:yes;status:no
  function OpenModalDialog(Me,url,Parameters)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
   
   window.showModalDialog(url,Parameters);
  }	
  
  
 //改变当前页面的连接
  // '参数: Me 当前控件 加验证
  //'       url 地址包括地址参数
  function DiversionLink(Me,url)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
   window.document.location.href=url;
  }	
  
  
  
  
 //显示对话框

 function ShowDialog(Mess)
 {
 window.alert(Mess)
 }
  
  
//关闭一个窗口

   function CloseWindow()
  {
   window.close();
  }	
  
 // 刷新上一个用openwindow 或   OpenModalDialog 方式打开的窗口 适合编辑时点击保存使用

 
  //改变当前页面的连接
  // '参数: Me 当前控件 加验证
  //'       url 地址包括地址参数
  function DiversionLink(Me,url)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
   window.document.location.href=url
  }	
 
 
   function ReloadOpenerWindow()
  {
  // 
  // var url =window.opener.location.href
   // window.opener.location.href("");
   // window.opener.location.href("view-source:" + window.opener.location.href) ;
  //  window.opener.focus();
  var str =  window.opener.location.href
  str=str.replace('#','')
  window.opener.location.href=str
  }	
  
  
//从新加载当前页面 适合添加时点击保存使用

 function ReloadWindow()
 {

  var str =  window.opener.location.href
  str=str.replace('#','')
  window.opener.location.href=str
 }	
  
//
//  '获得代码选择脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得代码编号的控件名
//    '       CodeContentControl  获得代码内容的控件名
//    '       Code 代码编号
//    '       CodeContent 代码内容
     function SelCodeScript(TForm,TCodeControl,TCodeContentControl,TCode,TCodeContent) 
     {
      window.opener.document.forms(TForm).elements(TCodeControl).value=TCode
      window.opener.document.forms(TForm).elements(TCodeContentControl).value=TCodeContent
     }
       
 //  '获得学生选择脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得学号的控件名
//    '       CodeContentControl  获得姓名的控件名
//    '       Code   学号
//    '       CodeContent 姓名
     function SelStudentScript(TForm,TCodeControl,TCodeContentControl,TCode,TCodeContent,TClassControl,TClass) 
     {
      window.opener.document.forms(TForm).elements(TCodeControl).value=TCode
      window.opener.document.forms(TForm).elements(TCodeContentControl).value=TCodeContent
      
       if (TClassControl.length>0 && TClass.length>0)
       {window.opener.document.forms(TForm).elements(TClassControl).value=TClass}
     }
      

//
//  '获得代码选择脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得图片地址的控件名
//    '       Code 图片地址
     function SelImageScripte(TForm,TCodeControl,TCode) 
     {
      window.opener.document.images(TCodeControl).src=TCode
      window.opener.document.forms(TForm).elements("txtSrc").value=TCode
     }

//  '获得教职工号脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得教职工编号的控件名
//    '       CodeContentControl  获得教职工姓名的控件名
//    '       Code 教职工编号
//    '       CodeContent 教职工姓名

     function SelTeacherScript(TForm,TCodeControl,TCodeContentControl,TCode,TCodeContent,TKSMCContent,TKSHContent,TKSMC,TKSH) 
     {
        window.opener.document.forms(TForm).elements(TCodeContentControl).value=TCodeContent
        window.opener.document.forms(TForm).elements(TCodeControl).value=TCode
    
      if (TKSH.length>0 && TKSMC.length>0)
      {       window.opener.document.forms(TForm).elements(TKSMCContent).value=TKSMC
              window.opener.document.forms(TForm).elements(TKSHContent).value=TKSH }
     }
     
     
 //  '为排课表特写
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得科室编号的控件名
        function SelTeacherScript_KB(TCodeControl,JZGXM,ZGH) 
     {
        var str=window.opener.MainTable.cells(TCodeControl).innerHTML;
        var index=str.indexOf("<BR>",0);
      
        if (IsZGHCZ(window.opener.MainTable.cells(TCodeControl),ZGH)==true)
        {
			str=str.substr(0,index+3) + " <BR> <FONT class=\"font_5\">" + JZGXM + "<\FONT>";
			window.opener.MainTable.cells(TCodeControl).innerHTML=str;
			window.opener.MainTable.cells(TCodeControl).ZGH=ZGH
			return true
        }
        else
         {
           return false
         }
         
     }
     
     
      function IsZGHCZ(e,ZGH) //判断 星期几的第几节 是否有职工存在
          {
          
            var SK =new Array;
            var str = "";
            SK=e.id.split("_");
           
            if (SK.length>2)
            {
                
               
              
                
                 for (var i=0;i<window.opener.BJTable.cells.length-1;i++)
                 {
                    var Me=window.opener.MainTable.cells("TD" + window.opener.BJTable.cells(i).title + "_" + SK[SK.length-2] + "_" + SK[SK.length-1] )
                     
                   
                    if (Me.id != e.id)   
                    {
                      if (Me.ZGH==ZGH && Me.ZGH.length>0)
                          {
                             
                             window.alert(window.opener.BJTable.cells(i).title + "班级的上课老师和当前产生冲突。")
                             return false 
                          }
   
                     }
                   }
              return true    
             }
             
            
          } 
     
     
     

//  '获得科室编号脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得科室编号的控件名
//    '       CodeContentControl  获得科室名称的控件名
//    '       Code 科室编号
//    '       CodeContent 科室名称

     function SelBranchScript(TForm,TCodeControl,TCodeContentControl,TCode,TCodeContent) 
     {
      window.opener.document.forms(TForm).elements(TCodeControl).value=TCode
      window.opener.document.forms(TForm).elements(TCodeContentControl).value=TCodeContent
     }





// 

	    
// 全选checked按钮
function CheckBoxChang(form)
				{
				for (var i=0;i<form.elements.length;i++)
						{
							var e = form.elements[i];
							if ( e.name != 'AllSelect')
							{
							e.checked = form.AllSelect.checked
							}
		   
				
							
				}	
        
        }
        
        function radioBoxChang(form,thises)
				{
				
				for (var i=0;i<form.elements.length;i++)
						{
							var e = form.elements[i];
							if ( e.name != 'AllSelect')
							{
							e.checked = false;
							}
		   
				
							
				}	
				thises.checked=true;
        
        }


//
//  '获得房间编号脚本
//    '参数: Form 要传入控件所在的form
//    '       CodeControl 获得房间编号的控件名
//    '       CodeContentControl  获得房间名称的控件名
//    '       Code 房间编号
//    '       CodeContent 房间名称

     function SelRoomScript(TForm,TCodeControl,TCodeContentControl,TCode,TCodeContent) 
     {
      window.opener.document.forms(TForm).elements(TCodeControl).value=TCode
      window.opener.document.forms(TForm).elements(TCodeContentControl).value=TCodeContent
     }


//点击下拉列表链接到URL
//<select name="aaaa" onClick="MM_jumpMenu('parent',this,0)">
  //  <option value="http://www.163.com" selected>163</option>
    //<option value="http://www.sohu.com" selected>sohu</option>
  //</select>
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu1(targ,selObj,restore){ //v3.0
  window.open(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
//<a href="javascript:window.external.AddFavorite('http://www.163.com')" >加入收藏</a>
//<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.163.com')">设为首页</a>
//<a href="mailto:XXX@163.com" class="aa">联系我们</a>