//==========================================
// 在 A 按 onCLick事件
//==========================================
function openurl(strurl){
	//alert(strurl);
	parent.MA_MidMid.frames.location.href=strurl;
	window.status='';
	return true
}
	
	
//==========================================
// 檢核欄位資料正確性
//==========================================
function DataChk(Str,Str1,Num){

var RefString="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (Count=0; Count < Str.value.length; Count++){
TempChar= Str.value.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1){
alert('『'+Str1+'』欄位資料只能填入英文或數字喔 !!');
return false;}}

if (Str.value.length<Num){
alert('『'+Str1+'』欄位字元至少要大於等於'+Num+'個字元，請重新輸入 !!');
return false;}

}

//==========================================
// 檢核欄位資料是否為數字
//==========================================
function NumChk(Str1,Str2){

var RefString="1234567890";
for (Count=0; Count < Str1.value.length; Count++){
TempChar= Str1.value.substring (Count, Count+1);

if (RefString.indexOf (TempChar, 0)==-1){
alert('『'+Str2+'』欄位資料只能填入數字喔 !!');
Str1.value ="";
return false;}}

}

//==========================================
// 檢核輸入值是否為Empty
//==========================================
function ChkEmpty(Str){
if (Str.value=='' || Str.value==null) return false;}


//==========================================
// 檢核輸入值是否為Empty (檢查下拉物件)
//==========================================
function ChkEmptySelect(Str){
if (Str.options[Str.selectedIndex].value=='' || Str.options[Str.selectedIndex].value==0) return false;
}


//==========================================
// 檢核Email格式是否正確
//==========================================
function EmailChk(Str) {
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if (re.test(Str.value)){
			return true;}
	else{
			return false;}}

//==========================================
// 身分證字號檢核 第－碼英文，後九碼數字
//==========================================
function IDChk(Str){
	var patrn=/^[a-zA-Z]{1}[0-9]{9}$/;	//本國身份證
	var patrn2=/^[a-zA-Z]{2}[0-9]{8}$/;	//外國人護照 第1,2碼英文，後8碼數字
	if (!patrn.exec(Str.value)) {
		if (!patrn2.exec(Str.value)) {
			return false
		}else {return true}
	}
	return true
}



//==========================================
// 密碼檢核4-12字(英文、數字)
//==========================================

function PassChk(Str){
	var patrn=/^[a-zA-Z0-9]{4,12}$/;
	if (!patrn.exec(Str.value)) return false
	return true
}

//==========================================
// 電話檢核格式 0X　-　XXXXXXXXX
//               -     ---------
//               1碼    7-8碼
//==========================================
function TelChk(Str){
	var patrn=/^[0]{1}[2-9]{1}[-]{1}[0-9]{7,8}$/;
	if (!patrn.exec(Str.value)) return false
	return true
}

//==========================================
// 行動電話檢核 格式09XXXXXXXX
//==========================================
function CellChk(Str){
	var patrn=/^[0]{1}[9]{1}[0-9]{8}$/;
	if (!patrn.exec(Str.value)) return false
	return true
}

//==========================================
// 檢查輸入日期是否正確　
//==========================================
function checkDate(input){
	var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //格式 yyyy/mm/dd
	var returnval=false
	if (!validformat.test(input.value))
		return false;
		//alert("輸入格式錯誤，格式為 yyyy/mm/dd ")
	else{ //Detailed check for valid date ranges
		var yearfield=input.value.split("/")[0]
		var monthfield=input.value.split("/")[1]
		var dayfield=input.value.split("/")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
			return false;
			//alert("輸入日期錯誤！！")
		else
			returnval=true
	}
	if (returnval==false) input.select()
	return returnval
}


//==========================================
// 開啟視窗;參數(連結,視窗名稱,視窗長度,視窗寬度)
//==========================================
function OpenWin(Url,WinName,Width,Heigth,Top){
	window.open(Url,WinName,'menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=yes,width='+ Width +',height='+ Heigth +',top='+ Top +',left='+(screen.width-Width)/2+'');
}

