
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function check_digit_id_card() {
	var multi_num = 13;
	var str_digit = 0;
	var result = 0;

	return true; // เอาออกเมื่อทำโปรแกรมในส่วนของใส่เลขทะเบียนบริษัทเสร็จแล้ว

	id_card = document.Register.soc_id.value;

    if(id_card.length != 13) {
        alert('โปรดใส่หมายเลขบัตรประชาชนให้ถูกต้อง');
        return false;
    }
    
	while(multi_num != 1) {
	    if(id_card.charAt(str_digit) == Number.NaN) {
	        alert('โปรดใส่หมายเลขบัตรประชาชนให้ถูกต้อง');
	        return false;
	    }
	    result = result + id_card.charAt(str_digit)*multi_num;
	    multi_num = multi_num - 1;
	    str_digit = str_digit + 1;
	}

	result = result % 11;
	if(result == 0) result = 10;

	result = 11 - result;

	if(result == 10) result = 0;

    if(result == id_card.charAt(12)) {
        return true;
    } else {
        alert('โปรดใส่หมายเลขบัตรประชาชนให้ถูกต้อง');
        return false;
    }
    
}

function NewWindow(mypage, myname, w, h, scroll) {
	var winl = 120;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

