//
// UI层通用的javascript function
// by eric 2004-7-23
// 
//
//================================================


//将enter键转换为tab键，防止回车提交
//by eric 2004-8-16
//====================================
document.onkeydown=KeyDownEvent;
var count;
function KeyDownEvent()
{
	//alert(event.target);
	
	if(event.keyCode==13)
	{
     if (event.srcElement.tagName !="TEXTAREA")
		event.keyCode=9;
    }
}
//====================================

// 有提醒的关闭
function closeWithReminder()
{
	var reply = confirm("是否确定将关闭窗口?");
	if (reply) {
		top.close ();
	}

}
//删除提醒
function DeleteConfirm()
{
    return window.confirm("确实要删除吗?");
}
//返回到主页面
function ReturnHome()
{
	top.location .href ="../oa/oaindex.aspx";
}

//打开一个标准的窗口
function openWindow(strURL)
{

	//window.open(strURL);
	//window.open(strURL,"abc","menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=500");
	openWindow2(strURL,"Material");
}
function openWindow2(strURL,strTitle)
{

	//window.open(strURL);
	//window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=500");
	var W = 500; // width
	var H = 600; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	var win;
	win=window.open(strURL,strTitle,s);
	win.focus();		
	
}
//新打开一个窗体用于录入或显示780X600
//by eric 0907
// by jili 2005-02-17
function openPageWindow(strURL)
{	
	//alert(222);
	var win;
	var strTitle="showPage";
	//window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
	var W = 780; // width
	var H = 600; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	win=window.open(strURL,strTitle,s);
	win.focus();

}

function openPageWindow2(strURL) {
    //alert(222);
    var win;
    var strTitle = "showPage";
    //window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
    var W = 920; // width
    var H = 700; // height
    var X = (screen.availWidth - W) / 2; // x position
    var Y = (screen.availHeight - H) / 2; // y position
    var s = "resizable,left=" + X + ",top=" + Y + ",screenX=" + X + ",screenY=" + Y + ",scrollbars=yes,width=" + W + ",height=" + H;

    win = window.open(strURL, strTitle, s);
    win.focus();

}

function openPageWindow3(strURL) {
    //alert(222);
    var win;
    var strTitle = "showPage";
    //window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
    var W = 800; // width
    var H = 400; // height
    var X = (screen.availWidth - W) / 2; // x position
    var Y = (screen.availHeight - H) / 2; // y position
    var s = "resizable,left=" + X + ",top=" + Y + ",screenX=" + X + ",screenY=" + Y + ",scrollbars=yes,width=" + W + ",height=" + H;

    win = window.open(strURL, strTitle, s);
    win.focus();

}


function openPageWindows(strURL) {
    //alert(222);
    var win;
    var strTitle = "showPage";
    //window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
    var W = 700; // width
    var H = 400; // height
    var X = (screen.availWidth - W) / 2; // x position
    var Y = (screen.availHeight - H) / 2; // y position
    var s = "resizable,left=" + X + ",top=" + Y + ",screenX=" + X + ",screenY=" + Y + ",scrollbars=yes,width=" + W + ",height=" + H;

    win = window.open(strURL, strTitle, s);
    win.focus();

}
//新打开最大化窗体小50的窗口，用于显示内容多的页面。

//by eric 0907
function openMaxWindow(strURL)
{	
	var win;
	var strTitle="showPage";
	//window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
	var W = screen.availWidth-20; // width
	var H = screen.availHeight-100; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	win=window.open(strURL,strTitle,s);
	win.focus();	
	
}
function openSizeModalDialogMax(url)
{
    var win;
	var strTitle="showPage";
	//window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
	var W = screen.availWidth-20; // width
	var H = screen.availHeight-100; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	//var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
		var windowFeatures="dialogLeft:"+X+"px;dialogTop:"+Y+"px; dialogWidth:"+W+"px; dialogHeight:"+H+"px; center:yes";		
		var result = window.showModalDialog(url, window,windowFeatures);
}
//用于在新打开的窗体基础上再新打开一个窗体

//by chunminghong 
function openBlankPageWindow(strURL)
{
	var strTitle="showPage";	
	//window.open(strURL,"_blank","menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
	
	// by jili 2005-02-17
	var W = 780; // width
	var H = 600; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strURL,"_blank",s)		
	
	
}
function openBlankMaxWindow(strURL)
{
    var win;
	//var strTitle="showPage";
	//window.open(strURL,strTitle,"menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,height=600,width=780");
	var W = screen.availWidth-20; // width
	var H = screen.availHeight-100; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	win=window.open(strURL,"_blank",s);
	win.focus();	
}


