
/*******************************************************************************************************************
* 函數名稱: CheckEmail																						       *	
* 功能說明: 檢查 email格式是否正確																		       *
* 傳入參數: 1. sTextObj 為 text 欄位值； 型態為 字串	；如sTextName 為空白，則不做任何動作	  				   *
*																												   *   
* 傳 回 值:   True or False																							   *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckEmail(sTextObj){
	var x =	sTextObj.value ;
	var re = new RegExp("[\?\/\*\+\?\(\)\[!#$^&;',<>\}\{\"\~]+","i");
	var result;

	result = re.exec(x);

if (sTextObj.value!='') {
	
	if (result != null) { 

		alert ("你所輸入的E-Mail格式錯誤");

		sTextObj.select();

		return false;

	} else if (sTextObj.value.indexOf("@")<=0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf("@")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (sTextObj.value.indexOf("@") != sTextObj.value.lastIndexOf("@")) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (sTextObj.value.indexOf(".",parseInt(sTextObj.value.indexOf("@"))) <= 0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf(".")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else {
	
		return true;
	}

		return true;
  }
	
}
/*******************************************************************************************************************
* 函數名稱: CheckNumbChar																						   *	
* 功能說明: 檢查 所輸入之姓名是否輸入文字及數字以外之其它資料，如有，則將以訊息告知使用者並將游標移至此欄位		   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckNumbChar(sTextObj,sMsgTxt){
	var sx = sTextObj.value ;
	var re = new RegExp("[\?\/\.\*\+\?\|\(\)\[@!#$%^&';:,<>\}\{\"\~]+","i");
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " +"不可輸入特殊字元資料");
		sTextObj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckNumb																						       *	
* 功能說明: 檢查 所輸入之值是否為數值字串																		   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckNumb(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^0-9]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " + "不可輸入數字以外的資料");
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckID																						       *	
* 功能說明: 檢查 所輸入之身份證字號是否正確																		   *
* 傳入參數: 1. sId 為 text 欄位值			； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*							   *   
* 傳 回 值:   True  OR  False 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckID(sId) {
  var sIdLoad = ''+ sId.value.toUpperCase()
  
  if (sIdLoad !="") {
	  if (sIdLoad.length != 10)
		{
			alert('身分證號碼錯誤!\r\n字數不足!')
			sId.select();
			return false;
		}
	
	  //建立一個 ID_Input 陣列
	  var ID_Input    = new Array(10)
	  //將 sIdLoad 字串一個字元接著一個字元放入 ID_Input 陣列內
	  for (var i=0; i<10; i++) { ID_Input[i] = sIdLoad.charAt(i) }
	  //====以下測試 ID_Input[0] 是否為英文字母===
	  var EngString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	  ID_Input[0]   = EngString.indexOf(ID_Input[0])
	  if (ID_Input[0] == -1)
		{
			alert('身分證號碼錯誤!\r\n無開頭的字母!')
			sId.select();
			return false;
		}
	  if (ID_Input[1] !=1 && ID_Input[1] !=2)
		{
			alert('身分證號碼錯誤!\r\n無法辨識性別!')
			sId.select();
			return false;
		}
		  var NumArray  = new Array(26)
		  NumArray[0]   = 1 ; NumArray[1]  = 10; NumArray[2]  = 19;
		  NumArray[3]   = 28; NumArray[4]  = 37; NumArray[5]  = 46;
		  NumArray[6]   = 55; NumArray[7]  = 64; NumArray[8]  = 39;
		  NumArray[9]   = 73; NumArray[10] = 82; NumArray[11] = 2 ;
		  NumArray[12]  = 11; NumArray[13] = 20; NumArray[14] = 48;
		  NumArray[15]  = 29; NumArray[16] = 38; NumArray[17] = 47;
		  NumArray[18]  = 56; NumArray[19] = 65; NumArray[20] = 74;
		  NumArray[21]  = 83; NumArray[22] = 21; NumArray[23] = 3 ;
		  NumArray[24]  = 12; NumArray[25] = 30;

	  var result = NumArray[ID_Input[0]]
	  for (var i=1; i<10; i++)
		{
		var NumString = '0123456789'
		ID_Input[i] = NumString.indexOf(ID_Input[i])
		if (ID_Input[i] == -1)
		  {
			  alert('身分證號碼錯誤!\r\n數字檢查錯誤!')
			  sId.select();
			  return false;
		  }
		else
		  { result += ID_Input[i] * (9-i) }
		}
	
	  result += 1 * ID_Input[9]
	  if (result % 10 != 0)
		{
			alert('身分證號碼錯誤!\r\n加總檢查錯誤!')
			sId.select();
			return false;
		}
	  return true;
 	} 
 }

/*******************************************************************************************************************
* 函數名稱: CheckEmail																						       *	
* 功能說明: 檢查 email格式是否正確																		       *
* 傳入參數: 1. sTextObj 為 text 欄位值； 型態為 字串	；如sTextName 為空白，則不做任何動作	  				   *
*																												   *   
* 傳 回 值:   True or False																							   *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckEmail(sTextObj){
	var x =	sTextObj.value ;
	var re = new RegExp("[\?\/\*\+\?\(\)\[!#$^&;',<>\}\{\"\~]+","i");
	var result;

	result = re.exec(x);

if (sTextObj.value!='') {
	
	if (result != null) { 

		alert ("你所輸入的E-Mail格式錯誤");

		sTextObj.select();

		return false;

	} else if (sTextObj.value.indexOf("@")<=0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf("@")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (sTextObj.value.indexOf("@") != sTextObj.value.lastIndexOf("@")) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (sTextObj.value.indexOf(".",parseInt(sTextObj.value.indexOf("@"))) <= 0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf(".")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else {
	
		return true;
	}

		return true;
  }
	
}

/*******************************************************************************************************************
* 函數名稱: CheckCDate																						       *	
* 功能說明: 檢查民國年日期格式是否正常																	           *
* 傳入參數: 1. oObjName 為 text 名稱		 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  			   *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True or False																						   *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2005/06/09	 																                       *
* 更新人員:   洪筱倩																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/
function CheckCDate(oObjName,sMsgText){
	var lIs_ok;
	var vDate;
	lIs_ok = true;   	
	if (oObjName.value != "") { 
		vDate=(parseInt(oObjName.value.substr(0,2))+1911).toString()+"/"+oObjName.value.substr(2,2)+"/"+oObjName.value.substr(4,2);
		sArry_date = vDate.split("/");		
		if (lIs_ok == true && sArry_date.length != 3) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』格式不正確");		
			oObjName.focus();
		} else {	
			sTemp_year = sArry_date[0] ;
			sTemp_month = sArry_date[1] ;
			sTemp_day = sArry_date[2] ;
		}
		
		//檢查是否輸入非數字的資料或數字格式不正確

		if (lIs_ok == true && (isNaN(sTemp_year) == true || sTemp_year.length != 4 || sTemp_year.indexOf(".",0) != -1 ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，年份格式不正確");		
			oObjName.focus();
		}
		
		
		if (lIs_ok == true && (isNaN(sTemp_month) == true || sTemp_month.indexOf(".",0) != -1 || (parseFloat(sTemp_month) < 1 || parseFloat(sTemp_month) > 12) ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，月份格式不正確");		
			oObjName.focus();
		}
		
		//alert(parseInt(sTemp_month));
		
		
		if (lIs_ok == true) {
			
			switch (parseFloat(sTemp_month)) {
				
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12 :
					
					//alert(parseFloat(sTemp_day));
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 31) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						oObjName.focus();
					}
					
					break;
				
				case 4:
				case 6:
				case 9:
				case 11 :
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 30) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						oObjName.focus();
					}
					
					break;
				
				case 2 :
					
					if (parseFloat(sTemp_year) % 4 == 0 && parseFloat(sTemp_year) % 100 != 0 || parseFloat(sTemp_year) % 400 == 0) {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 29) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
							oObjName.focus();
						}
						
						break;
						
					} else {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 28) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
							oObjName.focus();
						}
						
						break;
					
					}
			}
		}		
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckDate																						       *	
* 功能說明: 檢查 日期格式是否正常																		           *
* 傳入參數: 1. oObjName 為 text 名稱		 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  				   *
*			2.	sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息																								   *   
* 傳 回 值:   True or False																							   *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckDate(oObjName,sMsgText){
	var lIs_ok;
	lIs_ok = true;   
	
	
	if (oObjName.value != "") { 
		
		sArry_date = oObjName.value.split("/") ;
		
		if (lIs_ok == true && sArry_date.length != 3) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』格式不正確");		
		} else {		
			sTemp_year = sArry_date[0] ;
			sTemp_month = sArry_date[1] ;
			sTemp_day = sArry_date[2] ;
		}
		
		//檢查是否輸入非數字的資料或數字格式不正確
		if (lIs_ok == true && (isNaN(sTemp_year) == true || sTemp_year.length != 4 || sTemp_year.indexOf(".",0) != -1 ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，年份格式不正確");		
		}
		
		
		if (lIs_ok == true && (isNaN(sTemp_month) == true || sTemp_month.indexOf(".",0) != -1 || (parseFloat(sTemp_month) < 1 || parseFloat(sTemp_month) > 12) ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，月份格式不正確");		
		}
		
		//alert(parseInt(sTemp_month));
		
		
		if (lIs_ok == true) {
			
			switch (parseFloat(sTemp_month)) {
				
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12 :
					
					//alert(parseFloat(sTemp_day));
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 31) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
					}
					
					break;
				
				case 4:
				case 6:
				case 9:
				case 11 :
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 30) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
					}
					
					break;
				
				case 2 :
					
					if (parseFloat(sTemp_year) % 4 == 0 && parseFloat(sTemp_year) % 100 != 0 || parseFloat(sTemp_year) % 400 == 0) {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 29) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						}
						
						break;
						
					} else {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 28) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						}
						
						break;
					
					}
			}
		}		
	}

	if (lIs_ok == true) { 
		if (oObjName.value!= "") {
			if (sTemp_month.length<2)
			{
				sTemp_month = "0" + sTemp_month;
			}
			if (sTemp_day.length <2)
			{
				sTemp_day = "0" + sTemp_day;
			}

			oObjName.value=sTemp_year + "/" + sTemp_month + "/" + sTemp_day;
			return true;
		}
	} else {
		
		oObjName.select();
		return false;
	}	
}

/*******************************************************************************************************************
* 函數名稱: CheckStdYear																						       *	
* 功能說明: 檢查 學年度是否為『093』之格式																		   *
* 傳入參數: 1. sObj 為 text 欄位值			； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*							   *   
* 傳 回 值:   正確的學年度格式 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/23	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function CheckStdYear(sObj){
	var sStdYear = sObj.value;
	
	if (sStdYear.length<3 && sStdYear !="")
	{
		sStr = "0" + sStdYear
		sObj.value = sStr;
	}
	
	return true;
}


/*******************************************************************************************************************
* 函數名稱: ToRight_All																						       *	
* 功能說明: 將多重欄位的資料全部從左邊移轉到右邊																		   *
* 傳入參數: 1. sSource 為 左邊多重欄位值(來源資料)； 型態為 字串												   *   
*           2. sTarget  為 被移轉到的資料(目的資料)； 型態為 字串
* 傳 回 值:   左邊的資料全部移轉到右邊 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function ToRight_All(sSource,sTarget){
	var nNum;//照順序排序用
	var nTot;//判斷來源資料共有幾個

	nTot=sSource.length;
	nNum=0;
	for(i=0;i<nTot;i++){
		if(i-nNum>=0){
			oNewOption=document.createElement("OPTION");
			oNewOption.text=sSource.options[i-nNum].text;
			oNewOption.value=sSource.options[i-nNum].value;					
			AddItem(sTarget,oNewOption);
			DeleteItem(sSource,i-nNum);
			nNum=nNum+1;
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: ToLeft_All																						       *	
* 功能說明: 將多重欄位的資料全部從右邊移轉到左邊																		   *
* 傳入參數: 1. sSource 為 右邊多重欄位值(來源資料)； 型態為 字串												   *   
*           2. sTarget  為 被移轉到的資料(目的資料)； 型態為 字串
* 傳 回 值:   右邊的資料全部移轉到左邊 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function ToLeft_All(sSource,sTarget){
	var nNum;//照順序排序用
	var nTot;//照順序排序用
	nTot=sSource.length;
	nNum=0;
	for(i=0;i<nTot;i++){
		if(i-nNum>=0){
			oNewOption=document.createElement("OPTION");
			oNewOption.text=sSource.options[i-nNum].text;
			oNewOption.value=sSource.options[i-nNum].value;					
			AddItem(sTarget,oNewOption);
			DeleteItem(sSource,i-nNum);
			nNum=nNum+1;
		}
	}
}
/*******************************************************************************************************************
* 函數名稱: ToRight																						       *	
* 功能說明: 將多重欄位的資料左邊所選取的資料移轉到右邊																		   *
* 傳入參數: 1. sSource  為 左邊多重欄位值(來源資料)； 型態為 字串												   *   
*           2. sTarget  為 被移轉到的資料(目的資料)； 型態為 字串
* 傳 回 值:   左邊所選取的資料全部移轉到右邊 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function ToRight(sSource,sTarget){
	var nNum;//照順序排序用
	var nTot;//判斷來源資料共有幾個

	nTot=sSource.length;
	nNum=0;
	for(i=0;i<nTot;i++){
		if(i-nNum>=0){
			if (sSource.options[i-nNum].selected){
				oNewOption=document.createElement("OPTION");
				oNewOption.text=sSource.options[i-nNum].text;
				oNewOption.value=sSource.options[i-nNum].value;					
				AddItem(sTarget,oNewOption);
				DeleteItem(sSource,i-nNum);
				nNum=nNum+1;
			}
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: ToLeft																						       *	
* 功能說明: 將多重欄位的資料右邊所選取的資料移轉到左邊																		   *
* 傳入參數: 1. sSource  為 右邊多重欄位值(來源資料)； 型態為 字串												   *   
*           2. sTarget  為 被移轉到的資料(目的資料)； 型態為 字串
* 傳 回 值:   右邊所選取的資料全部移轉到左邊 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function ToLeft(sSource,sTarget){
	var nNum;//照順序排序用
	var nTot;//照順序排序用
	nTot=sSource.length;
	nNum=0;
	for(i=0;i<nTot;i++){
		if(i-nNum>=0){
			if (sSource.options[i-nNum].selected){
				oNewOption=document.createElement("OPTION");
				oNewOption.text=sSource.options[i-nNum].text;
				oNewOption.value=sSource.options[i-nNum].value;					
				AddItem(sTarget,oNewOption);
				DeleteItem(sSource,i-nNum);
				nNum=nNum+1;
			}
		}
	}
}
/*******************************************************************************************************************
* 函數名稱: AddItem																						       *	
* 功能說明: 新增項目資料到目的地的多重欄位																		   *
* 傳入參數: 1. nTheList 為 要新增的物件數值； 型態為 數值												   *   
*           2. nOpt  為 要新增的第幾個項目資料
* 傳 回 值:   將值傳回到目的地多重欄位																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function AddItem(nTheList,nOpt) {
	 nTheList.options.add(nOpt);
}
/*******************************************************************************************************************
* 函數名稱: DeleteItem																						       *	
* 功能說明: 將來源的多重欄位值做刪除動作																		   *
* 傳入參數: 1. nTheList 為 要刪除的物件項目值； 型態為 數值												   *   
*           2. nItemNo  為 要刪除的第幾個項目資料
* 傳 回 值:   無																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/27	 																                       *
* 更新人員:   王佳文																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

function DeleteItem(nTheList,nItemNo) {       
	 nTheList.options.remove(nItemNo);
}




/*******************************************************************************************************************
* 函數名稱: Auth_Lv																								　 *	
* 功能說明: 抓取權限使用																						   *
* 傳入參數:																							  		       *
*																												   *   
* 傳 回 值:					 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2004/12/28	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

	function Auth_Lv_old(SselectName,VarName,FunName) {
		
		var sXvalue;
		var sStr ;
		var nCount =document.all[SselectName].length ;
		if (VarName !="") {
			
			for (i = 0 ; i < nCount ; i++) {
			  if (VarName == document.all[SselectName].options[i].value) {
					document.all[SselectName].options[i].selected = true ;
					
					if (FunName !="") {					
						//str = funname + "('N','N','PKD_NO','PTE_NO')";
						
						//eval(str);
						
					}
					
					return true;
			  }
			}
		}
		return false;
	
	}
/*******************************************************************************************************************
* 函數名稱: MM_openBrWindow																						　 *	
* 功能說明: 開始新視窗 																							   *
* 傳入參數:																							  		       *
*																												   *   
* 傳 回 值:					 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2005/01/03	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/

	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
	


/*******************************************************************************************************************
* 函數名稱: New_win1																							   *	
* 功能說明: 另開新視窗																							   *
* 傳入參數: 1. sAdd_Url 為 開啟新視窗後，要連結的網頁名稱 ； 型態為 字串							  		       *
*			2. sWin_Name 為 新視窗的物件名稱     ； 型態為 字串	；如sWin_Name為空白字串，則預設視窗名稱為"printing"*   
*			3. sMove_X   為 新視窗的 X座標位置   ； 型態為 字串													   *
*			4. sMove_Y   為 新視窗的 Y座標位置   ； 型態為 字串													   *
*			5. sResize_X 為 新視窗的 寬度  ； 型態為 字串													 	   *
*			6. sResize_Y 為 新視窗的 高度   ； 型態為 字串													  	   *
* 傳 回 值:   無			 																                       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2005/1/4	 																                       	   *
* 更新人員:   劉哲偉																	                           *
*																						                           *
*																						                           *
*******************************************************************************************************************/

