function memberSubscribe(){
	var oForm = document.all['memberForm']
	if(!checkMemberForm(oForm))
		return
	oForm.submit()
}
function memberUnsubscribe(){
	var oForm = document.all['memberForm']
	if(!checkMemberForm(oForm))
		return
	oForm.submit()
}
function isNumber(obj){
	var bOkKey = false
	var okKeyCode = [8,9,18,16,46,39,37]
	for(var x in okKeyCode) if(okKeyCode[x]==event.keyCode) bOkKey=true
	if(event.keyCode >= 48 && event.keyCode <= 57) bOkKey=true
	if(event.keyCode >= 96 && event.keyCode <= 105) bOkKey=true
	if(!bOkKey){
		alert(dic.DIGIT_ONLY)
		obj.focus()
	}
}
function checkMemberForm(Form){
	for(var i = 0 ; i < Form.length ;i++){
		if(Form.item(i).value == ""  && Form.item(i).required == 'true'){
			alert(dic.ENTER + " " + Form.item(i).trueName);
			Form.item(i).focus();
			return false;
		}
		
		if(Form.item(i).datatype=='email' && Form.item(i).value != ""){
			if(!validateEmail(Form.item(i).value)){
				alert(dic.BAD_MAIL);
				Form.item(i).focus();
				return false;
			}
		}
		if(Form.item(i).datatype=='id' && Form.item(i).value != ""){
			if(!checkIDNumber(Form.item(i))){
				return false
			}
		}
	}

	return true
}
function validateEmail(email) {
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return (re.test(email))
} 
function checkIDNumber(obj)
{
	var Id2Check = obj.value
	var i = j = startmult = total = result = Down = idstart = Up = 0;
	var addstr="";
	var mult="121212121";
	var zero2Add=9-Id2Check.length;
	if (zero2Add > 0) {
		var index=0;
		while (index < zero2Add)	{
			addstr += "0";
			index++;
		}
		Id2Check = addstr + Id2Check;
	}
	var L = Id2Check.length ;
	var idstr = Id2Check;
	while (i < Id2Check.length-1 ) { 
		var asNumber = parseFloat (Id2Check);
		if (isNaN(asNumber)) { 
				
			obj.focus()
			alert("letter only")
			return false; 
		}
		if ((idstr.charCodeAt(j)<48)||(idstr.charCodeAt(j)>57)){
			alert(dic.DIGIT_ONLY)
			obj.focus()
			return false; 
		}

		Up=eval(idstr.charAt(i));
		Down=eval(mult.charAt(j));

		if ((Up!=0)&&(startmult==0)) startmult=1;
			
		result=Up*Down;
		if ( result > 9 ) { 
			resultx = Math.floor ( result/10 ) ;
			result = resultx + ( result - resultx*10 ) 
		}	 
		total=total + result;
		j++;
		i++;
	} 

	total = Math.ceil ( total/10 ) *10 -total;
	var idstr=Id2Check;

	if ((idstr.charCodeAt(L-1)<=57)&&(idstr.charCodeAt(L-1)>=48)) 
		var add= eval(idstr.charAt(L-1));
		
	if (L==9) idstart=1;
		
	if (total != add){
		obj.focus()
		alert(dic.WRONG_ID)
		return false;
	} 
	else return true;	
}