function openSizeWindow(strURL,H,W)
{	
	// by jili 2005-02-17
	//alert('oi');
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top=0,screenX="+X+",scrollbars=yes,width="+W+",height="+(H-30);
 
	window.open(strURL,"Material",s)	
	
}
//打开一个模式窗体

function openModalDialog(url)
{

		var result = window.showModalDialog(url, window, 
						"dialogWidth:400px; dialogHeight:300px; center:yes");
}
//打开一个自定义的模式窗体

function openSizeModalDialog(url,height,width)
{

		var windowFeatures="dialogWidth:"+width+"px; dialogHeight:"+height+"px; center:yes";		
		var result = window.showModalDialog(url, window,windowFeatures);
}

//是否是有效点击得radio

function isValidRadio(radio) {
    var valid = false;
    for (var i = 0; i < radio.length; i++) {
        if (radio[i].checked) {
            return true;
        }
    }
  //  alert("Make a choice from the radio buttons.");
    return false;
}

function ShowMagazineTree()
{
	//window.open("../../Public/DepartmentTree.aspx?ReturnDesc=tbxSuggestDepartment&ReturnID=tbxSuggestDepartmentID","_blank","fullscreen=no,height=400,width=200,left=500,top=100");
	openWindow("MagazineTypeTree.aspx");
}
//modify by chenlin @2005-0128
function ShowPeopleTree(ControlName)
{
	//window.open("../../Public/PeopleTree.aspx?ReturnDesc="+ControlName+"&ReturnID="+ControlName+"ID","_blank","fullscreen=no,scrollbars=yes,height=400,width=200,left=500,top=100");
	//PeopleTreeForAuto(ControlName,ControlName,2);
	PeopleTreeShow(ControlName,ControlName+"ID",2);
	

}

//用于检查TextBox的字符串长度
function tbxVallenCheck(obj, maxLen,errMessage)
{
	strValue=obj.value;
	if (strValue.length>maxLen)
	{
		alert(errMessage + maxLen);
		obj.focus();
	}
}

//用于在界面显示/隐藏界面元素
//by eric 2004-11-25
//refrence to OAUI/usercontrol/CtrlAssetBuyApplyInfo.ascx
function ShowHidePanel(varElement1,varImage)
{
	var block = document.getElementById(varElement1);
	var blockImg = document.getElementById(varImage);
	
	if( blockImg.alt=="hide")
	{//if current status is hide,then show
		block.style.display = "block";
		blockImg.alt="show";
		blockImg.src="../../images/BttnCllps.gif";
	}else
	{//if current status is show,then hide;
		block.style.display = "none";
		blockImg.alt="hide";
		blockImg.src="../../images/BttnExpnd.gif";
	}
}
//hide a element
function HideHtmlElement(varElement1)
{
	var block = document.getElementById(varElement1);
	if (block!=null)
		block.style.display = "none";
}
function ShowHtmlElement(varElement1)
{
	var block = document.getElementById(varElement1);
	if (block!=null)
		block.style.display = "block";
}

function ShowGDZCTree(codeCtrl, itemNameCtrl, unitCtrl, itemTypeCtrl)
{
	//固定资产的选择树

	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
	
	window.open("../../public/GDZCTree.aspx?codeCtrl="+codeCtrl+"&itemNameCtrl="+itemNameCtrl+"&unitCtrl="+unitCtrl+"&itemTypeCtrl="+itemTypeCtrl, "_blank",s);
}

// 显示部门树

function DeptTreeShow(param1,param2,level)
{
	var strLevel="../../";
	if (level==1)
		strLevel="../";		
	//window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank",s)
}

// 显示党组织树
function PartyDeptTreeShow(param1,param2,level)
{
	var strLevel="../../";
	if (level==1)
		strLevel="../";		
	//window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/CadreOrganizationTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank",s)
}

//显示人员树

function PeopleTreeShow(param1,param2,level)
{
var strLevel="../../";
	if (level==1)
		strLevel="../";	
//	alert(strLevel);	
	//window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank",s)
	//window.open(strLevel+"Public/DepTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank",s)	
	
}

