/****************************************************************
程式用途：Script Library
開發者：Eddie
開發日期：91/2/20 下午 03:02:13
更新日期：2002/6/7 上午 10:06:52(6)
使用方法：
注意事項：
****************************************************************/

/*********************************************************
	● 檢查表單物件
	物件名稱：CheckForm
	使用方法：CheckForm(arg1)
	傳遞引數：
				arg1：選擇項。表單物件名稱，必須為文字型態。
	函數：checkID(),checkEmail()
**********************************************************/
function CheckForm(formObj)
{
	if (typeof(formObj) == "object")
	{
		this.formObj = formObj.elements;
	}
	else if (typeof(document.forms[formObj]) == "object")
	{
		this.formObj = document.forms[formObj].elements;
	}
	else
	{
		this.formObj = document.all;
	}
}
   
	/**************************************************************
	   檢查表單物件 [ 檢查身份證字號函數 ] 
	   函數名稱：checkID
	   函數類型：Public
	   使用方法：objName.checkID(arg1,arg2)
	   傳遞引數：
	          objName：必要項。所引用的objName必須為檢查表單物件。
	             arg1：必要項。身份證字號欄位名稱，必須為文字型態。
	             arg2：選擇項。欄位是否可重覆，0=不重覆,1=重覆，預設為不可重覆。
	***************************************************************/
	CheckForm.prototype.checkID = function (id,flag)
	{

		var Num = new Array(11); 
		var thisobj;

		try
		{
			var obj=this.formObj(id);
	        if( obj.length > 1 && (flag==0 || typeof(flag) != "number"))
			{
				e = new Error(1, "請檢查身分證字號欄位 - 欄位名稱 [ " + id + " ] 是否重複 !!");
	  			throw e;
			}
		}
		catch(e)
		{
			if(e.number != 1)
			{
				e.description = "請檢查身分證字號欄位 - 欄位名稱 [ " + id + " ] 是否存在 !!";
			}
			
			alert(e.description);
			return false;
		}
		if (typeof(obj.length) != "number")
		{
			obj.length=1;
		}

		for(var z=0; z < obj.length ; z++)
		{
			if (obj.length == 1)
			{
				thisobj=obj ;
			}
			else
			{
				thisobj=obj[z] ;
			}

			if (thisobj.value.length == 0)
			{

				alert ("請檢查身分證字號欄位 - 尚未輸入身份證字號  ")
				thisobj.focus();
				return false;
			}

			if (thisobj.value.length != 10)
			{
				alert ("請檢查身分證字號欄位 - 輸入之身份證字號的欄位個數錯誤  ")
				thisobj.focus();
				return false;
			}
     

			Num[0] = thisobj.value.charCodeAt(0);
			if ((parseInt(Num[0]) < 65) || (parseInt(Num[0]) > 122))
			{
				alert("請檢查身分證字號欄位 - 身份證字號第一個字必須是英文字母  ")
				thisobj.focus();
				return false;
			}
	
			Num[0] = thisobj.value.charAt(0);
			if ((Num[0] == "A") || (Num[0] == "a")) { Num[0]=1; Num[1] = 0;}
			if ((Num[0] == "B") || (Num[0] == "b")) { Num[0]=1; Num[1] = 1;}
			if ((Num[0] == "C") || (Num[0] == "c")) { Num[0]=1; Num[1] = 2;}
			if ((Num[0] == "D") || (Num[0] == "d")) { Num[0]=1; Num[1] = 3;}
			if ((Num[0] == "E") || (Num[0] == "e")) { Num[0]=1; Num[1] = 4;}
			if ((Num[0] == "F") || (Num[0] == "f")) { Num[0]=1; Num[1] = 5;}
			if ((Num[0] == "G") || (Num[0] == "g")) { Num[0]=1; Num[1] = 6;}
			if ((Num[0] == "H") || (Num[0] == "h")) { Num[0]=1; Num[1] = 7;}
			if ((Num[0] == "I") || (Num[0] == "i")) { Num[0]=3; Num[1] = 4;} 
			if ((Num[0] == "J") || (Num[0] == "j")) { Num[0]=1; Num[1] = 8;}
			if ((Num[0] == "K") || (Num[0] == "k")) { Num[0]=1; Num[1] = 9;}
			if ((Num[0] == "L") || (Num[0] == "l")) { Num[0]=2; Num[1] = 0;}
			if ((Num[0] == "M") || (Num[0] == "m")) { Num[0]=2; Num[1] = 1;}
			if ((Num[0] == "N") || (Num[0] == "n")) { Num[0]=2; Num[1] = 2;}
			if ((Num[0] == "O") || (Num[0] == "o")) { Num[0]=3; Num[1] = 5;} 
			if ((Num[0] == "P") || (Num[0] == "p")) { Num[0]=2; Num[1] = 3;}
			if ((Num[0] == "Q") || (Num[0] == "q")) { Num[0]=2; Num[1] = 4;}
			if ((Num[0] == "R") || (Num[0] == "r")) { Num[0]=2; Num[1] = 5;}
			if ((Num[0] == "S") || (Num[0] == "s")) { Num[0]=2; Num[1] = 6;}
			if ((Num[0] == "T") || (Num[0] == "t")) { Num[0]=2; Num[1] = 7;}
			if ((Num[0] == "U") || (Num[0] == "u")) { Num[0]=2; Num[1] = 8;}
			if ((Num[0] == "V") || (Num[0] == "v")) { Num[0]=2; Num[1] = 9;}
			if ((Num[0] == "W") || (Num[0] == "w")) { Num[0]=3; Num[1] = 2;}
			if ((Num[0] == "X") || (Num[0] == "x")) { Num[0]=3; Num[1] = 0;}
			if ((Num[0] == "Y") || (Num[0] == "y")) { Num[0]=3; Num[1] = 1;}
			if ((Num[0] == "Z") || (Num[0] == "z")) { Num[0]=3; Num[1] = 3;}
			  
			for (i=2;i < 11;i++) 
			{
				Num[i] = thisobj.value.charAt(i-1);
				if (isNaN(Num[i]))
				{
					alert("請檢查身分證字號欄位 - 第" + i + "欄位不是數字　")
					thisobj.focus();
					return false;
				}
			}       
	
			var out = eval(Num[0]) + eval(Num[1])*9 + eval(Num[2])*8 + eval(Num[3])*7 + 
					  eval(Num[4])*6 + eval(Num[5])*5 + eval(Num[6])*4 + eval(Num[7])*3 + 
					  eval(Num[8])*2 + eval(Num[9]) + eval(Num[10]); 
					        
			out = out % 10;
	
			if (out != 0)
			{
				alert("請檢查身分證字號欄位 - 不合法的身份證字號  ")
				thisobj.focus();
				return false;
			}
		}
	
		return true;
	}
	
	/**************************************************************
	   檢查表單物件 [ 檢查統一編號函數 ] 
	   函數名稱：checkSID
	   函數類型：Public
	   使用方法：objName.checkSID(arg1,arg2)
	   傳遞引數：
	          objName：必要項。所引用的objName必須為檢查表單物件。
	             arg1：必要項。身份證字號欄位名稱，必須為文字型態。
	             arg2：選擇項。欄位是否可重覆，0=不重覆,1=重覆，預設為不可重覆。
	***************************************************************/
	CheckForm.prototype.checkSID = function (id,flag)
	{

		var Num = new Array(11); 
		var thisobj;

		try
		{
			var obj=this.formObj(id);
	        if( obj.length > 1 && (flag==0 || typeof(flag) != "number"))
			{
				e = new Error(1, "請檢查統一編號欄位 - 欄位名稱 [ " + id + " ] 是否重複 !!");
	  			throw e;
			}
		}
		catch(e)
		{
			if(e.number != 1)
			{
				e.description = "請檢查統一編號欄位 - 欄位名稱 [ " + id + " ] 是否存在 !!";
			}
			
			alert(e.description);
			return false;
		}
		if (typeof(obj.length) != "number")
		{
			obj.length=1;
		}

		for(var z=0; z < obj.length ; z++)
		{
			if (obj.length == 1)
			{
				thisobj=obj ;
			}
			else
			{
				thisobj=obj[z] ;
			}

			if (thisobj.value.length == 0)
			{

				alert ("請檢查統一編號欄位 - 尚未輸入統一編號  ")
				thisobj.focus();
				return false;
			}

			if (thisobj.value.length != 8)
			{
				alert ("請檢查統一編號欄位 - 輸入之統一編號的欄位個數錯誤  ")
				thisobj.focus();
				return false;
			}
     
			if (!this.checkIsNum(id))
			{
				thisobj.focus();
				return false;
			}

			var Num = new Array(1,2,1,2,1,2,4,1);
			var strSID = "";
			var numSID = 0;
			for (var zz = 0 ; zz < thisobj.value.length ; zz++)
			{
				strSID += String(Number(thisobj.value.substring(zz,zz+1)) * Num[zz]);
			}

			for (var zz = 0 ; zz < strSID.length ; zz++)
			{
				numSID += Number(strSID.substring(zz,zz+1));
			}

			if((numSID % 10) != 0)
			{
				alert("請檢查統一編號欄位 - 不合法的統一編號  ")
				thisobj.focus();
				return false;
			}
		}
	
		return true;
	}

	/***********************************************************
		檢查表單物件 [ 檢查電子郵件函數 ] 
		函數名稱：checkEmail
		函數類型：Public
		使用方法：objName.checkEmail(arg1,arg2)
		傳遞引數：
					objName：必要項。所引用的objName必須為檢查表單物件。
					arg1：必要項。電子郵件欄位名稱,必須為文字型態。
					arg2：選擇項。欄位是否可重覆，1=重覆，預設為不可重覆。
	************************************************************/
	CheckForm.prototype.checkEmail = function (email,flag)
	{
			var obj=this.formObj(email)
			var thisobj;

			try {

					if( obj.length > 1  && (flag==0 || typeof(flag) != "number"))
					{
						var e = new Error(1,"請檢查電子郵件欄位 - 欄位名稱 [ " + email + " ] 是否重複 !!")
		                throw e;
					}
			}
			catch(e){

       			if (e.number != 1 )
				{
					e.description="請檢查電子郵件欄位 - 欄位名稱 [ " + email + " ] 是否存在 !!"
		        } 
				alert(e.description)
				return false;
			}


			if (typeof(obj.length) != "number")
			{
				obj.length=1;
			}

			for(var z=0; z < obj.length ; z++)
			{
				if (obj.length == 1)
				{
					thisobj=obj ;
				}
				else
				{
					thisobj=obj[z] ;
				}
	
				if (thisobj.value.length==0 )
				{
					alert("請檢查電子郵件欄位 - 尚未輸入電子郵件  ");
					thisobj.focus();
					return false;
				}

				if (thisobj.value.indexOf("@") < 0 )
				{
					alert("請檢查電子郵件欄位 - 不正確的電子郵件格式  ");
					obj.focus();
					return false;
				}

				if (thisobj.value.indexOf(".",thisobj.value.indexOf("@")) < 0 )
				{
					alert("請檢查電子郵件欄位 - 不正確的電子郵件格式  ");
					thisobj.focus();
					return false;
				}

				if (thisobj.value.indexOf(".",thisobj.value.indexOf("@"))+1 == thisobj.value.length)
				{
					alert("請檢查電子郵件欄位 - 不正確的電子郵件格式  ");
					thisobj.focus();
					return false;
				}
			}
			return true;
	}


	/***********************************************************
		檢查表單物件 [ 檢查欄位是否為未輸入資料 ] 
		函數名稱：checkIsEmpty
		函數類型：Public
		使用方法：objName.checkIsEmpty(arg1,arg2)
		傳遞引數：
					objName：必要項。所引用的objName必須為檢查表單物件。
					arg1：必要項。任意欄位名稱,必須為文字型態。
					arg2：選擇項。欄位是否可重覆，1=重覆，預設為不可重覆。
	************************************************************/
	CheckForm.prototype.checkIsEmpty = function (IsEmpty,flag) {

		var obj=this.formObj(IsEmpty)
		var thisTitle = "";
		var thisobj;
		try
		{
			if (obj.tagName != "SELECT")
			{
				if( obj.length > 1  && (flag==0 || typeof(flag) != "number"))
				{
					var e = new Error(1,"請檢查此欄位 - 欄位名稱 [ " + IsEmpty + " ] 是否重複 !!")
					throw e;
				}
			}			
		}
		catch(e)
		{

			if (e.number!=1)
			{
				e.description="請檢查此欄位 - 欄位名稱 [ " + IsEmpty + " ] 是否存在 !!"
			} 
			alert(e.description)
			return false;
		}

		if (obj.tagName != "SELECT")
		{
			if (typeof(obj.length) != "number")
			{
				obj.length=1;
			}

			for(var z=0; z < obj.length ; z++)
			{
				if (obj.length == 1)
				{
					thisobj=obj ;
				}
				else
				{
					thisobj=obj[z] ;
				}

				if (thisobj.title=="") thisTitle = IsEmpty ;else thisTitle = thisobj.title;
	
				if (thisobj.value.length==0)
				{
					alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未輸入任何資料 !!")
					thisobj.focus()
					return false;
				}
			}
			return true;
		}
		else
		{
			if (obj.title=="") thisTitle = IsEmpty ;else thisTitle = obj.title;
			if (obj.value.length==0)
			{
				alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料 !!")
				obj.focus()
				return false;
			}
			return true;
		}

	}


	/***********************************************************
	檢查表單物件 [ 檢查欄位是否只輸入數字資料 ] 
	函數名稱：checkIsNum
	函數類型：Public
	使用方法：objName.checkIsNum(arg1,arg2)
	傳遞引數：
				objName：必要項。所引用的objName必須為檢查表單物件。
				arg1：必要項。任意欄位名稱,必須為文字型態。
				arg2：選擇項。欄位是否可重覆，1=重覆，預設為不可重覆。
	************************************************************/
	CheckForm.prototype.checkIsNum = function (IsNum,flag)
	{

		var obj=this.formObj(IsNum)
		var thisTitle = "";
		var thisobj;

		try {

			if( obj.length > 1 && (flag==0 || typeof(flag) != "number"))
			{
				var e = Error(1,"請檢查此欄位 - 欄位名稱 [ " + IsNum + " ] 是否重複 !!")
	  			throw e;
			}
		}
		catch(e){
			if (e.number != 1)
			{
				e.description="請檢查此欄位 - 欄位名稱 [ " + IsNum + " ] 是否存在 !!"
			} 
			alert(e.description)
			return false;
		}

		if (typeof(obj.length) != "number") obj.length=1;

		for(var z=0; z < obj.length ; z++)
		{
			if (obj.length == 1)
			{
				thisobj=obj ;
			}
			else
			{
				thisobj=obj[z] ;
			}

			if (thisobj.title=="") thisTitle = IsNum ;else thisTitle = thisobj.title;

			if (thisobj.value.length == 0)
			{
				alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未輸入任何資料  ")
				thisobj.focus();
				return false;
			}

			if (isNaN(thisobj.value))
			{
				alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 此欄位只允許輸入數字資料  ")
				thisobj.focus();
				return false;
			}
		}
		return true;
	}

	/*********************************************************************
	檢查表單物件 [ 檢查日期範圍函數 ] 
	函數名稱：checkDateRange
	函數類型：Public
	使用方法：objName.checkDateRange(arg1,arg2,arg3,arg4,arg5,arg6)
	傳遞引數：
				objName：必要項。所引用的objName必須為檢查表單物件。
				arg1：必要項。啟始日期 [ 年 ] 欄位名稱,必須為文字型態。
				arg2：必要項。啟始日期 [ 月 ] 欄位名稱,必須為文字型態。
				arg3：必要項。啟始日期 [ 日 ] 欄位名稱,必須為文字型態。
				arg4：必要項。結束日期 [ 年 ] 欄位名稱,必須為文字型態。
				arg5：必要項。結束日期 [ 月 ] 欄位名稱,必須為文字型態。
				arg6：必要項。結束日期 [ 日 ] 欄位名稱,必須為文字型態。
	*********************************************************************/
	CheckForm.prototype.checkDateRange=function (startYearName,startMonthName,startDayName,endYearName,endMonthName,endDayName) {

		try {

			var s_yearObj = this.formObj(startYearName);
			var s_monthObj = this.formObj(startMonthName);
			var s_dayObj = this.formObj(startDayName);
			var e_yearObj = this.formObj(endYearName);
			var e_monthObj = this.formObj(endMonthName);
			var e_dayObj = this.formObj(endDayName);
			var thisTitle = "";

			try
			{
					s_yearObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + startYearName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				s_monthObj.length += 0;
			}
			catch (e)
			{ 
				throw "請檢查此欄位 - 欄位名稱 [ " + startMonthName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				s_dayObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + startDayName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				e_yearObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + endYearName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				e_monthObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + endMonthName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				e_dayObj.length += 0; 
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + endDayName + " ] 是否重覆使用或不存在 !!";
			}

		}
		catch(e)
		{

			alert(e);
			return false;

		}

		if (s_yearObj.title=="") thisTitle = startYearName ;else thisTitle = s_yearObj.title;
		if (s_yearObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ;
			s_yearObj.focus();
			return false;
		}
		if (s_monthObj.title=="") thisTitle = startMonthName ;else thisTitle = s_monthObj.title;
		if (s_monthObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ")  ;
			s_monthObj.focus() ;
			return false;
		}
		if (s_dayObj.title=="") thisTitle = startDayName ;else thisTitle = s_dayObj.title;
		if (s_dayObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ; 
			s_dayObj.focus() ; 
			return false; 
		}
		if (e_yearObj.title=="") thisTitle = endYearName ;else thisTitle = e_yearObj.title;
		if (e_yearObj.value.length==0)
		{ 
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ; 
			e_yearObj.focus() ; 
			return false; 
		}
		if (e_monthObj.title=="") thisTitle = endMonthName ;else thisTitle = e_monthObj.title;
		if (e_monthObj.value.length==0)
		{ 
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ; 
			e_monthObj.focus() ; 
			return false; 
		}
		if (e_dayObj.title=="") thisTitle = endDayName ;else thisTitle = e_dayObj.title;
		if (e_dayObj.value.length==0)
		{ 
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ; 
			e_dayObj.focus() ; 
			return false; 
		}
 
		var startVal= new Date(s_yearObj.value,s_monthObj.value,s_dayObj.value)
		var endVal= new Date(e_yearObj.value,e_monthObj.value,e_dayObj.value)

		if (startVal > endVal) 
		{
			alert("啟始日期大於結束日期，請重新選擇日期。");
			s_yearObj.focus();
			return false;
		}

		return true;
	}

	/*********************************************************************
	檢查表單物件 [ 檢查日期函數 ] 
	函數名稱：checkDate
	函數類型：Public
	使用方法：objName.checkDate(arg1,arg2,arg3)
	傳遞引數：
				objName：必要項。所引用的objName必須為檢查表單物件。
				arg1：必要項。啟始日期 [ 年 ] 欄位名稱,必須為文字型態。
				arg2：必要項。啟始日期 [ 月 ] 欄位名稱,必須為文字型態。
				arg3：必要項。啟始日期 [ 日 ] 欄位名稱,必須為文字型態。
				arg4：必要項。結束日期 [ 年 ] 欄位名稱,必須為文字型態。
				arg5：必要項。結束日期 [ 月 ] 欄位名稱,必須為文字型態。
				arg6：必要項。結束日期 [ 日 ] 欄位名稱,必須為文字型態。
	*********************************************************************/
	CheckForm.prototype.checkDate=function (startYearName,startMonthName,startDayName) {

		try {

			var s_yearObj = this.formObj(startYearName);
			var s_monthObj = this.formObj(startMonthName);
			var s_dayObj = this.formObj(startDayName);

			try
			{
					s_yearObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + startYearName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				s_monthObj.length += 0;
			}
			catch (e)
			{ 
				throw "請檢查此欄位 - 欄位名稱 [ " + startMonthName + " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				s_dayObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + startDayName + " ] 是否重覆使用或不存在 !!";
			}


		}
		catch(e)
		{

			alert(e);
			return false;

		}
 
		if (s_yearObj.title=="") thisTitle = startYearName ;else thisTitle = s_yearObj.title;
		if (s_yearObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ;
			s_yearObj.focus();
			return false;
		}
		if (s_monthObj.title=="") thisTitle = startMonthName ;else thisTitle = s_monthObj.title;
		if (s_monthObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ")  ;
			s_monthObj.focus() ;
			return false;
		}
		if (s_dayObj.title=="") thisTitle = startDayName ;else thisTitle = s_dayObj.title;
		if (s_dayObj.value.length==0)
		{
			alert("請檢查此欄位 - 欄位名稱 [ " + thisTitle + " ] 尚未選擇任何資料  ") ; 
			s_dayObj.focus() ; 
			return false; 
		}
		return true;
	}

