﻿function enableNumberOnly() {var k=event.keyCode; if ((k==46) || (k<=57 && k>=48)) return true; else return false; }
function enableIntegerOnly() {var k=event.keyCode; if (k<=57 && k>=48) return true; else return false; }
function show(message) { alert(message); }        
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function LoginOnload()
{
    if (top.location != self.location){   
        top.location=self.location;   
    }
}
function checkidentity(source,arguments) { 
	    UniNo=arguments.Value;
	    var res = new Array(8);
	    var key = "12121241";
	    var isModeTwo = false;	//第7個數是否為7
	    var result = 0;

	    if(UniNo.length != 8){
	    	alert('【統一編號】不可少於或多於8碼！');
	    	arguments.IsValid = false;
	    	return false ;
	    }

	    for(var i=0; i<8; i++){
	    	var tmp = UniNo.charAt(i) * key.charAt(i);
	    	res[i] = Math.floor(tmp/10) + (tmp%10); //取出10位數和個位數相加
	    	if(i == 6 && UniNo.charAt(i) == 7)
    		isModeTwo = true;
	    }

	    for(var s=0; s<8; s++)
	    	result += res[s];

	    if(isModeTwo){
	    	if((result % 10) != 0 && ((result + 1) % 10) != 0){  //如果第7位數為7
	    		alert('【統一編號】編碼不正確，請重新輸入！');
	    		arguments.IsValid = false;
	    		return false;
	    	}
	    }
	    else
    		if((result % 10) != 0){
	    		alert('【統一編號】編碼不正確，請重新輸入！');
	    		arguments.IsValid = false;
	    		return false;
	    	}
	    arguments.IsValid = true;
   		return true;
}