/**
*	控件部分
*/

/*

-------------- 函数检索 --------------
trim函数:                         trim() lTrim() rTrim()
校验字符串是否为空:                 checkIsNotEmpty(str)
校验字符串是否为整型:               checkIsInteger(str)
校验整型最小值:                    checkIntegerMinValue(str,val)
校验整型最大值:                    checkIntegerMaxValue(str,val) 
校验整型是否为非负数:               isNotNegativeInteger(str)
校验字符串是否为浮点型:             checkIsDouble(str) 
校验浮点型最小值:                  checkDoubleMinValue(str,val)
校验浮点型最大值:                  checkDoubleMaxValue(str,val)
校验浮点型是否为非负数:             isNotNegativeDouble(str)
检验浮点值的小数位：				checkFlatDecimalLength(sControlObject,iDecimalLength)
校验字符串是否为日期型:             checkIsValidDate(str)
校验两个日期的先后:                checkDateEarlier(strStart,strEnd)
校验字符串是否为email型:           checkEmail(str)

校验字符串是否为中文:               checkIsChinese(str)
计算字符串的长度，一个汉字两个字符:   realLength()
校验字符串是否符合自定义正则表达式:   checkMask(str,pat)
得到文件的后缀名:                   getFilePostfix(oFile)  
-------------- 函数检索 --------------
*/
/**
*	added by snakeyang 2004.10.19
*	对页面的控件值进行判断
*	sControlObject 	控件对象
*	sControlType 	控件类型	Integer 整型；Float 浮点；PN 正数；Date 日期；Email 邮件地址；String 字符串
*	sMinValue		最小值
*	sMaxValue		最大值
*	iDecimalLength  小数点长度
*	iNullFlag		控件值是否可以为空	0、允许；1、不允许
**/
function checkControlValue(sControlObject,sControlType,sMinValue,sMaxValue,iDecimalLength,iNullFlag,sMessage){
	var sControlValue=sControlObject.value;
	var sControlName=sControlObject.name;
	
	if (sMessage!=null){
		sControlName=sMessage;
	}	
	
	if (parseInt(iNullFlag)==1){
		if (checkIsNotEmpty(sControlValue)==false){
			alert(sControlName+"不能为空值！");
			return false;
		}	
	}
	if (sControlType=="Integer") {
		if (checkIsInteger(sControlValue)==false){
			alert(sControlName+"不是整数类型！");
			sControlObject.focus();
			return false;
		}else{
			if (sMinValue!=null){
				if (checkIntegerMinValue(sControlValue,sMinValue)==false){
					alert(sControlName+"不能小于"+sMinValue+"！");
					sControlObject.focus();
					return false;
				}
			}
			if (sMaxValue!=null){
				if (checkIntegerMaxValue(sControlValue,sMaxValue)==false){
					alert(sControlName+"不能大于"+sMaxValue+"！");
					sControlObject.focus();
					return false;
				}
			}	
		}	
	}else if (sControlType=="Float") {
		if (checkIsDouble(sControlValue)==false){
			alert(sControlName+"不是浮点类型！");
			sControlObject.focus();
			return false;
		}else{
			if (sMinValue!=null){
				if (checkDoubleMinValue(sControlValue,sMinValue)==false){
					alert(sControlName+"不能小于"+sMinValue+"！");
					sControlObject.focus();
					return false;
				}
			}
			if (sMaxValue!=null){
				if (checkDoubleMaxValue(sControlValue,sMaxValue)==false){
					alert(sControlName+"不能大于"+sMaxValue+"！");
					sControlObject.focus();
					return false;
				}
			}	
			if (iDecimalLength!=null){
				if (!checkFlatDecimalLength(sControlObject,iDecimalLength)){
					sControlObject.focus();
					return false;
				}	
			}
		}		
	}else if (sControlType=="PN"){
		if (isNotNegativeDouble(sControlValue)==false){
			alert(sControlName+"不能是负数！");
			sControlObject.focus();
			return false;
		}else{
			if (sMinValue!=null){
				if (checkIntegerMinValue(sControlValue,sMinValue)==false){
					alert(sControlName+"不能小于"+sMinValue+"！");
					sControlObject.focus();
					return false;
				}
			}
			if (sMaxValue!=null){
				if (checkIntegerMaxValue(sControlValue,sMaxValue)==false){
					alert(sControlName+"不能大于"+sMaxValue+"！");
					sControlObject.focus();
					return false;
				}
			}	
		}	
	}else if (sControlType=="Date"){
		if (checkIsValidDate(sControlName,sControlValue)==false){
			sControlObject.focus();
			return false;
		}		
	}else if (sControlType=="Email"){
		if (checkEmail(sControlValue)==false){
			alert(sControlName+"的格式不合法！");
			sControlObject.focus();
			return false;
		}else{
			if (sMinValue!=null){
				if (parseInt(sControlValue.realLength())<parseInt(sMinValue)){
					alert(sControlName+"的长度不能小于"+sMinValue+"！");
					sControlObject.focus();
					return false;
				}
			}
			if (sMaxValue!=null){
				if (parseInt(sControlValue.realLength())>parseInt(sMaxValue)){
					alert(sControlName+"的长度不能大于"+sMaxValue+"！");
					sControlObject.focus();
					return false;
				}
			}	
		}			
	}else{
		if (sMinValue!=null){
			if (parseInt(sControlValue.realLength())<parseInt(sMinValue)){
				alert(sControlName+"的长度不能小于"+sMinValue+"！");
				sControlObject.focus();
				return false;
			}
		}
		if (sMaxValue!=null){
			if (parseInt(sControlValue.realLength())>parseInt(sMaxValue)){
				alert(sControlName+"的长度不能大于"+sMaxValue+"！");
				sControlObject.focus();
				return false;
			}
		}	
	} 
	
	return true;
}	
/**
* added by LxcJie 2004.6.25
* 去除多余空格函数
* trim:去除两边空格 lTrim:去除左空格 rTrim: 去除右空格
* 用法：
*     var str = "  hello ";
*     str = str.trim();
*/
String.prototype.trim = function()
{
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
String.prototype.lTrim = function()
{
    return this.replace(/(^[\s]*)/g, "");
}
String.prototype.rTrim = function()
{
    return this.replace(/([\s]*$)/g, "");
}
/********************************** Empty **************************************/
/**
*校验字符串是否为空
*返回值：
*如果不为空，定义校验通过，返回true
*如果为空，校验不通过，返回false               参考提示信息：输入域不能为空！
*/
function checkIsNotEmpty(str)
{
    if(str.trim() == "")
        return false;
    else
        return true;
}//~~~
/*--------------------------------- Empty --------------------------------------*/
/********************************** Integer *************************************/
/**
*校验字符串是否为整型
*返回值：
*如果为空，定义校验通过，      返回true
*如果字串全部为数字，校验通过，返回true
*如果校验不通过，              返回false     参考提示信息：输入域必须为数字！
*/
function checkIsInteger(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(/^(\-?)(\d+)$/.test(str))
        return true;
    else
        return false;
}//~~~
/**
*校验整型最小值
*str：要校验的串。  val：比较的值
*
*返回值：
*如果为空，定义校验通过，                返回true
*如果满足条件，大于等于给定值，校验通过，返回true
*如果小于给定值，                        返回false              参考提示信息：输入域不能小于给定值！
*/
function checkIntegerMinValue(str,val)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(typeof(val) != "string")
        val = val + "";
    if(checkIsInteger(str) == true)
    {
        if(parseInt(str,10)>=parseInt(val,10))
            return true;
        else
            return false;
    }
    else
        return false;
}//~~~
/**
*校验整型最大值
*str：要校验的串。  val：比较的值
*
*返回值：
*如果为空，定义校验通过，                返回true
*如果满足条件，小于等于给定值，校验通过，返回true
*如果大于给定值，                        返回false       参考提示信息：输入值不能大于给定值！
*/
function checkIntegerMaxValue(str,val)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(typeof(val) != "string")
        val = val + "";
    if(checkIsInteger(str) == true)
    {
        if(parseInt(str,10)<=parseInt(val,10))
            return true;
        else
            return false;
    }
    else
        return false;
}//~~~
/**
*校验整型是否为非负数
*str：要校验的串。
*
*返回值：
*如果为空，定义校验通过，返回true
*如果非负数，            返回true
*如果是负数，            返回false               参考提示信息：输入值不能是负数！
*/
function isNotNegativeInteger(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(checkIsInteger(str) == true)
    {
        if(parseInt(str,10) < 0)
            return false;
        else
            return true;
    }
    else
        return false;
}//~~~
/*--------------------------------- Integer --------------------------------------*/
/********************************** Double ****************************************/
/**
*校验字符串是否为浮点型
*返回值：
*如果为空，定义校验通过，      返回true
*如果字串为浮点型，校验通过，  返回true
*如果校验不通过，              返回false     参考提示信息：输入域不是合法的浮点数！
*/
function checkIsDouble(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    //如果是整数，则校验整数的有效性
    if(str.indexOf(".") == -1)
    {
        if(checkIsInteger(str) == true)
            return true;
        else
            return false;
    }
    else
    {
        if(/^(\-?)(\d+)(.{1})(\d+)$/g.test(str))
            return true;
        else
            return false;
    }
}//~~~
/**
*校验浮点型最小值
*str：要校验的串。  val：比较的值
*
*返回值：
*如果为空，定义校验通过，                返回true
*如果满足条件，大于等于给定值，校验通过，返回true
*如果小于给定值，                        返回false              参考提示信息：输入域不能小于给定值！
*/
function checkDoubleMinValue(str,val)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(typeof(val) != "string")
        val = val + "";
    if(checkIsDouble(str) == true)
    {
        if(parseFloat(str)>=parseFloat(val))
            return true;
        else
            return false;
    }
    else
        return false;
}//~~~
/**
*校验浮点型最大值
*str：要校验的串。  val：比较的值
*
*返回值：
*如果为空，定义校验通过，                返回true
*如果满足条件，小于等于给定值，校验通过，返回true
*如果大于给定值，                        返回false       参考提示信息：输入值不能大于给定值！
*/
function checkDoubleMaxValue(str,val)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(typeof(val) != "string")
        val = val + "";
    if(checkIsDouble(str) == true)
    {
        if(parseFloat(str)<=parseFloat(val))
            return true;
        else
            return false;
    }
    else
        return false;
}//~~~
/**
*校验浮点型是否为非负数
*str：要校验的串。
*
*返回值：
*如果为空，定义校验通过，返回true
*如果非负数，            返回true
*如果是负数，            返回false               参考提示信息：输入值不能是负数！
*/
function isNotNegativeDouble(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(checkIsDouble(str) == true)
    {
        if(parseFloat(str) < 0)
            return false;
        else
            return true;
    }
    else
        return false;
}//~~~
/*--------------------------------- Double ---------------------------------------*/
/********************************** date ******************************************/
/**
*校验字符串是否为日期型
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为日期型，校验通过，       返回true
*如果日期不合法，                   返回false    参考提示信息：输入域的时间不合法！（yyyy-MM-dd）
*/
function checkIsValidDate(sControlName,sControlValue)
{
    //如果为空，则通过校验
   
    if(sControlValue == "")
        return true;
    var pattern = /^((\d{4})|(\d{2}))-(\d{1,2})-(\d{1,2})$/g;
    if(!pattern.test(sControlValue)){
        alert(sControlName+"的格式不合法(yyyy-MM-dd)！");
        return false;
    }    
    var arrDate = sControlValue.split("-");
    if(parseInt(arrDate[0],10) < 100)
        arrDate[0] = 2000 + parseInt(arrDate[0],10) + "";
    var date =  new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]);
    if (parseInt(arrDate[1],10)>12 && parseInt(arrDate[1],10)>0){
    	alert(sControlName+"的月份不能大于12"); 
        return false;
    }else if ((parseInt(arrDate[1],10)==1 || parseInt(arrDate[1],10)==3 || parseInt(arrDate[1],10)==5 || parseInt(arrDate[1],10)==7 || parseInt(arrDate[1],10)==8 || parseInt(arrDate[1],10)==10 || parseInt(arrDate[1],10)==12) && parseInt(arrDate[1],10)>0){
		if (parseInt(arrDate[2],10)>31 && parseInt(arrDate[2],10)>0){
			alert(sControlName+"的值错误"+arrDate[0]+"年"+arrDate[1]+"月的天数不能大于31"); 
        	return false;
    	}
	}else if ((parseInt(arrDate[1],10)==4 || parseInt(arrDate[1],10)==6 || parseInt(arrDate[1],10)==9 || parseInt(arrDate[1],10)==11) && parseInt(arrDate[1],10)>0){
		if (parseInt(arrDate[2])>30 && parseInt(arrDate[2],10)>0){
			alert(sControlName+"的值错误"+arrDate[0]+"年"+arrDate[1]+"月的天数不能大于30");
        	return false;
    	}
	}else if (parseInt(arrDate[1],10)==2 && parseInt(arrDate[1],10)>0){ 
		if (checkLeapYear(arrDate[0]) && parseInt(arrDate[2],10)>29 && parseInt(arrDate[2],10)>0){
			alert(sControlName+"的值错误"+arrDate[0]+"年"+arrDate[1]+"月的天数不能大于29");
			return false;
		}
		if (!checkLeapYear(arrDate[0]) && parseInt(arrDate[2],10)>28 && parseInt(arrDate[2],10)>0){
			alert(sControlName+"的值错误"+arrDate[0]+"年"+arrDate[1]+"月的天数不能大于28");	
			return false;
		}
	}else if (date.getYear() == arrDate[0] && date.getMonth() == (parseInt(arrDate[1],10) -1)+"" && date.getDate() == arrDate[2]){
        return true;
    }else{
    	alert(sControlName+"的格式不合法(yyyy-MM-dd)！");
		return false;
	}
	return true;	 	    
}//~~~
/**
*校验两个日期的先后
*返回值：
*如果其中有一个日期为空，校验通过,          返回true
*如果起始日期早于等于终止日期，校验通过，   返回true
*如果起始日期晚于终止日期，                 返回false    参考提示信息： 起始日期不能晚于结束日期。
*/
function checkDateEarlier(strStart,strEnd)
{
    if(checkIsValidDate(null,strStart) == false || checkIsValidDate(null,strEnd) == false)
        return false;
    //如果有一个输入为空，则通过检验
    if (( strStart == "" ) || ( strEnd == "" ))
        return true;
    var arr1 = strStart.split("-");
    var arr2 = strEnd.split("-");
    var date1 = new Date(arr1[0],parseInt(arr1[1].replace(/^0/,""),10) - 1,arr1[2]);
    var date2 = new Date(arr2[0],parseInt(arr2[1].replace(/^0/,""),10) - 1,arr2[2]);
    if(arr1[1].length == 1)
        arr1[1] = "0" + arr1[1];
    if(arr1[2].length == 1)
        arr1[2] = "0" + arr1[2];
    if(arr2[1].length == 1)
        arr2[1] = "0" + arr2[1];
    if(arr2[2].length == 1)
        arr2[2]="0" + arr2[2];
    var d1 = arr1[0] + arr1[1] + arr1[2];
    var d2 = arr2[0] + arr2[1] + arr2[2];
    if(parseInt(d1,10) > parseInt(d2,10))
       return false;
    else
       return true;
}//~~~
/*--------------------------------- date -----------------------------------------*/
/********************************** email *****************************************/
/**
*校验字符串是否为email型
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为email型，校验通过，      返回true
*如果email不合法，                  返回false    参考提示信息：Email的格式不正確！
*/
function checkEmail(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if (str.charAt(0) == "." || str.charAt(0) == "@" || str.indexOf('@', 0) == -1
        || str.indexOf('.', 0) == -1 || str.lastIndexOf("@") == str.length-1 || str.lastIndexOf(".") == str.length-1)
        return false;
    else
        return true;
}//~~~
/*--------------------------------- email ----------------------------------------*/
/********************************** chinese ***************************************/
/**
*校验字符串是否为中文
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为中文，校验通过，         返回true
*如果字串为非中文，             返回false    参考提示信息：必须为中文！
*/
function checkIsChinese(str)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi;
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~~
/**
* 计算字符串的长度，一个汉字两个字符
*/
String.prototype.realLength = function()
{
  return this.replace(/[^\x00-\xff]/g,"**").length;
}
/*--------------------------------- chinese --------------------------------------*/
/********************************** mask ***************************************/
/**
*校验字符串是否符合自定义正则表达式
*str 要校验的字串  pat 自定义的正则表达式
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串符合，校验通过，           返回true
*如果字串不符合，                   返回false    参考提示信息：必须满足***模式
*/
function checkMask(str,pat)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = new RegExp(pat,"gi")
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~~
/*--------------------------------- mask --------------------------------------*/
/********************************** file ***************************************/
/**
* added by LxcJie 2004.6.25
* 得到文件的后缀名
* oFile为file控件对象
*/
function getFilePostfix(oFile)
{
    if(oFile == null)
        return null;
    var pattern = /(.*)\.(.*)$/gi;
    if(typeof(oFile) == "object")
    {
        if(oFile.value == null || oFile.value == "")
            return null;
        var arr = pattern.exec(oFile.value);
        return RegExp.$2;
    }
    else if(typeof(oFile) == "string")
    {
        var arr = pattern.exec(oFile);
        return RegExp.$2;
    }
    else
        return null;
}//~~~
/*--------------------------------- file --------------------------------------*/