function New_win1(sAdd_Url,sWin_Name,sMove_X,sMove_Y,sResize_X,sResize_Y){



      sXpos= document.body.scrollLeft+event.screenX;

      sYpos = document.body.scrollTop+event.screenY;

      if (sWin_Name==""){ sWin_Name="printing";}

             sConf="resizable=no,scrollbars=no ";

             oNewprint=window.open(sAdd_Url,sWin_Name,sConf);

             oNewprint.focus();

             oNewprint.moveTo(sMove_X,sMove_Y);

             oNewprint.resizeTo(sResize_X,sResize_Y);

}


/*************************************************************************************************************************
* 函數名稱: Close_win																							         *	
* 功能說明: 關閉新開啟的視窗																					         *
* 傳入參數: 1. sIs_Show  為 關閉新視窗後，是否要顯示提示訊息 ； 型態為 字串；sIs_Show為"Y"，則顯示訊息，空白，則不秀訊息 *
*			2. sShow_Msg 為 要顯示的提示訊息     ； 型態為 字串															 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function Close_win(sIs_Show,sShow_Msg){
	oNewprint.close();
	if (sIs_Show =="Y") {
		alert(sShow_Msg);
	}
}



/*************************************************************************************************************************
* 函數名稱: Select_Text_Loc																							     *	
* 功能說明: 取物件資料(字串)(針對SELECT 物件)的左邊算起第一個字													         *
* 傳入參數: 1. sTxtname  為 放置 取出資料 的物件名稱(TEXT 物件) ； 型態為 字串											 *
*			2. oXobj 為 被取出資料的SELECT 物件   ； 型態為 物件														 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function Select_Text_Loc(sTxtname,oXobj) {
	//alert(sTxtname);
	var nSelect_length = oXobj.length;
	var sXdata="";
	
	sXdata = oXobj.options[oXobj.selectedIndex].text;
	
	//document.all[txtname].value = xdata.substr(4,1);
	document.all[sTxtname].value = sXdata.substr(0,1);
 	
}

function Select_Text_Loc_num(sTxtname,oXobj) {
	//alert(sTxtname);
	var nSelect_length = oXobj.length;
	var sXdata="";
	
	sXdata = oXobj.options[oXobj.selectedIndex].text;
	
	//document.all[txtname].value = xdata.substr(4,1);
	document.all[sTxtname].value = Number((sXdata.substr(0,1)).charCodeAt(0))-64;
 	
}


/*************************************************************************************************************************
* 函數名稱: CHECK_SEL_TEXT																							     *	
* 功能說明: 當條件成立時(針對SELECT 物件)，顯示或隱藏 某個物件													         *
* 傳入參數: 1. sSelobj  為 被驗證的物件名稱(SELECT 物件) ； 型態為 字串													 *
*			2. sTxtobj_clen 為 當條件成立時，顯示或隱藏 的物件名稱； 型態為 物件										 *   
*			3. sSelvalue1、sSelvalue2、sSelvalue3 為 條件成立時，的條件資料； 型態為 物件								 *  
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function CHECK_SEL_TEXT(sSelobj,sTxtobj_clen,sTxtobj_clen_text_color,sSelvalue1,sSelvalue2,sSelvalue3,sSelvalue4,sTxtobj_date_text_color,sDateobj){

	var sSelname="";
	
	sSelname = document.form1.elements[sSelobj].options[document.form1.elements[sSelobj].selectedIndex].value;

	 if (sSelname==sSelvalue1 || sSelname==sSelvalue2 || sSelname==sSelvalue3) {
		document.form1.elements[sTxtobj_clen].value="";
		document.form1.elements[sTxtobj_clen].disabled=true;
		document.all[sTxtobj_clen_text_color].style.color = "black";
	 } else {
	 	//document.form1.elements[txtobj_clen].value="";
		document.form1.elements[sTxtobj_clen].disabled=false;
		document.all[sTxtobj_clen_text_color].style.color = "red";
	 }
	 
	 if (sSelvalue4 != null)
	 {
		 if (sSelname==sSelvalue4)
		 {
			document.all[sTxtobj_date_text_color].style.color = "red";
			document.form1.elements[sDateobj].disabled=false;
		 }else{
			document.all[sTxtobj_date_text_color].style.color = "black";
			document.form1.elements[sDateobj].disabled=true;
		 }
	 }
}


/*************************************************************************************************************************
* 函數名稱: SetCheckValue																							     *	
* 功能說明: 當條件成立時(針對CHECKBOX 物件)，勾選CHECKBOX 物件													         *
* 傳入參數: 1. sSetTxtName  為 被驗證的物件名稱(CHECKBOX 物件) ； 型態為 字串											 *
*			2. sOrgTxtName 為 當條件成立時，要勾選CHECKBOX 物件名稱； 型態為 字串										 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function SetCheckValue(sSetTxtName,sOrgTxtName){	
	var nForm_count;
	var sOrgvalue;
		
	//alert(document.all[orgtxtname].value);
	
	sOrgvalue = document.all[sOrgTxtName].checked;
	
	nForm_count = 0 ;
	
	/*算元件數*/
	for (i=1;i<=document.form1.length-1;i++) {
		
		nX_name = document.form1.elements[i].name.indexOf(sSetTxtName) ; 
		if (parseFloat(nX_name) != -1 ){
			nForm_count = nForm_count + 1 ;
		}
		
		
	}
	
	
	for (i=1;i<=nForm_count;i++) {	 
		document.all[sSetTxtName +"(" + i + ")"].checked = sOrgvalue ;	
	}
	
	
}