/*************************************************************************************
	● 設定日期物件
	物件名稱：DateSerial
	使用方法：DateSerial(arg1,arg2,arg3,arg4)
	傳遞引數：
				arg1：必要項。日期物件之作用目標名稱,必須為<span>或<div>,必須為文字型態。
				arg2：必要項。年份欄位名稱,必須為文字型態。
				arg3：必要項。月份欄位名稱,必須為文字型態。
				arg4：必要項。日期欄位名稱,必須為文字型態。
	函數：setYearPeriod(),writeHTML()
*************************************************************************************/
var startYear;
var endYear;

function DateSerial(span_obj,year_obj,month_obj,day_obj){

	try {

		if (typeof(span_obj) != "string" || typeof(year_obj) != "string" || typeof(month_obj) != "string" || typeof(day_obj) != "string" )
		{
			throw "欄位引數錯誤，請檢查引數數目及型態是否正確！";
		}

		var obj=document.all(span_obj);

		try
		{
			obj.length += 0;
		}
		catch (e)
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj  + " ] 是否存在 !!";
		}

		if( obj.length > 1 )
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj + " ] 是否重複 !!"
		}

	}
	catch(e)
	{

		alert(e)
		return false;
	}

	var thisYear=new Date();

	this.startYear=1900;
	this.endYear = thisYear.getYear();
	this.span_obj=span_obj;
	this.year_obj=year_obj;
	this.month_obj=month_obj;
	this.day_obj=day_obj;
	startYear=this.startYear;
	endYear=this.endYear;
}

	/****************************************************************
		設定日期物件 [ 設定日期物件啟始年份及結束年份 ] 
		函數名稱：setYearPeriod
		函數類型：Public
		使用方法：objName.setYearPeriod(arg1,arg2)
		傳遞引數：
					objName：必要項。所引用的objName必須為設定日期物件。
					arg1：必要項。起始年份,必須為數值型態。
					arg2：必要項。結束年份,必須為數值型態。
	*****************************************************************/

	DateSerial.prototype.setYearPeriod = function(startYear,endYear){

		var thisYear=new Date();

		if( typeof(startYear) != "number" || startYear < 1900  )
		{
			this.startYear = 1900;
		}
		else
		{
			this.startYear = startYear;
		}

		if ( typeof(endYear) != "number" || endYear < 1900 )
		{
			this.endYear = thisYear.getYear();
		}
		else
		{
			this.endYear=endYear;
		}

		if (this.startYear > this.endYear)
		{
			this.startYear = 1900;
		}
	}
	
	/****************************************************************
		設定日期物件 [ 設定 ** 民國 **日期物件啟始年份及結束年份] 
		函數名稱：setYearPeriod2
		函數類型：Public
		使用方法：objName.setYearPeriod(arg1,arg2)
		傳遞引數：
					objName：必要項。所引用的objName必須為設定日期物件。
					arg1：必要項。起始年份,必須為數值型態。
					arg2：必要項。結束年份,必須為數值型態。
	*****************************************************************/

	DateSerial.prototype.setYearPeriod2 = function(startYear,endYear){
		
		var thisYear=new Date()-1911;
		//var thisYear=new Date();
		

		if( typeof(startYear) != "number" || startYear < 80  )
		{
			this.startYear = 80;
		}
		else
		{
			this.startYear = startYear;
		}

		if ( typeof(endYear) != "number" || endYear < 80 )
		{
			this.endYear = thisYear.getYear();
		}
		else
		{
			this.endYear=endYear;
		}

		if (this.startYear > this.endYear)
		{
			this.startYear = 80;
		}
	}


	/****************************************************************
		設定日期物件 [ 將日期物件置於作用目標 ] 
		函數名稱：writeHTML
		函數類型：Public
		使用方法：writeHTML()
		傳遞引數：無
	*****************************************************************/
	DateSerial.prototype.writeHTML = function ()
	{

		var innerStr="";
		innerStr = innerStr + "<select title='年' name='" + this.year_obj + "' onchange=" + "setDateVal(" + this.startYear + "," + this.endYear + ",'" + this.year_obj + "','" + this.month_obj + "','" + this.day_obj + "');" + " style='font:9pt'></select>"
		innerStr = innerStr + "<select title='月' name='" + this.month_obj + "' onchange=" + "setDateVal(" + this.startYear + "," + this.endYear + ",'" + this.year_obj + "','" + this.month_obj + "','" + this.day_obj + "');" + " style='font:9pt'></select>"
		innerStr = innerStr + "<select title='日' name='" + this.day_obj + "' style='font:9pt'></select>"

		if(typeof(this.span_obj)=="string")
		{
			document.all(this.span_obj).innerHTML=innerStr;
			setDateVal(this.startYear,this.endYear,this.year_obj,this.month_obj,this.day_obj);
		}
	}

	/****************************************************************
		設定日期物件 [ 設定日期函數 ] 
		函數名稱：setDateVal
		函數類型：Private
		使用方法：setDateVal(arg1,arg2,arg3,arg4,arg5)
		傳遞引數：
					objName：必要項。所引用的objName必須為設定日期物件。
					arg1：必要項。起始年份,必須為數字型態。
					arg2：必要項。結束年份,必須為數字型態。
					arg3：必要項。年份欄位名稱,必須為文字型態。
					arg4：必要項。月份欄位名稱,必須為文字型態。
					arg5：必要項。日期欄位名稱,必須為文字型態。
	*****************************************************************/
	function setDateVal(startYear,endYear,yearName,monthName,dayName)
	{

		try
		{

			var yearObj = document.all(yearName);
			var monthObj = document.all(monthName);
			var dayObj = document.all(dayName);

			try
			{
				yearObj.length += 0;
			}
			catch (e)
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + yearName +  " ] 是否重覆使用或不存在 !!";
			}

			try
			{
				monthObj.length += 0; 
			} 
			catch (e) 
			{ 
				throw "請檢查此欄位 - 欄位名稱 [ " + monthName +  " ] 是否重覆使用或不存在 !!";
			}

			try 
			{
				dayObj.length += 0; 
			} 
			catch (e) 
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + dayName +  " ] 是否重覆使用或不存在 !!";
			}
		}
		catch(e)
		{
			alert(e);
			return false;
		}

		//*********** 填入年份 *******************
		if (yearObj.length==0) 
		{
			yearObj.length=(endYear-startYear)+2;
			yearObj.options[0].value = "" ;
			yearObj.options[0].text = "年" ;
			for (var i=startYear ; i <= endYear ; i++)
			{
				yearObj.options[i-startYear+1].value = i;
				yearObj.options[i-startYear+1].text = i;
			}
		}
  
		//*********** 填入月份 *******************
		if (monthObj.length==0) 
		{
			monthObj.length=13;
			monthObj.options[0].value = "" ;
			monthObj.options[0].text = "月" ;
			for (var i=1 ; i < monthObj.length ; i++)
			{
				monthObj.options[i].value = i;
				monthObj.options[i].text = i;
			}
		}
  
		//*********** 填入日期 ******************
		if (dayObj.length==0) 
		{
			var dat =new Date(yearObj.options[1].value,monthObj.options[1].value,0)  
			dayObj.length=dat.getDate()+1;
		}
		else
		{
			var dat =new Date(yearObj.options[yearObj.selectedIndex].value,monthObj.options[monthObj.selectedIndex].value,0)  
			dayObj.length=dat.getDate()+1;
		}
		dayObj.options[0].value = "" ;
		dayObj.options[0].text = "日" ;
		for (var i=1 ; i < dayObj.length ; i++)
		{
			dayObj.options[i].value = i;
			dayObj.options[i].text = i;
		}
  
	}


