		function isFilled(elm)
		{
			var str = trim(elm.value);
			if ( str.length == 0 )
			{
				elm.value="";
				elm.focus();
				return false;
			}
			return true;
		}

		function isSpecific(elm)
		{
			var str = elm.value;
			if (!(str.indexOf("'") == -1 && str.indexOf("\"") == -1 && str.indexOf("%") == -1 && str.indexOf("*") == -1))
			{
				alert("欄位中不可以有 \' 或 \" 或 * 或 % 的特殊字元出現");
				elm.value = "";
				elm.focus();
				return false;
			}

			return true;
		}

		function isNormaldata(elm)
		{
			if( !isFilled(elm) )
				return false;
			if( !isSpecific(elm) )
				return false;

			elm.value = trim(elm.value);
			return true;
		}

		function isCorrectChar(elm)
		{
			if (!isFilled(elm))
				return false;
			
			var str = elm.value;
			var i
			var j
			for (i=0 ; i<str.length ; i++)
			{
				j = str.charCodeAt(i);
				if (!((j>=48 && j<=57) || (j>=65 && j<=90) || (j>=97 && j<=122)))
				{
					alert("帳號欄位資料由1～20個數字或英文的字元組成，\n不可以含有 \' 或 \'\' 或 * 或 % 等特殊字元，\n不可以含有空格等空白字元，\n不可以含有中文字元，\n英文字元大小寫視為相同");
					elm.value = "";
					elm.focus();
					return false;
				}
			}
			return true;
		}

		function pwdlength(elm)
		{
			if((elm.value.length>8)||(elm.value.length<6))
			return false;
			else return true;
		}

		function check_pwd(elm1, elm2)
		{
			if(elm1.value != elm2.value)
			{
				alert("密碼不正確，請重新核對您的密碼");
				elm1.value = "";
				elm2.value = "";
				elm1.focus();
				return false;
			}
			return true;
		}

/*==========================================================================
				檢查身分證字號
==========================================================================*/
		function p_no(elm)
		{
			id_str=elm.value+'$' 
			str="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			letter=id_str.substring(0,1)
			letter1=letter.toUpperCase()
			sumval=0
			modval=-1
			rc=true
			a1=0
			a2=0
			if( (str.indexOf(letter1,0) == -1) || (id_str.length < 11) )
			{
				alert("身 分 證 字 號 輸 入 錯 誤 !!!");
				return false;
			}
			else
			{
			      if (letter1=="A"){a1=1;a2=0}
			      if (letter1=="B"){a1=1;a2=1}
			      if (letter1=="C"){a1=1;a2=2}
			      if (letter1=="D"){a1=1;a2=3}
			      if (letter1=="E"){a1=1;a2=4}
			      if (letter1=="F"){a1=1;a2=5}
			      if (letter1=="G"){a1=1;a2=6}
			      if (letter1=="H"){a1=1;a2=7}
			      if (letter1=="J"){a1=1;a2=8}
			      if (letter1=="K"){a1=1;a2=9}
			      if (letter1=="L"){a1=2;a2=0}
			      if (letter1=="M"){a1=2;a2=1}
			      if (letter1=="N"){a1=2;a2=2}
			      if (letter1=="P"){a1=2;a2=3}
			      if (letter1=="Q"){a1=2;a2=4}
			      if (letter1=="R"){a1=2;a2=5}
			      if (letter1=="S"){a1=2;a2=6}
			      if (letter1=="T"){a1=2;a2=7}
			      if (letter1=="U"){a1=2;a2=8}
			      if (letter1=="V"){a1=2;a2=9}
			      if (letter1=="X"){a1=3;a2=0}
			      if (letter1=="Y"){a1=3;a2=1}
			      if (letter1=="W"){a1=3;a2=2}
			      if (letter1=="Z"){a1=3;a2=3}
			      if (letter1=="I"){a1=3;a2=4}
			      if (letter1=="O"){a1=3;a2=5} 
			      d1=id_str.substring(1,2)
			      d2=id_str.substring(2,3)
			      d3=id_str.substring(3,4)
			      d4=id_str.substring(4,5)
			      d5=id_str.substring(5,6)
			      d6=id_str.substring(6,7)
			      d7=id_str.substring(7,8)
			      d8=id_str.substring(8,9)
			      d9=id_str.substring(9,10)
			      no_str="0123456789"
			      if ((no_str.indexOf(d1,0) == -1)||(no_str.indexOf(d2,0) == -1)||(no_str.indexOf(d3,0) == -1)||(no_str.indexOf(d4,0) == -1)||(no_str.indexOf(d5,0) == -1)||(no_str.indexOf(d6,0) == -1)||(no_str.indexOf(d7,0) == -1)||(no_str.indexOf(d8,0) == -1)||(no_str.indexOf(d9,0) == -1))
			      {
				alert("身 分 證 字 號 輸 入 錯 誤 !!!");
				return false;
			      }  
			      else
			      {
				sumval=eval(a1*1+a2*9+d1*8+d2*7+d3*6+d4*5+d5*4+d6*3+d7*2+d8*1+d9*1) 
				modval=sumval%10
				if (modval != 0){alert("身 分 證 字 號 輸 入 錯 誤 !!!");return false;} 
	      		      }   
			}   
		}

/*==========================================================================
		         確認E-mail非空白且帶有"@" "."
==========================================================================*/
		function isEmail(elm)
		{
			if(elm.value.indexOf("@") !="-1" && elm.value.indexOf(".") !="-1" && elm.value !="")
				return true;
			else return false;
		}

/*
多選的check		
*/		
function numberOfCheckedItems(list) 
{
	var times = 0;
	for(i=0;i<list.length;i++)
	{
		if(list[i].checked) times++;
	}
	return times;
}

function checkMultiQ(name, errStr)
{
	target = document.getElementsByName(name);
	if(numberOfCheckedItems(target) == 0)
	{
		alert(errStr);
		return false;
	}
	else
		return true;
}		