/*************************************************************************************************************************
* 函數名稱: SetCheckValueClean																							     *	
* 功能說明: 當條件成立時(針對CHECKBOX 物件)，勾選CHECKBOX 物件(sOrgTxtName 物件)													         *
* 傳入參數: 1. sSetTxtName  為 被驗證的物件名稱(CHECKBOX 物件) ； 型態為 字串											 *
*			2. sOrgTxtName 為 當條件成立時，要勾選CHECKBOX 物件名稱； 型態為 字串										 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/11 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function SetCheckValueClean(sSetTxtName,sOrgTxtName,sFormName){	
	var nForm_count;
	var sOrgvalue;
	var sCheck;
		
	//alert(document.all[orgtxtname].value);
	
	//sOrgvalue = document.all[sOrgTxtName].checked;
	
	nForm_count = 0 ;
	
	/*算元件數*/
	for (i=1;i<=document.form1.length-1;i++) {
		
		nX_name = document.form1.elements[i].name.indexOf(sSetTxtName) ; 
		if (parseFloat(nX_name) != -1 ){
			nForm_count = nForm_count + 1 ;
		}
		
		
	}
	
	sCheck ="";
	
	for (i=1;i<=nForm_count;i++) {	 
		if (document.all[sSetTxtName +"(" + i + ")"].checked==false){
			sCheck= "NOALL" ;
		}
		
	}
	
	
	if (sCheck=="NOALL") {
		document.all[sOrgTxtName].checked =false ;
	} else {
		document.all[sOrgTxtName].checked = true;
	}
	
	
}




