function chk(obj){
	var str=obj.value;
	if (str!=""){
		var regEx;   
		regEx= /^\d+$/;
		if(!regEx.test(str)){
			alert("輸入格式不正確,請重新輸入")
			return false;
		 }
		else
		 return true;
	}
}

function chkStr(str){
	if (str!=""){
		var regEx;   		
		regEx=/^[A-Za-z0-9]+$/;
		if(!regEx.test(str) || str.length<4 ){
			alert("輸入格式不正確,請重新輸入")
			return false;
		 } 
		else
			return true;
			
	}else
		return true;
}

function openDialog2(urlString,width,height){

if (typeof(width)=="undefined")
	width=600;
if (typeof(height)=="undefined")
	height=480;

var url='../dialog2.php?'+urlString;
var NEW_DIALOG=window.showModalDialog(url,window,'dialogHeight:'+height+'px;dialogWidth:'+width+'px;center:1;help:0;resizable:0;status:0;scroll:0');	 
//Window.open(url);
}

function openDialog(urlString,width,height){

var url=window.location.href;

if (typeof(width)=="undefined" )
	width=600;
if (typeof(height)=="undefined")
	height=480;

url='../dialog.php?'+url.substr(0,url.lastIndexOf('/')+1)+urlString;
 //window.showModalDialog(url,window,'dialogHeight:'+height+'px;dialogWidth:'+width+'px;center:1;help:0;resizable:0;status:0;scroll:0');	 
 window.open(url);
}

function check_sid(id) {
//身分証字號檢查
   check:{
	if (id.length != 10) break check;
	var no=id.split("");
	no[0]=no[0].toUpperCase();	
	if ((no[0]<"A") || (no[0]>"Z")) break check;
	if ((no[1]<"1") || (no[1]>"2")) break check;
	for (var i=1;i<10;i++) if ((no[i]<"0" || no[i]>"9")) break check; else no[i]=Number(no[i]);
	no[0]=no[0].charCodeAt(0);
	if (no[0]<73) no[0]-=55;
	   else if (no[0]==73) no[0]=34;
	      else if (no[0]<79) no[0]-=56;
	         else if (no[0]==79) no[0]=35;
	            else if (no[0]<87) no[0]-=57;
	               else if (no[0]==87) no[0]=32;
	                  else if (no[0<90]) no[0]-=58; else no[0]=33;
	var sum=Math.floor((no[0]/10))+(no[0]%10)*9;
	for (var i=1;i<9;i++) sum+=no[i]*(9-i);
	sum+=no[9];
	if (sum%10 != 0) break check;
	return true;
   }	 
   return false;
}

//格式化數字 每3個字加 ","
function format_number(number)
{
      number = (Math.round(number));
      var oldNum = '' + number;
      var newNum = '';
      decPos = oldNum.indexOf(',');
      if(decPos >= 0) {
        newNum = ','+oldNum.substring(decPos+1,oldNum.length);
      }
      else {
        newNum = '';
        decPos = oldNum.length;
      }
      for (var i=decPos; i>0; i -= 3) {
        if (i > 3) {
          newNum = ','+oldNum.substring(i-3,i)+newNum;
        }
        else {
          newNum = oldNum.substring(i-3,i)+newNum;
        }
      }
      return newNum;
}

//將格式化後的數字 轉成原來的數字字串 就是將","拿掉
function unformat_number(number)
{
     /* var oldNum = '' + number;
      var newNum = '';
   var pPos = oldNum.indexOf(',');
      while ( pPos>0) {
   newNum = oldNum.substring(0,pPos)+oldNum.substring(pPos+1,oldNum.length);
   oldNum=newNum;
   pPos = oldNum.indexOf(',');
   }
   newNum=oldNum;
      return newNum;
*/
return number.replace(",","");  
}