//检验浮点值的小数位
function checkFlatDecimalLength(sControlObject,iDecimalLength){
 	//判断小数位
	var sControlValue=sControlObject.value;
	var sControlName=sControlObject.name;
	
 	if(!checkIsInteger(sControlValue)){
		var iValueLength=sControlValue.split(".")[1].length;
 		if(parseInt(iValueLength,10) > parseInt(iDecimalLength,10)){
 			alert("在"+sControlName+"中只允许输入"+iDecimalLength+"位小数，请重新填写！");
 			return false ;
 		}
 	}
 	return true;
}


//检查时间是否正确
function checkTime(sHour,sMinute,displayValue){
	var hour=sHour.value;
	var minute=sMinute.value;
	if(hour>23||hour<0){
    	alert(displayValue+"时数在0-23之内");
    	return false;
	}
	if(minute>59||minute<0){
    	alert(displayValue+"分钟数在0-59之内");
    	return false;
	}
	return true;
}

//检查是否闰年
function checkLeapYear(sYear){
	if (((sYear%4==0)&&(sYear%100!=0))||(sYear%400))
		return true;
	else
		return false;
}

//多行列表框移动操作
//查找所有记录
function selectAll(objectName){
 	var ilen;
  	ilen=objectName.length;
  	for (var i=0;i<ilen;i++){
    	objectName.options[i].selected=true;
  	}
}
//移动到顶部
function upTopMove(objectName){
  	var temptext,tempvalue;
  	var index;
  	index=objectName.selectedIndex; 
  	if (index == -1)
    	alert("请先选择一项！");
  	else {
   		if (index > 0) {
    		temptext=objectName.options[index].text;
    		tempvalue=objectName.options[index].value;
    		for (i = index -1;i > -1;i--) {  	
  				objectName.options[i + 1].text=objectName.options[i].text;
  				objectName.options[i + 1].value=objectName.options[i].value;  	
  			}
    		objectName.options[0].text=temptext;
    		objectName.options[0].value=tempvalue;
    		objectName.selectedIndex = 0;
    	}
  	}
}
//向上移动
function upStepMove(objectName){
  	var temptext,tempvalue;
  	var index;
  	index=objectName.selectedIndex;
  	if (index == -1)
    	alert("请先选择一项！");
  	else {
   		if (index > 0) {
  			temptext=objectName.options[index - 1].text;
  			tempvalue=objectName.options[index - 1].value;
  			objectName.options[index - 1].text=objectName.options[index].text;
  			objectName.options[index - 1].value=objectName.options[index].value;
  			objectName.options[index].text=temptext;
  			objectName.options[index].value=tempvalue;
  			objectName.selectedIndex = index - 1; 
  		}
  	}
}
//向下移动
function downStepMove(objectName){
 	var temptext,tempvalue;
  	var index;
  	index=objectName.selectedIndex;  
  	if (index == -1)
    	alert("请先选择一项！");
  	else {
    	if (index < objectName.length - 1 ) {
  			temptext=objectName.options[index + 1].text;
  			tempvalue=objectName.options[index + 1].value;
  			objectName.options[index + 1].text=objectName.options[index].text;
  			objectName.options[index + 1].value=objectName.options[index].value;
  			objectName.options[index].text=temptext;
  			objectName.options[index].value=tempvalue;
  			objectName.selectedIndex = index + 1;  	
  		}
  	}
}
//移动到底部
function downFloorMove(objectName){
  	var temptext,tempvalue;
  	var index,MaxIndex;
  	index=objectName.selectedIndex;
  	MaxIndex=objectName.length - 1;
   	if (index == -1)
    	alert("请先选择一项！");
  	else {
   		if (index < objectName.length - 1) {
    		temptext=objectName.options[index].text;
    		tempvalue=objectName.options[index].value;
    		for (i = index +1;i < objectName.length;i++) {  	
  				objectName.options[i - 1].text=objectName.options[i].text;
  				objectName.options[i - 1].value=objectName.options[i].value;  	
  			}
    		objectName.options[MaxIndex].text=temptext;
    		objectName.options[MaxIndex].value=tempvalue;
    		objectName.selectedIndex = MaxIndex;
   	 	}
  	}
}
//向左移动
function leftMove(TarObjectName,ResObjectName){
   	var index = ResObjectName.selectedIndex;
   	var MaxIndex = ResObjectName.length;
   	var oOption;
   	if (index == -1)
    	alert("请先选择一项！");
  	else {
    	StartPoint = 0;
    	EndPoint = MaxIndex;
    	for (i=StartPoint;i < EndPoint;i++){
       		if (ResObjectName.options[i].selected){      
    			oOption = new Option(ResObjectName.options[i].text,ResObjectName.options[i].value);
    			TarObjectName.add(oOption);
    			ResObjectName.remove(i);
    			i--;
    			EndPoint--;
    		}
    	}	
   	}  
}
//全部左移
function leftAllMove(TarObjectName,ResObjectName){
   	var MaxIndex = ResObjectName.length;
   	var oOption;   
   	if (MaxIndex != 0){    
    	for (i=0;i < MaxIndex;i++){       
    		oOption = new Option(ResObjectName.options[0].text,ResObjectName.options[0].value);
    		TarObjectName.add(oOption);
    		ResObjectName.remove(0);    		
    	}
    }	   
}
//向右移动
function rightMove(TarObjectName,ResObjectName){
   	var index = TarObjectName.selectedIndex;
   	var MaxIndex = TarObjectName.length;
   	var oOption;
   	if (index == -1)
    	alert("请先选择一项！");
  	else {
    	StartPoint = 0;
    	EndPoint = MaxIndex;
    	for (i=StartPoint;i < EndPoint;i++){
       		if (TarObjectName.options[i].selected){      
    			oOption = new Option(TarObjectName.options[i].text,TarObjectName.options[i].value);
    			ResObjectName.add(oOption);
    			TarObjectName.remove(i);
    			i--;
    			EndPoint--;
    		}    	
    	} 	
   }
}
//全部右移
function rightAllMove(TarObjectName,ResObjectName){
   	var MaxIndex = TarObjectName.length;
    if (MaxIndex != 0){    
    	for (i=0;i < MaxIndex;i++){     		    		  		
    		oOption = new Option(TarObjectName.options[0].text,TarObjectName.options[0].value);
    		ResObjectName.add(oOption);
    		TarObjectName.remove(0);  
    	}
    }	
}