function DepTreeShow(param1,param2,level,myid)
{
	var strLevel="../../";
	if (level==1)
		strLevel="../";	
//	alert(strLevel);	
	//window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
	//alert(document.forms[0].elements[myid]);
	window.open(strLevel+"Public/MyTreeKS.aspx?ReturnDesc="+param1+"&lpid="+document.forms[0].elements[myid].value+"&ReturnID="+param2,"_blank",s)	
}

function DepTreeShow_ForQuery(param1,param2,level,myid)
{
	var strLevel="../../";
	if (level==1)
		strLevel="../";	
//	alert(strLevel);	
	//window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2,"_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
	//alert(document.forms[0].elements[myid]);
	window.open(strLevel+"Public/MyTree_ForQuery.aspx?ReturnDesc="+param1+"&lpid="+document.forms[0].elements[myid].value+"&ReturnID="+param2,"_blank",s)	
}

function PeopleTreeForAuto(param1,param2,level)
{
    var strLevel="../../";
	if (level==1)
		strLevel="../";	
	//window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2+"ID","_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/PeopleTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2+"ID","_blank",s)
	
}
function DeptTreeForAuto(param1,param2,level)
{
    var strLevel="../../";
	if (level==1)
		strLevel="../";	
	//window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2+"ID","_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");               
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc="+param1+"&ReturnID="+param2+"ID","_blank",s)

}

function  DeptTreeForAutoSpec1(level)
{
    var strLevel="../../";
	if (level==1)
		strLevel="../";	
	//window.open(strLevel+"Public/DepartmentTree.aspx?FormName=AutoRegister&ReturnDesc=tbxSYBM&ReturnID=tbxSYBMID","_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/DepartmentTree.aspx?FormName=AutoRegister&ReturnDesc=tbxSYBM&ReturnID=tbxSYBMID","_blank",s)
	
}
function  DeptTreeForAutoSpec2(level)
{
    var strLevel="../../";
	if (level==1)
		strLevel="../";	
	//window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc=tbxSybm&ReturnID=tbxSybmID","_blank","fullscreen=no,scrollbars=yes,height=500,width=380,left=400,top=100");
	
	//by jili 2005-02-17
	var W = 380; // width
	var H = 500; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strLevel+"Public/DepartmentTree.aspx?ReturnDesc=tbxSybm&ReturnID=tbxSybmID","_blank",s)
	
}


//打开一个帮助文件的窗口 
function helpWindow(strUrl)
{
	

	//var X = (screen.availWidth-750)/2; // x position
	//var Y = (screen.availHeight-560)/2; // y position
	var W = 750; // width
	var H = 560; // height
	var X = (screen.availWidth-W)/2; // x position
	var Y = (screen.availHeight-H)/2; // y position
	var s="resizable,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",scrollbars=yes,width="+W+",height="+H;
 
	window.open(strUrl,'TheWindow',s)
}

//CheckBox选择项

function CCA(CB)
{
var frm=document.Form1;
if (CB.checked)
hL(CB);
else
dL(CB);

var TB=TO=0;
for (var i=0;i<frm.elements.length;i++)
{
var e=frm.elements[i];
if ( e.type=='checkbox')
{
TB++;
if (e.checked)
TO++;
}
}
//frm.allbox.checked=(TO==TB)?true:false;
}


function hL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="ChangeColor";
}

function dL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="BeforeColor";
}

function OpenMultiPeopleTree(level,Name,ID)
{
	var list;
	list = document.forms[0].elements[ID].value;
	if(null !=list) 
	{
		list=list.replace(/[\;]/g,",");
	}
	//openSizeWindow(level + 'public/SelectMultiPerson.aspx?ReturnDesc=' + Name + '&ReturnID=' + ID + '&IDList=' + list ,600,500);
	openSizeWindow(level + 'public/myTree.aspx?ReturnDesc=' + Name + '&ReturnID=' + ID + '&IDList=' + list,600,500);

}

//path存放IE打印设置的注册表地址, reg存放WScript.Shell组件的对象 
 
//通过注册表修改打印设置，只修改页眉、页脚和各边界的值 
//参数说明：header--页眉，footer--页脚，margin_left--左边界 

//margin_top--上边界，margin_right--右边界，margin_bottom--下边界 

//页边距的设置中 1对应25.4mm，即margin_left=1表示实际值的25.4mm 