/********************************************************************
	● 設定地址物件
	物件名稱：AddressSerial
	使用方法：AddressSerial(arg1,arg2,arg3,arg4,arg5)
	傳遞引數：
				arg1：必要項。地址物件之作用目標名稱,必須為<span>或<div>,必須為文字型態。
				arg2：必要項。縣市欄位名稱,必須為文字型態。
				arg3：必要項。區域欄位名稱,必須為文字型態。
				arg4：必要項。郵遞區號欄位名稱,必須為文字型態。
				arg5：必要項。其它地址欄位名稱,必須為文字型態。
				函數：setAddressVal()
**********************************************************************/
function AddressSerial(span_obj,city_obj,area_obj,zipcode_obj,addr_obj)
{

	County = new  Array("臺北市", "基隆市", "臺北縣", "宜蘭縣", "新竹市", 
						"新竹縣", "桃園縣", "苗栗縣", "臺中市", "臺中縣", "彰化縣",
						"南投縣", "嘉義市", "嘉義縣", "雲林縣", "臺南市", "臺南縣",
						"高雄市", "高雄縣", "澎湖縣", "屏東縣", "臺東縣", "花蓮縣",
						"金門縣", "連江縣", "南海諸島", "釣魚台列嶼");

	Zone = new Array(27);
	// for "臺北市"
	Zone[0] = new Array("中正區","大同區","中山區","松山區","大安區",
						"萬華區","信義區","士林區","北投區","內湖區","南港區",
						"文山區(木柵)","文山區(景美)");
	// for "基隆市"
	Zone[1] = new Array("仁愛區","信義區","中正區","中山區","安樂區",
						"暖暖區","七堵區");
	// for "臺北縣"
	Zone[2] = new Array("萬里鄉","金山鄉","板橋市","汐止鎮","深坑鄉","石碇鄉","瑞芳鎮",
						"平溪鄉","雙溪鄉","貢寮鄉","新店市","坪林鄉","烏來鄉","永和市","中和市","土城市",
						"三峽鎮","樹林市","鶯歌鎮","三重市","新莊市","泰山鄉","林口鄉","蘆洲市","五股鄉",
						"八里鄉","淡水鎮","三芝鄉","石門鄉");
	// for "宜蘭縣"
	Zone[3] = new Array("宜蘭市","頭城鎮","礁溪鄉","壯圍鄉","員山鄉","羅東鎮","三星鄉",
						"大同鄉","五結鄉","冬山鄉","蘇澳鎮","南澳鄉");
	// for "新竹市"
	Zone[4] = new Array(" ");
	// for "新竹縣"
	Zone[5] = new Array("竹北市","湖口鄉","新豐鄉","新埔鄉","關西鎮","芎林鄉","寶山鄉",
						"竹東鎮","五峰鄉","橫山鄉","尖石鄉","北埔鄉","峨嵋鄉");
	// for "桃園縣"
	Zone[6] = new Array("中壢市","平鎮","龍潭鄉","楊梅鎮","新屋鄉","觀音鄉","桃園市",
						"龜山鄉","八德市","大溪鎮","復興鄉","大園鄉","蘆竹鄉");
	// for "苗栗縣"
	Zone[7] = new Array("竹南鎮","頭份鎮","三灣鄉","南庄鄉","獅潭鄉","後龍鎮","通霄鎮",
						"苑裡鎮","苗栗市","造橋鄉","頭屋鄉","公館鄉","大湖鄉","泰安鄉","鉰鑼鄉","三義鄉",
						"西湖鄉","卓蘭鄉");
	// for "臺中市"
	Zone[8] = new Array("中區","東區","南區","西區","北區","北屯區",
						"西屯區","南屯區");
	// for "臺中縣"
	Zone[9] = new Array("太平市","大里市","霧峰鄉","烏日鄉","豐原市","后里鄉","石岡鄉",
						"東勢鎮","和平鄉","新社鄉","潭子鄉","大雅鄉","神岡鄉","大肚鄉","沙鹿鎮","龍井鄉",
						"梧棲鎮","清水鎮","大甲鎮","外圃鄉","大安鄉");
	// for "彰化縣"
	Zone[10] = new Array("彰化市","芬園鄉","花壇鄉","秀水鄉","鹿港鎮","福興鄉","線西鄉",
						"和美鎮","伸港鄉","員林鎮","社頭鄉","永靖鄉","埔心鄉","溪湖鎮","大村鄉","埔鹽鄉",
						"田中鎮","北斗鎮","田尾鄉","埤頭鄉","溪州鄉","竹塘鄉","二林鎮","大城鄉","芳苑鄉",
						"二水鄉");
	// for "南投縣"
	Zone[11] = new Array("南投市","中寮鄉","草屯鎮","國姓鄉","埔里鎮","仁愛鄉","名間鄉",
						"集集鄉","水里鄉","魚池鄉","信義鄉","竹山鎮","鹿谷鄉");
	// for "嘉義市"
	Zone[12] = new Array(" ");
	// for "嘉義縣"
	Zone[13] = new Array("番路鄉","梅山鄉","竹崎鄉","阿里山鄉","中埔鄉","大埔鄉",
						"水上鄉","鹿草鄉","太保市","朴子市","東石鄉","六腳鄉","新港鄉","民雄鄉","大林鎮","漢口鄉",
						"義竹鄉","布袋鎮");
	// for "雲林縣"
	Zone[14] = new Array("斗南市","大埤鄉","虎尾鎮","土庫鎮","褒忠鄉","東勢鄉","臺西鄉",
						"崙背鄉","麥寮鄉","斗六市","林內鄉","古坑鄉","莿桐鄉","西螺鎮","二崙鄉","北港鎮",
						"水林鄉","口湖鄉","四湖鄉","元長鄉");
	// for "臺南市"
	Zone[15] = new Array("中區","東區","南區","西區","北區","安平區","安南區");
	// for "臺南縣"
	Zone[16] = new Array("永康市","歸仁鄉","新化鎮","左鎮鄉","玉井鄉","楠西鄉","南化鄉",
						"仁德鄉","關廟鄉","龍崎鄉","官田鄉","麻豆鎮","佳里鎮","西港鄉","七股鄉","將軍鄉",
						"學甲鎮","北門鄉","新營市","後壁鄉","白河鎮","東山鄉","六甲鄉","下營鄉","柳營鄉",
						"鹽水鎮","善化鎮","大內鄉","山上鄉","新市鄉","安定鄉");
	// for "高雄市"
	Zone[17] = new Array("新興區","前金區","苓雅區","鹽埕區","鼓山區",
						"旗津區","前鎮區","三民區","楠梓區","小港區","左營區");
	// for "高雄縣"
	Zone[18] = new Array("仁武鄉","大社鄉","岡山鎮","路竹鄉","阿蓮鄉","田寮鄉","燕巢鄉",
						"橋頭鄉","梓官鄉","彌陀鄉","永安鄉","湖內鄉","鳳山市","大寮鄉","林園鄉","鳥松鄉",
						"大樹鄉","旗山鎮","美濃鎮","六龜鄉","內門鄉","杉林鄉","甲仙鄉","桃源鄉","三民鄉",
						"茂林鄉","茄萣鄉");
	// for "澎湖縣"
	Zone[19] = new Array("馬公市","西嶼鄉","望安鄉","七美鄉","白沙鄉","湖西鄉");
	// for "屏東縣"
	Zone[20] = new Array("屏東市","三地門鄉","霧臺鄉","瑪家鄉","九如鄉","里港鄉","高樹鄉",
						"鹽埔鄉","長治鄉","麟洛鄉","竹田鄉","內埔鄉","萬丹鄉","潮州鎮","泰武鄉","來義鄉",
						"萬巒鄉","嵌頂鄉","新埤鄉","南州鄉","林邊鄉","東港鎮","琉球鄉","佳冬鄉","新園鄉",
						"枋寮鄉", "枋山鄉","春日鄉","獅子鄉","車城鄉","牡丹鄉","恆春鎮","滿州鄉");
	// for "臺東縣"
	Zone[21] = new Array("臺東市","綠島鄉","蘭嶼鄉","延平鄉","卑南鄉","鹿野鄉","關山鎮",
						"海端鄉","池上鄉","東河鄉","成功鎮","長濱鄉","太麻里鄉","金峰鄉","大武鄉","達仁鄉");
	// for "花蓮縣"
	Zone[22] = new Array("花蓮市","新城鄉","秀林鄉","吉安鄉","壽豐鄉","鳳林鎮","光復鄉",
						"豐濱鄉","瑞穗鄉","萬榮鄉","玉里鎮","卓溪鄉","富里鄉");
	// for "金門縣"
	Zone[23] = new Array("金沙鎮","金湖鎮","金寧鄉","金城鎮","烈嶼鄉","烏坵鄉");
	// for "連江縣"
	Zone[24] = new Array("南竿鄉","北竿鄉","莒光鄉","東引");
	// for "南海諸島"
	Zone[25] = new Array("東沙","西沙");
	// for "釣魚台列嶼"
	Zone[26] = new Array(" ");

	ZipCode = new Array(27);
	// for "臺北市"
	ZipCode[0] = new Array("100","103","104","105","106","108","110","111",
							"112","114","115","116","117");
	// for "基隆市"
	ZipCode[1] = new Array("200","201","202","203","204","205","206");
	// for "臺北縣"
	ZipCode[2] = new Array("207","208","220","221","222","223","224","226",
							"227","228","231","232","233","234","235","236","237","238","239",
							"241","242","243","244","247","248","249","251","252","253");
	// for "宜蘭縣"
	ZipCode[3] = new Array("260","261","262","263","264","265","266","267",
							"268","269","270","272");
	// for "新竹市"
	ZipCode[4] = new Array("300");
	// for "新竹縣"
	ZipCode[5] = new Array("302","303","304","305","306","307","308","310",
							"311","312","313","314","315");
	// for "桃園縣"
	ZipCode[6] = new Array("320","324","325","326","327","328","330","333",
							"334","335","336","337","338");
	// for "苗栗縣"
	ZipCode[7] = new Array("350","351","352","353","354","356","357",
							"358","360","361","362","363","364","365","366","367","368","369");
	// for "臺中市"
	ZipCode[8] = new Array("400","401","402","403","404","406","407","408");
	// for "臺中縣"
	ZipCode[9] = new Array("411","412","413","414","420","421","422","423",
							"424","426","427","428","429","432","433","434","435","436","437",
							"438","439");
	// for "彰化縣"
	ZipCode[10] = new Array("500","502","503","504","505","506","507","508",
							"509","510","511","5112","513","514","515","516","520","521","522",
							"523","524","525","526","527","528","530");
	// for "南投縣"
	ZipCode[11] = new Array("540","541","542","544","545","546","551","552",
							"553","555","556","557","558");
	// for "嘉義市"
	ZipCode[12] = new Array("600");
	// for "嘉義縣"
	ZipCode[13] = new Array("602","603","604","605","606","607","608","611",
							"612","613","614","615","616","621","622","623","624","625");
	// for "雲林縣"
	ZipCode[14] = new Array("630","631","632","633","634","635","636","637",
							"638","640","643","646","647","648","649","651","652","653","654",
							"655");
	// for "臺南市"
	ZipCode[15] = new Array("700","701","702","703","704","708","709");
	// for "臺南縣"
	ZipCode[16] = new Array("710","711","712","713","714","715","716","717",
							"718","719","720","721","722","723","724","725","726","727","730",
							"731","732","733","734","735","736","737","741","742","743","744",
							"745");
	// for "高雄市"
	ZipCode[17] = new Array("800","801","802","803","804","805","806","807",
							"811","812","813");
	// for "高雄縣"
	ZipCode[18] = new Array("814","815","820","821","822","823","824","825",
							"826","827","828","829","830","831","832","833","840","842","843",
							"844","845","846","847","848","849","851","852");
	// for "澎湖縣"
	ZipCode[19] = new Array("880","881","882","883","884","885");
	// for "屏東縣"
	ZipCode[20] = new Array("900","901","902","903","904","905","906","907",
							"908","909","911","912","913","920","921","922","923","924","925",
							"926","927","928","929","931","932","940","941","942","943","944",
							"945","946","947");
	// for "臺東縣"
	ZipCode[21] = new Array("950","951","952","953","954","955","956","957",
							"958","959","961","962","963","964","965","966");
	// for "花蓮縣"
	ZipCode[22] = new Array("970","971","972","973","974","975","976","977",
							"978","979","981","982","983");
	// for "金門縣"
	ZipCode[23] = new Array("890","891","892","893","894","896");
	// for "連江縣"
	ZipCode[24] = new Array("209","210","211","212");
	// for "南海諸島"
	ZipCode[25] = new Array("817","819","290");
	// for "釣魚台列嶼"
	ZipCode[26] = new Array("290");

	try
	{

		if (typeof(span_obj) != "string" || typeof(city_obj) != "string" || typeof(area_obj) != "string" || typeof(zipcode_obj) != "string" || typeof(addr_obj) != "string" )
		{
			throw "欄位引數錯誤，請檢查引數數目及型態是否正確！";
		}
		var obj=document.all(span_obj);

		try
		{
			obj.length += 0;
		} 
		catch (e)
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj  + " ] 是否存在 !!";
		}

		if( obj.length > 1 )
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj + " ] 是否重複 !!"
		}

	}
	catch(e)
	{
		alert(e)
		return false;
	}

	this.span_obj = span_obj;
	this.city_obj=city_obj;
	this.area_obj=area_obj;
	this.zipcode_obj=zipcode_obj;
	this.addr_obj=addr_obj;

}

	/****************************************************************
		設定地址物件 [ 將地址物件置於作用目標 ] 
		函數名稱：writeHTML
		函數類型：Public
		使用方法：writeHTML()
		傳遞引數：無
	*****************************************************************/
	AddressSerial.prototype.writeHTML = function ()
	{

		var innerStr="";
		innerStr = innerStr + "<select title='縣市' name='" + this.city_obj + "' onchange=" + "setAddressVal('" + this.city_obj + "','" + this.area_obj + "','" + this.zipcode_obj + "');" + " style='font:9pt'></select> "
		innerStr = innerStr + "<select title='鄉鎮市區' name='" + this.area_obj + "' onchange=" + "setAddressVal('" + this.city_obj + "','" + this.area_obj + "','" + this.zipcode_obj + "');" + " style='font:9pt'></select> "
		innerStr = innerStr + "<input title='郵遞區號' name='" + this.zipcode_obj + "' style='font:9pt' readonly size='2'> "
		innerStr = innerStr + "<input title='住址' name='" + this.addr_obj + "' style='font:9pt'> "

		if(typeof(this.span_obj)=="string")
		{
			document.all(this.span_obj).innerHTML=innerStr;
			setAddressVal(this.city_obj,this.area_obj,this.zipcode_obj);
		}

	}



	/****************************************************************
		設定地址物件 [ 設定縣市/鄉鎮市區/郵遞區號函數 ] 
		函數名稱：setAddressVal
		函數類型：Private
		使用方法：objName.setAddressVal(arg1,arg2,arg3)
		傳遞引數：
					objName：必要項。所引用的objName必須為設定住址物件。
					arg1：必要項。縣市欄位名稱,必須為文字型態。
					arg2：必要項。鄉鎮市區欄位名稱,必須為文字型態。
					arg3：必要項。郵遞區號欄位名稱,必須為文字型態。
	*****************************************************************/
	function setAddressVal(cityName,areaName,zipcodeName)
	{

		try 
		{
			var cityObj = document.all(cityName);
			var areaObj = document.all(areaName);
			var zipcodeObj = document.all(zipcodeName);

			try 
			{
				cityObj.length += 0;
			} 
			catch (e) 
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + cityName +  " ] 是否重覆使用或不存在 !!";
			}

			try 
			{
				areaObj.length += 0; 
			} 
			catch (e) 
			{ 
				throw "請檢查此欄位 - 欄位名稱 [ " + areaName +  " ] 是否重覆使用或不存在 !!";
			}

			try 
			{
				zipcodeObj.length += 0; 
			} 
			catch (e) 
			{
				throw "請檢查此欄位 - 欄位名稱 [ " + zipcodeName +  " ] 是否重覆使用或不存在 !!";
			}

		}
		catch(e)
		{
			alert(e);
			return false;
		}


		//*********** 填入省市 *******************
		cityObj.length = County.length+1;
		cityObj.options[0].value = "";
		cityObj.options[0].text = "請選擇城市";
		for (i = 0; i < County.length; i++) 
		{
			cityObj.options[i+1].value = County[i];
			cityObj.options[i+1].text = County[i];
		}
		if (cityObj.length==0)
		{
			cityObj.selectedIndex = 0;
		}


		//*********** 填入鄉鎮市區/郵遞區號 *******************

		if (cityObj.selectedIndex != 0)
		{
			areaObj.length = Zone[cityObj.selectedIndex-1].length+1;
			areaObj.options[0].value = "";
			areaObj.options[0].text = "請選擇區域";
			for (i = 0; i < Zone[cityObj.selectedIndex-1].length; i++) 
			{
				areaObj.options[i+1].value = Zone[cityObj.selectedIndex-1][i];

				if (Zone[cityObj.selectedIndex-1][i] == " ")
				{
					areaObj.options[i+1].text = "(無)";
				}
				else
				{
					areaObj.options[i+1].text = Zone[cityObj.selectedIndex-1][i];
				}
			}

			if (areaObj.length==0)
			{
				areaObj.selectedIndex = 0;
			}

			if(areaObj.selectedIndex==0 )
			{
				zipcodeObj.value = "";
			}
			else
			{
				zipcodeObj.value = ZipCode[cityObj.selectedIndex-1][areaObj.selectedIndex-1];
			}
		}
		else
		{
			areaObj.length = 1;
			areaObj.options[0].value = "";
			areaObj.options[0].text = "請選擇區域";
		}
		
	}