/**
*	页面控制部分
*/
//var sTG="WzjqyWIN";
var sTG="_blank";
//打开一个新窗口
function openWindow(htmlURL,sTarget,iTop,iLeft,sToolbar,sLocation,sDirectories,sStatus,sMenubar,sScrollbars,sResizable,iWidth,iHigh){
	var newWIN=window.open(htmlURL,sTarget,"top="+iTop+",left="+iLeft+",toolbar="+sToolbar+",location="+sLocation+",directories="+sDirectories+",status="+sStatus+",menubar="+sMenubar+",scrollbars="+sScrollbars+",resizable="+sResizable+",width="+iWidth+",height="+iHigh);
	newWIN.focus();
	return false;
}
//第一层窗口打开
function oneOpenWin(sUrl,sWidth,sHeight,sCheckValue){
  	if (sCheckValue!=null){
  		if(sCheckValue==""){
    		alert("请先选择记录！");
    		return false;
  		}
	}
  	openWindow(sUrl,sTG,"95","150","no","no","no","no","no","yes","no",sWidth,sHeight);
 	return true;
}
//第一层自定义长宽窗口打开
function oneOpenWinD(sUrl,sWidth,sHeight,sCheckValue){
  	if (sCheckValue!=null){
  		if(sCheckValue==""){
    		alert("请先选择记录！");
    		return false;
  		}
	}
		itop=parseInt(document.body.clientHeight)/2;
		ileft=parseInt(document.body.clientWidth)/2;
  	openWindow(sUrl,sTG,itop,ileft,"no","no","no","no","no","yes","no",sWidth,sHeight);
 	return true;
}
//多层窗口打开
function multilayerOpenWin(sUrl,sTarget,sWidth,sHeight,sCheckValue){
  	if (sCheckValue!=null){
  		if(sCheckValue==""){
    		alert("请选择记录！");
    		return false;
  		}
  	}	
  	openWindow(sUrl,sTarget,"20","20","no","no","no","no","no","yes","no",sWidth,sHeight);
  	return true;
}
//XML窗口打开
function xmlOpenWin(sUrl,sTarget,sWidth,sHeight){
  	openWindow(sUrl,sTarget,"20","20","no","no","no","no","no","no","no",sWidth,sHeight);
}
//打印系统时间
function sysDate(){
  	var y=new Date();
	var gy=y.getYear();
	var dName=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
	var mName=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
	return "<span class=\"date\">"+y.getFullYear() +"年"+ mName[y.getMonth()] + y.getDate() + "日" +"&nbsp; "+ dName[y.getDay()] + "</span>";
			
}

function isChecked(obj){
	if (obj==null){ 
  		return false;
  	}	
  	if (obj.length==null){
  		if (obj.checked == true)
  			return true;
  		else 
  			return false;
  	}
  	for (i=0;i < obj.length;i++){
  		if (obj[i].checked == true)
  			return true;
  	}
  	return false;
}
//查询按钮
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
//////////////////////////////////////
//以下为新增、修改界面公用
function SetRow(xmlTable){
   
	   var index = 0;
    for (i = 0; i < xmlTable.rows.length; i++) 
    {
 
       if ((xmlTable.rows(i) ==window.event.srcElement.parentElement)||(xmlTable.rows(i) ==window.event.srcElement.parentElement.parentElement)||(xmlTable.rows(i) ==window.event.srcElement.parentElement.parentElement.parentElement))
       {      
          xmlTable.rows(i).children(0).children(0).checked = true;
     	
       }
    }   

   
}