//==========================================
// 開啟視窗;參數(連結,視窗名稱,視窗長度,視窗寬度)
//==========================================
function OpenWin2(Url,WinName,Width,Heigth,Top){
	//window.open(Url,WinName);}
	window.open(Url,WinName,'menubar=no,toolbar=no,location=no,directories=no,status=No,resizable=no,scrollbars=no,width='+ Width +',height='+ Heigth +',top='+ Top +',left='+ (screen.width-Width)/2 +'');
}

//==========================================
// 開啟視窗;參數(連結,視窗名稱,視窗長度,視窗寬度)
//==========================================
function OpenWin3(Url,WinName,Width,Heigth,Top){
	window.open(Url,WinName,'menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=Yes,width='+ Width +',height='+ Heigth +',top='+ Top +',left='+ (screen.width-Width)/2 +'');
}


//==========================================
// 刪除資料(連結,標題)
//==========================================
function DataDel(Url,Title){
	if(confirm('■■■■■ 確定刪除此資料 !! ■■■■■\n\n'+Title)){
	window.location=Url;}
}

//==========================================
// 身分證字號檢核
//==========================================
function VerifyPersonIdno(Idno,ErrMsg){
	var D1,D2,Byte1,Byte2,i,Char;
	D = new Array();
	if (Idno.length != 10){
	ErrMsg = "身份證字號長度應為１０碼，請重新輸入 !!\n";return ErrMsg;}   

	Byte1=Idno.charAt(0);
	switch (Byte1){
		case "A": D1 = 1; D2 = 0; break;
		case "B": D1 = 1; D2 = 1; break;
		case "C": D1 = 1; D2 = 2; break;
		case "D": D1 = 1; D2 = 3; break;
		case "E": D1 = 1; D2 = 4; break;
		case "F": D1 = 1; D2 = 5; break;
		case "G": D1 = 1; D2 = 6; break;
		case "H": D1 = 1; D2 = 7; break;
		case "J": D1 = 1; D2 = 8; break;
		case "K": D1 = 1; D2 = 9; break;
		case "L": D1 = 2; D2 = 0; break;
		case "M": D1 = 2; D2 = 1; break;
		case "N": D1 = 2; D2 = 2; break;
		case "P": D1 = 2; D2 = 3; break;
		case "Q": D1 = 2; D2 = 4; break;
		case "R": D1 = 2; D2 = 5; break;
		case "S": D1 = 2; D2 = 6; break;
		case "T": D1 = 2; D2 = 7; break;
		case "U": D1 = 2; D2 = 8; break;
		case "V": D1 = 2; D2 = 9; break;
		case "X": D1 = 3; D2 = 0; break;
		case "Y": D1 = 3; D2 = 1; break;
		case "W": D1 = 3; D2 = 2; break;
		case "Z": D1 = 3; D2 = 3; break;
		case "I": D1 = 3; D2 = 4; break;
		case "O": D1 = 3; D2 = 5; break;
		default: ErrMsg = "身份證字號 [第１碼] 必須是英文字母,請重新輸入 !!\n";return ErrMsg;}

	Byte2 = Idno.charAt(1)
	if (Byte2 != 1 && Byte2 != 2){
	ErrMsg = "[身份證字號]輸入錯誤，請重新輸入 !!\n";return ErrMsg;}

	for (i = 1; i <= 9; i++){
	Char = new Number(Idno.charAt(i));
	if (isNaN(Char) == true){
	ErrMsg = "身份證字號 [第２碼∼第１０碼] 必須是數字，請重新輸入 !!\n";return ErrMsg;}
	D[i-1] = Char;}

	var CheckSum = D1 * 1 + D2 * 9 + D[0] * 8 + D[1] * 7 + 
				   D[2] * 6 + D[3] * 5 + D[4] * 4 + D[5] * 3 + 
				   D[6] * 2 + D[7] * 1 + D[8] * 1;
	  
	if (CheckSum % 10 != 0){
	ErrMsg = "[身份證字號]輸入錯誤，請重新輸入 !!\n";return ErrMsg;}
	ErrMsg='';return ErrMsg;
}