//create by niuys
var path;
path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup";
function pagesetup(header,footer, margin_left,margin_top,margin_right,margin_bottom) 
{ 
  try
  {
    
    var Wsh=new ActiveXObject("WScript.Shell");
    Wsh.RegWrite(path+"\\header", header); //设置页眉 
    Wsh.RegWrite(path+"\\footer", footer);//设置页脚 
    Wsh.RegWrite(path+"\\margin_left", margin_left); //设置左边界 
    Wsh.RegWrite(path+"\\margin_top", margin_top); //设置上边界 
    Wsh.RegWrite(path+"\\margin_right", margin_right); //设置右边界 
    Wsh.RegWrite(path+"\\margin_bottom", margin_bottom); //设置下边界 
   }
   catch(e)
   {
     window.alert("it can not create active object,please set up Ie option!");
   } 
}

//根据页面设置打印页面
//参数说明：header--页眉，footer--页脚，margin_left--左边界 

//margin_top--上边界，margin_right--右边界，margin_bottom--下边界 

//页边距的设置中 1对应25.4mm，即margin_left=1表示实际值的25.4mm 

//create by niuys
function PagePrint(header,footer, margin_left, margin_top, margin_right, margin_bottom)
{  
   //window.alert('print start!');
   pagesetup(header, footer, margin_left, margin_top, margin_right, margin_bottom);
   window.print();
}

//打印预览 
//create by niuys
function PagePrintView()
{
   //window.alert("print view!");
    document.SelectPeople.wb.ExecWB(7,1);
}
//打印页面设置
//create by niuys
function PrintSetUp()
{
  // window.alert("print preview");
   document.SelectPeople.wb.ExecWB(8,1);
}

//myTree开始

function MyTree(tmpid)
{
	var tmpTableId=document.getElementById(tmpid);
	var tmpImageId=document.getElementById("img_"+tmpid);
	
	if(tmpTableId.style.display=="")
	{
		tmpImageId.src="../images/cls/Rplus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="none";
	}
	else
	{
		tmpImageId.src="../images/cls/Rminus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="";
	}	
}

function MyTreeOpen(tmpid)
{
	var tmpTableId=document.getElementById(tmpid);
	var tmpImageId=document.getElementById("img_"+tmpid);
	
	if(tmpTableId.style.display=="")
	{
		tmpImageId.src="../images/cls/Lplus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="none";
	}
	else
	{
		tmpImageId.src="../images/cls/Lminus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="";
	}	
}

function MyTreeOpenDepartment(tmppra,tmpid)
{
	var tmpTableId=document.getElementById(tmppra);
	var tmpTableUId=document.getElementById("u_"+tmppra);
	var tmpImageId=document.getElementById("img_"+tmpid);
		//alert(tmppra);
		//alert(tmpTableId);
	if(tmpTableId.style.display=="")
	{
		tmpImageId.src="../images/cls/Lplus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="none";
	    if(tmpTableUId!=null) tmpTableUId.style.display="none";
	}
	else
	{
		tmpImageId.src="../images/cls/Lminus.gif"
		if(tmpTableId!=null) tmpTableId.style.display="";
		if(tmpTableUId!=null) tmpTableUId.style.display="";
	}	
}

function selAll(cb_pra)
{	
	var inputList = document.body.getElementsByTagName("INPUT");
	var tmpCbPraId=document.getElementById(cb_pra);
	var tmpName="";
	for(var i=0;i<inputList.length;i++)
	{
		if(inputList[i].type=="checkbox")
		{		
			tmpName=inputList[i].name;
			if(tmpName.indexOf(cb_pra)!=-1 || tmpName.indexOf("u_"+cb_pra)!=-1)
			{				
				inputList[i].checked=tmpCbPraId.checked;
			}
		}
	}
}
function selKsAll()
{	
	var inputList = document.body.getElementsByTagName("INPUT");
	var varAll=document.getElementById("ck_All");
	for(var i=0;i<inputList.length;i++)
	{
		if(inputList[i].type=="checkbox")
		{
			inputList[i].checked=varAll.checked;
		}
	}
}
function selAllDep(cb_pra)
{
	var inputList = document.body.getElementsByTagName("INPUT");
	var tmpCbPraId=document.getElementById(cb_pra);
	var tmpName="";
	for(var i=0;i<inputList.length;i++)
	{
		if(inputList[i].type=="checkbox")
		{		
			tmpName=inputList[i].name;
			if(tmpName.indexOf(cb_pra)!=-1 && tmpName!=cb_pra)
			{		
					inputList[i].disabled=tmpCbPraId.checked;
					inputList[i].checked=tmpCbPraId.checked;	
			}
		}
	}
}