/*************************************************************************************
	● 設定日期物件
	物件名稱：TimeSerial
	使用方法：TimeSerial(arg1,arg2,arg3,arg4)
	傳遞引數：
				arg1：必要項。日期物件之作用目標名稱,必須為<span>或<div>,必須為文字型態。
				arg2：必要項。[ 時 ] 欄位名稱,必須為文字型態。
				arg3：必要項。[ 分 ] 欄位名稱,必須為文字型態。
				arg4：必要項。[ 秒 ] 欄位名稱,必須為文字型態。
	函數：writeHTML()
*************************************************************************************/

function TimeSerial(span_obj,hour_obj,minute_obj,second_obj){

	try {

		if (typeof(span_obj) != "string" && (typeof(hour_obj) != "string" || typeof(minute_obj) != "string" || typeof(second_obj) != "string"))
		{
			throw "欄位引數錯誤，請檢查引數數目及型態是否正確！";
		}

		var obj=document.all(span_obj);

		try
		{
			obj.length += 0;
		}
		catch (e)
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj  + " ] 是否存在 !!";
		}

		if( obj.length > 1 )
		{
			throw "請檢查此欄位 - 欄位名稱 [ " + span_obj + " ] 是否重複 !!"
		}

	}
	catch(e)
	{

		alert(e)
		return false;
	}

	this.span_obj=span_obj;
	if (typeof(hour_obj)=="string") this.hour_obj=hour_obj;
	if (typeof(minute_obj)=="string") this.minute_obj=minute_obj;
	if (typeof(second_obj)=="string") this.second_obj=second_obj;

}

	/****************************************************************
		設定日期物件 [ 將日期物件置於作用目標 ] 
		函數名稱：writeHTML
		函數類型：Public
		使用方法：writeHTML()
		傳遞引數：無
	*****************************************************************/
	TimeSerial.prototype.writeHTML = function ()
	{

		var innerStr="";
		if (typeof(this.hour_obj)=="string" && this.hour_obj != "")
		{
			innerStr = innerStr + "<select title='時' name='" + this.hour_obj + "' style='font:9pt'></select> 時 "
		}
		if (typeof(this.minute_obj)=="string" && this.minute_obj != "")
		{
			innerStr = innerStr + "<select title='分' name='" + this.minute_obj + "' style='font:9pt'></select> 分 "
		}
		if (typeof(this.second_obj)=="string" && this.second_obj != "")
		{
			innerStr = innerStr + "<select title='秒' name='" + this.second_obj + "' style='font:9pt'></select> 秒 "
		}

		if(typeof(this.span_obj)=="string")
		{
			document.all(this.span_obj).innerHTML=innerStr;
			setTimeVal(this.hour_obj,this.minute_obj,this.second_obj);
		}
	}

	/****************************************************************
		設定日期物件 [ 設定日期函數 ] 
		函數名稱：setTimeVal
		函數類型：Private
		使用方法：setTimeVal(arg1,arg2,arg3)
		傳遞引數：
					objName：必要項。所引用的objName必須為設定日期物件。
					arg1：必要項。[ 時 ] 欄位名稱,必須為文字型態。
					arg2：必要項。[ 分 ] 欄位名稱,必須為文字型態。
					arg3：必要項。[ 秒 ] 欄位名稱,必須為文字型態。
	*****************************************************************/
	function setTimeVal(hourName,minuteName,secondName)
	{
		if (typeof(hourName)=="string" && hourName != "")
		{
			if (document.all(hourName).length == 0)
			{
				document.all(hourName).length = 24;
				for (var i = 0 ; i < document.all(hourName).length ; i++)
				{
					document.all(hourName).options[i].text = i;
					document.all(hourName).options[i].value = i;
				}
			}
		}
		if (typeof(minuteName)=="string" && minuteName != "")
		{
			if (document.all(minuteName).length == 0)
			{
				document.all(minuteName).length = 60;
				for (var i = 0 ; i < document.all(minuteName).length ; i++)
				{
					document.all(minuteName).options[i].text = i;
					document.all(minuteName).options[i].value = i;
				}
			}
		}
		if (typeof(secondName)=="string" && secondName != "")
		{
			if (document.all(secondName).length == 0)
			{
				document.all(secondName).length = 60;
				for (var i = 0 ; i < document.all(secondName).length ; i++)
				{
					document.all(secondName).options[i].text = i;
					document.all(secondName).options[i].value = i;
				}
			}
		}
	}
	