//==========================================
// 強迫變大寫字元(onblur事件）
//==========================================
function UpperCase(tagname){
	var InputValue = document.all[tagname].value;
	var MyStr=(new String(InputValue)).toUpperCase();
	document.all[tagname].value = MyStr;
}

//==========================================
// JavaScript新農民(大型)
//==========================================
function CalConv(CalType,NowDate) {
	FIRSTYEAR = 1998;
	LASTYEAR = 2031;
	var Weekname = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
	today = new Date(NowDate);
	SolarYear = today.getFullYear();
	SolarMonth = today.getMonth() + 1;
	SolarDate = today.getDate();
	Weekday = today.getDay();

	LunarCal = [
	new tagLunarCal( 27,  5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),
	new tagLunarCal( 46,  0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 1999 */
	new tagLunarCal( 35,  0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 2000 */
	new tagLunarCal( 23,  4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 42,  0, 1,  4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 31,  0, 2,  9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),
	new tagLunarCal( 21,  2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 2004 */
	new tagLunarCal( 39,  0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 28,  7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),
	new tagLunarCal( 48,  0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),
	new tagLunarCal( 37,  0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 2008 */
	new tagLunarCal( 25,  5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),
	new tagLunarCal( 44,  0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),
	new tagLunarCal( 33,  0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 22,  4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 2012 */
	new tagLunarCal( 40,  0, 1,  2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),
	new tagLunarCal( 30,  9, 2,  7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 49,  0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 38,  0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 2016 */
	new tagLunarCal( 27,  6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),
	new tagLunarCal( 46,  0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),
	new tagLunarCal( 35,  0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),
	new tagLunarCal( 24,  4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 2020 */
	new tagLunarCal( 42,  0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 31,  0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),
	new tagLunarCal( 21,  2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),
	new tagLunarCal( 40,  0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 2024 */
	new tagLunarCal( 28,  6, 2,  5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),
	new tagLunarCal( 47,  0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),
	new tagLunarCal( 36,  0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),
	new tagLunarCal( 25,  5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 2028 */
	new tagLunarCal( 43,  0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),
	new tagLunarCal( 32,  0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),
	new tagLunarCal( 22,  3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];


	/* 西曆年每月之日數 */
	SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

	/* 西曆年每月之累積日數, 平年與閏年 */
	SolarDays = [
	0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396,
	0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];

	AnimalIdx = ["馬 ", "羊 ", "猴 ", "雞 ", "狗 ", "豬 ", "鼠 ", "牛 ", "虎 ", "兔 ", "龍 ", "蛇 " ];
	LocationIdx = [ "南", "東", "北", "西" ];

	if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;

	sm = SolarMonth - 1;

	if ( sm < 0 || sm > 11 ) return 2;

	leap = GetLeap( SolarYear );

	if ( sm == 1 )
	d = leap + 28;
	else
	d = SolarCal[sm];

	if ( SolarDate < 1 || SolarDate > d ) return 3;

	y = SolarYear - FIRSTYEAR;
	acc = SolarDays[ leap*14 + sm ] + SolarDate;
	kc = acc + LunarCal[y].BaseKanChih;
	Kan = kc % 10;
	Chih = kc % 12;
	Location = LocationIdx[kc % 4];
	Age = kc % 60;
	if ( Age < 22 )
	Age = 22 - Age;
	else
	Age = 82 - Age;

	Age =Age + 3;

	if (Age < 10)
	Age=Age+60;

	Animal = AnimalIdx[ Chih ];

	if ( acc <= LunarCal[y].BaseDays ) {
	y--;
	LunarYear = SolarYear - 1;
	leap = GetLeap( LunarYear );
	sm += 12;
	acc = SolarDays[leap*14 + sm] + SolarDate;
	}
	else
	LunarYear = SolarYear;

	l1 = LunarCal[y].BaseDays;
	for ( i=0; i<13; i++ ) {
	l2 = l1 + LunarCal[y].MonthDays[i] + 29;
	if ( acc <= l2 ) break;
	l1 = l2;
	}

	LunarMonth = i + 1;
	LunarDate = acc - l1;
	im = LunarCal[y].Intercalation;

	if ( im != 0 && LunarMonth > im ) {
		LunarMonth--;
	if ( LunarMonth == im ) LunarMonth = -im;
	}

	if ( LunarMonth > 12 ) LunarMonth -= 12;

	if (CalType==1){
		document.write( "<FONT style='BACKGROUND-COLOR: #CC0000' Color='FFFFFF'>&nbsp;今天日期&nbsp;</Font>　西元 <font color=CC0000><B>" + SolarYear + "</B></font> 年 <font color=CC0000><B>" + SolarMonth + "</B></font> 月 <font color=CC0000><B>" + SolarDate + "</B></font> 日　<font color=CC0000>"+ Weekname[Weekday] +"</font>" );
		document.write( "　農曆 <font color=FF0099><B>" + LunarMonth + "</B></font> 月 <font color=FF0099><B>" + LunarDate + "</B></font> 日　" );
		document.write( "<font color=339900>煞" + Location + "　沖" + Animal + Age + " 歲</font>" ); }
	else if(CalType==2){
		document.write( "　農曆 <font color=FF0099><B>" + LunarMonth + "</B></font> 月 <font color=FF0099><B>" + LunarDate + "</B></font> 日　" );}
	else if(CalType==3){
		document.write("<font class=Font_11P Color=000000>農 "+ LunarMonth +"/"+ LunarDate +"</font>");}
	else if (CalType==4){
		document.write( "<FONT style='BACKGROUND-COLOR: #CC0000' Color='FFFFFF'>&nbsp;今天日期&nbsp;</Font>　西元 <font color=CC0000><B>" + SolarYear + "</B></font> 年 <font color=CC0000><B>" + SolarMonth + "</B></font> 月 <font color=CC0000><B>" + SolarDate + "</B></font> 日　<font color=CC0000>"+ Weekname[Weekday] +"</font>" );
		document.write( "　農曆 <font color=FF0099><B>" + LunarMonth + "</B></font> 月 <font color=FF0099><B>" + LunarDate + "</B></font> 日　" );}

	return 0;
 }

 /* 求此西曆年是否為閏年, 返回 0 為平年, 1 為閏年 */
function GetLeap( year )
 {
   if ( year % 400 == 0 )
     return 1;
   else if ( year % 100 == 0 )
     return 0;
   else if ( year % 4 == 0 )
     return 1;
   else
     return 0;
 }

function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {
 this.BaseDays = d;         /* 到西曆 1 月 1 日到農曆正月初一的累積日數 */
 this.Intercalation = i;    /* 閏月月份. 0==此年沒有閏月 */
 this.BaseWeekday = w;      /* 此年西曆 1 月 1 日為星期幾再減 1 */
 this.BaseKanChih = k;      /* 此年西曆 1 月 1 日之干支序號減 1 */
 this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此農曆年每月之大小, 0==小月(29日), 1==大月(30日) */
}

//==========================================
// 年月日程式(符合大月/小月/閏月)
//==========================================
function CalList(year,month,day,daynum){
	var thisDay=new Date(year.value,month.value-1,1);
	var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	var DaysArr=new Array('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
	year=thisDay.getYear();
	if(((year%4==0)&&(year%100!=0))||(year%400==0)) monthDays[1]=29;
	nDays=monthDays[thisDay.getMonth()];
	day.length=nDays;
	for(i=0;i<day.length;i++){
		day.options[i].value=DaysArr[i];
		day.options[i].text=DaysArr[i];}
		day.selectedIndex=daynum;
}

//==========================================
// 取的radio值
//==========================================

function CheckRadio(theRadio){
    var theRadioLen = theRadio.length;
    var theRadioValue = false;
    if (theRadioLen == undefined){
        if (theRadio.checked){
            theRadioValue = theRadio.value;
        }
    }else{
        for (theRadioI=0;theRadioI<theRadioLen;theRadioI++){
            if (theRadio[theRadioI].checked){
                theRadioValue = theRadio[theRadioI].value;
                break;
            }
        }
    }
    return theRadioValue;
}



//==========================================
// checkbox 的篩選 (傳入Checkbox ID Name 前６碼
//==========================================
function CheckSelAll(frmName,strCheckID) {
	with(document.forms[frmName]) {
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,strCheckID.length) == strCheckID)
				if (thiselm.disabled==false)
				{
					thiselm.checked = !thiselm.checked
				}
		}
	}
}


//==========================================
// checkbox 的篩選 (傳入Checkbox ID Name 前６碼
//==========================================
function CheckSelAll2(flgValue,frmName,strCheckID) {
	with(document.forms[frmName]) {
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,strCheckID.length) == strCheckID)
				thiselm.checked = flgValue
		}
	}
}

//==========================================
// 按刪除時要檢查 checkbox是否都有勾及詢問確定要刪除嗎
//==========================================
function DeleteCheck(frmName,strDelLink) {
	blnC=false;
	//alert(frmName);
	//var frm;
	//document.forms[frmName];
	with(document.forms[frmName]) {
	
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,6) == 'chkDEL')
			{
				if(thiselm.checked==true) {
				blnC=true;
				break;
				}
			}
		}
	}
	if (blnC==false){
		alert("您尚未勾選任何項目");
		return false;
	}
	
	if(confirm("您確定要刪除已勾選的項目嗎？")){
		document.forms[frmName].action=strDelLink;
		document.forms[frmName].submit();
	}
	return false;

}


//==========================================
// 欄位只能輸入數字
//strOther=例外字，可輸入
//==========================================
function InputIsNumeric(strOther){

	var isValidKey = false;   
	var intCode = window.event.keyCode;   

	if (intCode >= 48 && intCode <= 57) isValidKey = true;   

	if (intCode == 9)  isValidKey = true; //9 Tab 鍵 (Tab)
	if (intCode == 10) isValidKey = true; //10 換行符號 (Line Feed)
	if (intCode == 13) isValidKey = true; //13 enter   
	if (intCode == 27) isValidKey = true; //27 ESC   (Escape)

	if (strOther.value!='' || strOther.value!=null) {
		if (strOther.length >0 ){
			for (Count=0; Count < strOther.length; Count++){
				TempChar= strOther.substring (Count, Count+1);
				if (intCode == 32 && TempChar==" ") isValidKey = true; //32 spacebar   
				if (intCode == 35 && TempChar=="#") isValidKey = true; //35 # 
				if (intCode == 44 && TempChar==",") isValidKey = true; //44 , 
				if (intCode == 45 && TempChar=="-") isValidKey = true; //45 - 
				if (intCode == 46 && TempChar==".") isValidKey = true; //46 . 
				if (intCode == 47 && TempChar=="/") isValidKey = true; //47 / 
			}
		}
	}

	//依照需求自行增刪合法的 key code   
    //window.event.keyCode=0;
	window.event.returnValue = isValidKey;   
}

//==========================================
// 欄位只能輸入數字 OR 英文字
//strOther=例外字，可輸入
//==========================================
function InputIsNumericEngNum(strOther){

	var isValidKey = false;   
	var intCode = window.event.keyCode;   

	if (intCode >= 48 && intCode <= 57) isValidKey = true;   
	if (intCode >= 65 && intCode <= 90) isValidKey = true;   //A-Z
	if (intCode >= 97 && intCode <= 122) isValidKey = true;  //a-z

//alert(intCode)
	if (intCode == 9)  isValidKey = true; //9 Tab 鍵 (Tab)
	if (intCode == 10) isValidKey = true; //10 換行符號 (Line Feed)
	if (intCode == 13) isValidKey = true; //13 enter   
	if (intCode == 27) isValidKey = true; //27 ESC   (Escape)

	if (strOther.value!='' || strOther.value!=null) {

		if (strOther.length >0 ){
			for (Count=0; Count < strOther.length; Count++){
				TempChar= strOther.substring (Count, Count+1);
				if (intCode == 32 && TempChar==" ") isValidKey = true; //32 spacebar   
				if (intCode == 35 && TempChar=="#") isValidKey = true; //35 # 
				if (intCode == 44 && TempChar==",") isValidKey = true; //44 , 
				if (intCode == 45 && TempChar=="-") isValidKey = true; //45 - 
				if (intCode == 46 && TempChar==".") isValidKey = true; //46 . 
				if (intCode == 47 && TempChar=="/") isValidKey = true; //47 / 
				if (intCode == 95 && TempChar=="_") isValidKey = true; //95 _ 
			}
		}

	}
	//依照需求自行增刪合法的 key code   
    //window.event.keyCode=0;
	window.event.returnValue = isValidKey;   
}



//==========================================
// 將傳入的數字含有逗號去掉
//==========================================
function fn_StringToNumeric(value){
	value=value.replace(",","")
	return value;
}

//==========================================
// 將數字加上逗號傳回 (最多加3個逗號, 123,456,789,000
//==========================================
function fn_NumericToString(strNum){
	strNum=strNum +"";
	if (strNum.length>3){
		if (strNum.length>9){
				if (strNum.length==10) {strNum=strNum.substr(0,1) +","+ strNum.substr(1,3)+","+ strNum.substr(4,3)+","+ strNum.substr(7,3);return strNum;}
				if (strNum.length==11) {strNum=strNum.substr(0,2) +","+ strNum.substr(2,3)+","+ strNum.substr(5,3)+","+ strNum.substr(8,3);return strNum;}
				if (strNum.length==12) {strNum=strNum.substr(0,3) +","+ strNum.substr(3,3)+","+ strNum.substr(6,3)+","+ strNum.substr(9,3);return strNum;}
		}
		else if (strNum.length>6){
				if (strNum.length==7) {strNum=strNum.substr(0,1) +","+ strNum.substr(1,3)+","+ strNum.substr(4,3);return strNum;}
				if (strNum.length==8) {strNum=strNum.substr(0,2) +","+ strNum.substr(2,3)+","+ strNum.substr(5,3);return strNum;}
				if (strNum.length==9) {strNum=strNum.substr(0,3) +","+ strNum.substr(3,3)+","+ strNum.substr(6,3);return strNum;}
		
		} else {
				if (strNum.length==4) {strNum=strNum.substr(0,1) +","+ strNum.substr(1,3);return strNum;}
				if (strNum.length==5) {strNum=strNum.substr(0,2) +","+ strNum.substr(2,3); return strNum;}
				if (strNum.length==6) {strNum=strNum.substr(0,3) +","+ strNum.substr(3,3);return strNum;}
		}
	}
	return strNum;
}

//Format 數字有逗號小數點, ex: 123,456.00
function outputMoney(number) {
    return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
//Format 整數部份
function outputDollars(number) {
    if (number.length <= 3)
        return (number == '' ? '0' : number);
    else {
        var mod = number.length%3;
        var output = (mod == 0 ? '' : (number.substring(0,mod)));
        for (i=0 ; i < Math.floor(number.length/3) ; i++) {
            if ((mod ==0) && (i ==0))
                output+= number.substring(mod+3*i,mod+3*i+3);
            else
                output+= ',' + number.substring(mod+3*i,mod+3*i+3);
        }
        return (output);
    }
}
//Format 小數部份
function outputCents(amount) {
    amount = Math.round( ( (amount) - Math.floor(amount) ) * 100);
    return (amount < 10 ? '.0' + amount : '.' + amount);
}



// 宣告字串型有以下三種屬性
// 要使用以下三種屬性,ex: strValue=strValue.trim();
String.prototype.trim=trim;  //傳回去除前後空白的值
String.prototype.ltrim=ltrim;  //傳回去除左邊空白的值
String.prototype.rtrim=rtrim;  //傳回去除右邊空白的值
function trim() {
  return this.replace(/^\s+|\s+$/g, "");
} 
function ltrim() {
  return this.replace(/(^\s*)/g, "");
}
function rtrim() {
  return this.replace(/(\s*$)/g, "");
}


//==========================================
// 結束
//==========================================