/*************************************************************************************************************************
* 函數名稱: SelectValue																							    	 *	
* 功能說明: 將所選取的 SELECT 物件 的值，放入某個 TEXT 物件												        		 *
* 傳入參數: 1. sTxtname  為 被放入的物件名稱(TEXT 物件) ； 型態為 字串													 *
*			2. sXobj 	為 被取出的 SELECT 物件名稱； 型態為 字串														 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/
function SelectValue(sTxtname,sXobj) {
	//alert("aa");
	var sSelect_length =document.all[sXobj].length;
	var sXdata = document.all[sXobj].options[document.all[sXobj].selectedIndex].value;
	
	document.all[sTxtname].value = sXdata;
	
}
/*************************************************************************************************************************
* 函數名稱: locke_table_view																		    	             *	
* 功能說明: 將所選取的那一列變顏色                    												        		     *
* 傳入參數: 1. func_obj  為 指定物件 ； 型態為 字串													                     *
*			2. func_color 	為 表格顏色； 型態為 字串														             *   
*			3. func_over 	為 滑鼠OVER顏色； 型態為 字串														         *   
*			4. func_down 	為 滑鼠DOWN顏色； 型態為 字串														         *   
*			5. func_type 	為 類別{在上:over , 按下:down , 移出:out}； 型態為 字串										 *   
* 傳 回 值:   無			 																                       		 *
* 開發部門:   資訊管理中心																	                      		 *
* 更新日期:   2005/1/4	 																                       	  		 *
* 更新人員:   劉哲偉																	                          		 *
*																						                          		 *
*																						                         		 *
*************************************************************************************************************************/