function SubmitSelectDep()
{
	var tmpUrl=location.search+"&";
	if(tmpUrl==null || tmpUrl=="&") return;
	
	var varAll=document.getElementById("ck_All");
	if(varAll!=null)
	{
		varAll.checked=false;
	}
	
	var start=tmpUrl.indexOf("ReturnDesc=")+11;
	var end=tmpUrl.indexOf("&");
	var ReturnDesc=tmpUrl.substring(start,end);
	
	
	start=tmpUrl.indexOf("ReturnID=")+9;
	end=tmpUrl.indexOf("&",start);
	var ReturnID=tmpUrl.substring(start,end);
	
	var inputList = document.body.getElementsByTagName("INPUT");
	var tmpName="";
	var tmpId="";
	var isFirst=true;
	for(var i=0;i<inputList.length;i++)
	{
		if(inputList[i].type=="checkbox" && inputList[i].disabled!=true && inputList[i].checked==true)
		{	
			if(isFirst==true)	
			{
				tmpName=inputList[i].value;
				tmpId=inputList[i].title;
				isFirst=false;
			}
			else
			{
				tmpName+=";"+inputList[i].value;
				tmpId+=";"+inputList[i].title;
			}
		}
	}
	opener.document.forms[0].elements[ReturnDesc].value=tmpName;	
	opener.document.forms[0].elements[ReturnID].value=tmpId;
	
	window.close();
}


function SubmitSelect()
{
	var tmpUrl=location.search+"&";
	if(tmpUrl==null || tmpUrl=="&") return;
	
	var start=tmpUrl.indexOf("ReturnDesc=")+11;
	var end=tmpUrl.indexOf("&");
	var ReturnDesc=tmpUrl.substring(start,end);
	
	
	start=tmpUrl.indexOf("ReturnID=")+9;
	end=tmpUrl.indexOf("&",start);
	var ReturnID=tmpUrl.substring(start,end);
	
	var inputList = document.body.getElementsByTagName("INPUT");
	var tmpName="";
	var tmpId="";
	var isFirst=true;
	for(var i=0;i<inputList.length;i++)
	{
		if(inputList[i].type=="checkbox" && inputList[i].name.indexOf("u_")!=-1 && inputList[i].checked==true)
		{	
			if(isFirst==true)	
			{
				tmpName=inputList[i].value;
				tmpId=inputList[i].title;
				isFirst=false;
			}
			else
			{
				tmpName+=";"+inputList[i].value;
				tmpId+=";"+inputList[i].title;
			}
		}
	}
	//alert(ReturnID);
	//return;
	opener.document.forms[0].elements[ReturnDesc].value=tmpName;
	//alert(opener.document.forms[0].elements[ReturnID]);
	opener.document.forms[0].elements[ReturnID].value=tmpId;
	window.close();
}

function openAndClose(tmpId)
{
	var trId=document.getElementById(tmpId);
	var tmpImageId=document.getElementById("img_"+tmpId);
		//alert(tmppra);
		//alert(tmpTableId);
	if(trId.style.display=="")
	{
		if(tmpImageId!=null) tmpImageId.src="../../images/shrinkNode.gif"
		if(trId!=null) trId.style.display="none";
	}
	else
	{
		if(tmpImageId!=null) tmpImageId.src="../../images/showNode.gif"
		if(trId!=null) trId.style.display="";
	}
}

function view_list_open_close(tmpId)
{
	var trId=document.getElementById(tmpId);
	var tmpImageId=document.getElementById("img_"+tmpId);
		//alert(tmppra);
		//alert(tmpTableId);
	if(trId.style.display=="")
	{
		if(tmpImageId!=null) tmpImageId.src="../images/shrinkNode.gif"
		if(trId!=null) trId.style.display="none";
	}
	else
	{
		if(tmpImageId!=null) tmpImageId.src="../images/showNode.gif"
		if(trId!=null) trId.style.display="";
	}
	
}