// [ 加入千位元逗號 ]
// --------------------------------------------------------------------------------------------
function addcomma(us_value)
{
	if(chknum(us_value,"A")=="FALSE")
	{
		return("[INPUT ERROR]");
	}
	
	var val_buf="";
	
	if(us_value.indexOf("+",0)==0)
	{
		us_value=us_value.replace("+","");
		val_buf="+";
	}
	else if(us_value.indexOf("-",0)==0)
	{
		us_value=us_value.replace("-","");
		val_buf="-";
	}
	
	var value_array=String(us_value).split(".");
	var val_str=value_array[0];
	var val_len=val_str.length;
	
	for(var j=val_len;j>0;j--)
	{
		if((j%3==0)&&(j!=val_len))
		{
			val_buf=val_buf+","+val_str.substr(val_len-j,1);
		}
		else
		{
			val_buf=val_buf+val_str.substr(val_len-j,1);
		}
	}
	
	if(value_array[1]>0)
	{
		return(val_buf+"."+value_array[1]);
	}
	else
	{
		return(val_buf);
	}
}
// --------------------------------------------------------------------------------------------

// [ 除去千位元逗號 ]
// --------------------------------------------------------------------------------------------
function delcomma(us_value)
{
	if(chknum(us_value,"D")=="FALSE")
	{
		return("[INPUT ERROR]");
	}
	
	while(us_value.indexOf(",",0)>=0)
	{
		us_value=us_value.replace(",","");
	}

	return(us_value);
}
// --------------------------------------------------------------------------------------------

// [ 檢查是否為數字型態 ;; 數字型態回傳TRUE , 非數字型態回傳FALSE ]
// --------------------------------------------------------------------------------------------
function chknum(us_value,us_style)
{
	var dot_ct=0;
	var sign_ct=0;
	var val_len=us_value.length;
	for(var j=0;j<val_len;j++)
	{
		if("1234567890.,+-".indexOf(us_value.charAt(j),0)<0)
		{
			return("FALSE");
		}
		if((us_value.charAt(j)=="+")||(us_value.charAt(j)=="-"))
		{
			sign_ct++;
		}
		if(us_value.charAt(j)==".")
		{
			dot_ct++;
		}
		if((us_style=="A")&&(us_value.charAt(j)==","))
		{
			return("FALSE");
		}
	}

	if((((us_value.indexOf("+",0)>0)||(us_value.indexOf("-",0)>0))||(sign_ct>1))||(dot_ct>1))
	{
		return("FALSE");
	}

	return("TRUE");
}
// --------------------------------------------------------------------------------------------