function locke_table_view( func_obj , func_color , func_over , func_down , func_type ){
//author : locke_ad@yahoo.com.tw
	//滑鼠事件的變色函數  locke_table_view( 指定物件, 表格顏色 , 滑鼠在上的顏色 , 滑鼠按下後顏色 , 類別{在上:over , 按下:down , 移出:out} )
	if ( !func_obj['be_check'] ){func_obj['be_check'] = 0;}
	//be_check用來檢查有無按下滑鼠用的。
	if ( !func_obj['style'] ){
			document.write('func_obj.id');
			return;
		}	
	if ( !func_obj.be_check ){
		//當未按下時
		if ( func_type == 'down' ){
				func_obj.style.backgroundColor=func_down;
				func_obj.be_check=1;
			}
		if ( func_type =='over' ){
				func_obj.style.backgroundColor=func_over;
			}
		if ( func_type == 'out' ){
				func_obj.style.backgroundColor=func_color;
			}
	}else{
		//已有按下後
		if ( func_type == 'down' ){
			func_obj.style.backgroundColor=func_color;
			func_obj.be_check=0;
		}
	}
}
/*******************************************************************************************************************
* 函數名稱: MoveDown																						       *	
* 功能說明: 將下邊資料在多重欄位中向下移動																		   *
* 傳入參數: 1. sLoc  為 下邊資料； 型態為 字串																	   *   
* 傳 回 值:									 																       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2005/03/01	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
********************************************************************************************************************/
function MoveDown1(sLoc){
	sIndx = sLoc.selectedIndex;			//原第幾筆

	if (sIndx != -1){
		if (sIndx < sLoc.length - 1){
			var sTxt = sLoc.options[sIndx].text;//顯示資料
			var sVal = sLoc.options[sIndx].value;//傳值資料

			sLoc.options[sIndx].text = sLoc.options[sIndx+1].text;
			sLoc.options[sIndx].value = sLoc.options[sIndx+1].value;
			sLoc.options[sIndx+1].text = sTxt;
			sLoc.options[sIndx+1].value = sVal;
			sLoc.selectedIndex++;//setfocus~~
		}
	}
	return false;
}
/*******************************************************************************************************************
* 函數名稱: MoveUp																						       *	
* 功能說明: 將下邊資料在多重欄位中向上移動																		   *
* 傳入參數: 1. sLoc  為 下邊資料； 型態為 字串																	   *   
* 傳 回 值:									 																       *
* 開發部門:   資訊管理中心																	                       *
* 更新日期:   2005/03/02	 																                       *
* 更新人員:   林靖燕																	                           *
*																						                           *
*																						                           *
********************************************************************************************************************/
function MoveUp1(sLoc){

	sIndx = sLoc.selectedIndex;			//原第幾筆

	if (sIndx != -1){
		if (sIndx > 0){
			var sTxt = sLoc.options[sIndx].text;//顯示資料
			var sVal = sLoc.options[sIndx].value;
			
			sLoc.options[sIndx].text = sLoc.options[sIndx-1].text;
			sLoc.options[sIndx].value = sLoc.options[sIndx-1].value;
			sLoc.options[sIndx-1].text = sTxt;
			sLoc.options[sIndx-1].value = sVal;
			sLoc.selectedIndex--;
		}
	}
	return false;
}