function createDiv()
{
	var tdiv=document.createElement("div");
//Z-INDEX: 9; LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px
	var tmp2='<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">'
		tmp2+='<TR><td width="30%"><FONT face="宋体"></FONT></td><TD bgColor="#ff9900">'
		tmp2+='<TABLE height="70" cellSpacing="2" cellPadding="0" width="100%" border="0">'
		tmp2+='<TR><td align="center" bgColor="#eeeeee" style="font-size:33;color:#000000;"><img src="../../images/upimg.gif"></td></TR>'
		tmp2+='</TABLE>'
		tmp2+='</TD><td width="30%"></td>'
		tmp2+='</TR></TABLE>'


    var tmp1='<div style="width:100%;background:#ffffff;height:800px;Z-INDEX: 9; VISIBILITY: visible; POSITION: absolute;"><div style="Z-INDEX: 10; VISIBILITY: visible; POSITION: absolute;padding:300px 0 0 0;text-align:center;">'+tmp2+'</div></div>';
    tdiv.innerHTML=tmp1;
    tdiv.style.display="block";
    	
    tdiv.style.position="absolute";
    tdiv.style.filter="alpha(opacity=40)";
    //tdiv.style.cursor="move";
    
    tdiv.style.width="100%";
    tdiv.style.height=800;
    
    //此层初始化位置

    tdiv.style.top=0;
    tdiv.style.left=0;
    //document.body.appendChild(tdiv);
    document.body.appendChild(tdiv);
    
    //return;
}



function createWord(strTmp)
{	
	var tWord=document.createElement("div");

//Z-INDEX: 9; LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px
	
	var tmp2='<TABLE background:#B2B2B2; cellSpacing="0" cellPadding="0" width="100%" border="0">'
		tmp2+='<TR><td width="30%"><FONT face="宋体"></FONT></td><TD bgColor="#D6D6D6">'
		tmp2+='<TABLE height="221" cellSpacing="0" cellPadding="0" width="100%" border="0">'
		tmp2+='<TR><td align="center" bgColor="#D6D6D6" style="font-size:25;color:red;" id="td_info">';
		tmp2+='<embed src="../../images/'+strTmp+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="495" height="221"></embed>';
		tmp2+='</td></TR>'
		tmp2+='</TABLE>'
		tmp2+='</TD><td width="30%"></td>'
		tmp2+='</TR></TABLE>'


    var tmp1='<div style="width:100%;height:900px;Z-INDEX: 10; VISIBILITY: visible; POSITION: absolute;"><div style="Z-INDEX: 11; VISIBILITY: visible; POSITION: absolute;padding:200px 0 0 0;text-align:center;">'+tmp2+'</div></div>';
    
    //var tmp1='<div style="text-align:left;border:#000 1px solid;width:100%;background:#ffffff;height:800px;Z-INDEX: 9; VISIBILITY: visible; POSITION: absolute;"><div style="Z-INDEX: 10; VISIBILITY: visible; POSITION: absolute;padding:300px 0 0 0;text-align:center;">OK</div></div>';
    tWord.innerHTML=tmp1;
    tWord.style.display="block";
    	
    tWord.style.position="absolute";
    tWord.style.filter="alpha(opacity=100)";
    //tdiv.style.cursor="move";
    tWord.style.width="100%";
    tWord.style.height=screen.availHeight;
    
    //此层初始化位置

    tWord.style.top=0;
    tWord.style.left=0;
    //document.body.appendChild(tdiv);
    document.body.appendChild(tWord);
    
    return;

}
function createDivAll(strTmp)
{
	var tdiv=document.createElement("div");

    var tmp1='<div style="width:100%;background:#B2B2B2;height:900px;Z-INDEX: 9; VISIBILITY: visible; POSITION: absolute;"></div>';
    
    //var tmp1='<div style="text-align:left;border:#000 1px solid;width:100%;background:#ffffff;height:800px;Z-INDEX: 9; VISIBILITY: visible; POSITION: absolute;"><div style="Z-INDEX: 10; VISIBILITY: visible; POSITION: absolute;padding:300px 0 0 0;text-align:center;">OK</div></div>';
    tdiv.innerHTML=tmp1;
    tdiv.style.display="block";
    	
    tdiv.style.position="absolute";
    tdiv.style.filter="alpha(opacity=50)";
    //tdiv.style.cursor="move";
    tdiv.style.width="100%";
    tdiv.style.height=screen.availHeight;
    
    //此层初始化位置

    tdiv.style.top=0;
    tdiv.style.left=0;
    //document.body.appendChild(tdiv);
    document.body.appendChild(tdiv);
    createWord(strTmp);
    //return;
}

