//查找窗体
function st_findForm(fName){
	for(i =0 ; i < top.document.frames.length; i++){
		if(top.document.frames[i].name == fName){
			return top.document.frames[i];
		}
	}
}

function st_changeModule(sLocation, sTarget, sDefaultPage){
	st_changeLocation(sLocation, sTarget);
	st_changeLocation(sDefaultPage, "mainFrame");
	
}

function st_changeLocation(sLocation,sTarget){
	var obj = st_findForm(sTarget);
	obj.location = sLocation;
   
}

//设置菜单样式
function st_changeMenuStyle(currentObj){
	var obj = document.all.mi;
	if(obj.length > 0) {
		for(i = 0; i < obj.length; i++){
			obj[i].className = 'menustyle2';
		}		
	}
	currentObj.className = 'menustyle1';
}

//隐藏与显示HTML，sid为要操作的HTML ID
function showsubmenu(sid,tid)
{
	whichEl = eval(sid);
	if (whichEl.style.display == "none")
	{
		eval(sid + ".style.display=\"\";");
		if(tid != null && tid != "") 
		{
			eval(tid +".innerHTML='6';");
		}
//		document.all.addtitle.innerHTML="<font face=\"webdings\">4</font>";
	}
	else
	{
		eval(sid + ".style.display=\"none\";");
		if(tid != null && tid != "") 
		{
			eval(tid +".innerHTML='5';");
		}
		//eval(tid +".innerHTML='<font face=\"webdings\">6</font>';");
	}
}
//弹出一个窗口，url为地址，W为宽，H为高。
 function QR(Me,infor)
 {
		      return window.confirm(infor)		      
		   
 }
 function windopincludscroll(url,w,h)
{
	var widths,heights;
	if(w == null)
	{
		widths = 400;
	}else
	{
		widths = w;
	}
	if(h == null)
	{
		heights = 300;
	}else
	{
		heights = h;
	}
	window.open(url,"","top=200,left=200,width=" + widths + ",height=" + heights + ",scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes");
}
function windop(url,w,h)
{
	var widths,heights;
	if(w == 0)
	{
		widths = screen.Width;
	}else
	{
		widths = w;
	}
	if(h == 0)
	{
		heights = screen.Height;
	}else
	{
		heights = h;
	}
	win=window.open(url,"","width=" + widths + ",height=" + heights + ",scrollbars=no,menubar=no,toolbar=no,resizable=yes");
	win.moveTo(Math.round((screen.Width - w)/2),Math.round((screen.Height - h)/2) + 20);
}
//弹出模态窗口
function OpenPage(strv,name)
{
	var obj = eval("document.all." + name);
	var str = window.showModalDialog(strv,window,"center:yes;dialogHeight:450px;dialogWidth:550px;status:no;scroll:no");
	//window.alert(str);
	if(str != null && str != "")
	{
		obj.value = str;
	}
	//eval("document.all." + name + ".value=" + str + ";");
}
//关闭一个窗口
function closewin()
{
	window.close();
}
//弹出提示，返回True，false,MSG为要弹出的提示信息,URL为跳转到的页面
function WinConfig(msg,url)
{
	if(confirm(msg))
	{
		if(url != null && url != '')
		{
			window.navigate(url);
		}
		return true;
	}
	else
	{
		return false;
	}
}
//返回上一页
function back()
{
	history.go(-1)
}
//刷新父页且关闭当前页参数clo如果为true则关闭当前页
function winclose(clo)
{
	var str = window.opener.location.href;
	window.opener.location.href = str;
	if(clo == true)
	{
		window.close();
	}
}
// 全选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
		}
	}	
}

//点击链接全选checked
function LinkCheckBox(myname)
{
	var LinkHide = false
	var a = document.all.item(myname,0)
	if(a.checked == false)
	{
		//window.alert(a.checked);
		LinkHide = true;
		a.checked= true
	}
	else
		a.checked= false
	for (var i=0;i<document.all.item(myname).length;i++)
	{
	    
		var e = document.all.item(myname,i)
		
		if ( LinkHide == true)
		{
			e.checked = true
		}
		else
		e.checked = false
	}	
}


//删除询问    
	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 OpenWindowS(Me,url,Parameters,Width,Height)
  {
   if (Me.disabled==true)
	     {
	       return false
	      }
  var Ys="toolbar=no,location=no,directions=no,status=no,revisable=no,resizable=yes,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);
  } 	
  
  //显示对话框

 function ShowDialog(Mess)
 {
 window.alert(Mess)
 }
  
  //关闭一个窗口
   function CloseWindow()
  {
   window.close();
  }	
    //关闭一个窗口
   function CloseParentWindow()
  {
   window.parent.close();
  }	
   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 reLoadTopPag()
		{
		    window.top.location.href=window.top.location.href;
		}
  
  function SendUrl(url)
  {
        window.location.href=url;
  }
  
//从新加载当前页面 适合添加时点击保存使用


 function ReloadWindow()
 {

  var str =  window.opener.location.href
  str=str.replace('#','')
  window.opener.location.href=str
 }	
 
 //窗体居中
function LoadMove()
 {
	window.moveTo(Math.round((screen.Width - window.document.body.clientWidth )/2),Math.round((screen.height - window.document.body.clientHeight-160)/2) );
 }
		      
		      
 //验证控件是否有效

//返回模态窗口的值
function ReturnPageValue(a)
{
	
	window.returnValue = a;
	window.close();
}

 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
									}
							   }
							   
							}
												
						
						
	     }
	      
	      
	      
	    }