function delFile(divId)
{
	var delDiv=document.getElementById(divId);
	//delDiv.innerHTML="";
	delDiv.parentNode.removeChild(delDiv); 
	//delDiv.removeNode(true);
}

function openCloseAttach(attachId)
{
	
	var tr;
	var img_tmp=document.getElementById("img_"+attachId);	
	var styleString="";
	//alert(img_tmp.src);
	if(img_tmp.src.indexOf("folder.gif")!=-1)
	{
		img_tmp.src="../images/attach/folder_open.gif"
		styleString="";
	}
	else
	{
		img_tmp.src="../images/attach/folder.gif"
		styleString="none";
	}
	for(var i=0;i<100;i++)
	{
		tr=document.getElementById("tr_"+attachId+"_"+i);	
		if(tr==null) return ;
		
		tr.style.display=styleString;
	}
	
}
function OpenWinNoMaxMinClose(str1)
{/*
	maximizeWin();
	var mode="fullscreen=3,menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=no,status=0";
	window.open(str1,"",mode);
	*/
	maximizeWin();
	var mode="menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=no,status=1"
	var newwin=window.open(str1,"",mode);
	newwin.moveTo(0,0);			
	newwin.resizeTo(screen.availWidth,screen.availHeight);
			
}

function maximizeWin() { 
	if (window.screen) { 
	var aw = screen.availWidth; 
	var ah = screen.availHeight; 
	window.moveTo(0, 0); 
	window.resizeTo(aw, ah); 
	} 
}

function loading(width)
{	
    var frame=parent.window.document.getElementById("main");	    
    frame.setAttribute("height",width);
}

function ChangeImage(ThisImage,ImageName)
{	
    ThisImage.src="../images/button/" + ImageName;
} 

//给string 增加 trim() 函数
String.prototype.trim=function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
var FCheck = 
{
    IntReg : new RegExp("^[\\+\\-]?[0-9]+$"),
    FloatReg : new RegExp("^[\\+\\-]?[0-9]+([\\.][0-9]*)?$"),
    IsInt:function(NumStr)
    {
	    return FCheck.IntReg.test(NumStr.trim())
    },
    IsFloat:function(FloartStr,dotNum)
    {
	    var str = text.trim();
	    var regChar;
	    if (!dotNum)
	    {
		    dotNum = "*";
	    }
	    if (dotNum == "*")
	    {
		    regChar = FCheck.FloatReg;
	    }
	    else
	    {
            if(!FCheck.IsInt(dotNum) || parseInt(dotNum) < 0 )
            {
                throw "dotNum参数错误!";
            }
		    regChar = new RegExp("^[\\+\\-][0-9]+([\\.][0-9]{0,"+ dotNum +"})?$");
	    }
	    return regChar.test(str);
    },
    IsNullOrEmpty:function(str)
    {
        if(!str) return true;
        if(str.trim().length == 0) return true;
        return false;
    },
    CheckEmpty:function(id,message)
    {
        var value = $id(id).value;
        if(FCheck.IsNullOrEmpty(value))
        {
            alert(message + "不可为空！");
            return false;
        }
        return true;
    },
    CheckInt:function (id,message)
    {
        var value =  $id(id).value.trim();
        if(!FCheck.IsInt(value))
        {
            alert(message + "的格式不正确，必须整数！");
            return false;
        }
        return true;
    },
    CheckFloat:function (id,message,dotNum)
    {
        var value =  $id(id).value.trim();
        if(!dotNum) dotNum = "*";
        if(!(dotNum == "*" || (FCheck.IsInt(dotNum) && parseInt(dotNum) >= 0 )))
        {
            throw "dotNum参数错误!";
        }
        if(!FCheck.IsFloat(value,dotNum))
        {
            if(FCheck.IsInt(dotNum))
            {
                alert(message + "的格式不正确，必须为不超过"+ dotNum +"位的小数！！");
            }
            else
            {
                alert(message + "的格式不正确，必须为小数！！");
            }
            return false;
        }
        return true;
    }
}    
function $id(strId)
{
    return document.getElementById(strId);
}



