
function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}
function CheckobjNonChecked(objCheck,ErrMsg)
{
if (objCheck.value != null)
var IsMulti = false;
else
var IsMulti = true;

if (IsMulti == false)
{
if (objCheck.checked == false)
{
if (ErrMsg != null && ErrMsg != "")
alert(ErrMsg);

objCheck.focus();
return false;
}
}
else
{
var flg = false;
for (var i=1; i<=objCheck.length; i++)
{
if (objCheck[i-1].checked == true)
{
flg = true;
break;
}
}

if (flg == false)
{
if (ErrMsg != null && ErrMsg != "")
alert(ErrMsg);

objCheck[0].focus();
return false;
}
}

return true;
}

function ShowError(errMsg ,Focusfield){
if (errMsg != null && errMsg != "")
alert(errMsg);
if (Focusfield != null)
Focusfield.focus();
return false;
}


function Trim(txt)
{
if (txt == "")
return txt;

var txtLen = txt.length;

for (var i=1; i<= txtLen; i++)
{
if (txt.substring(0,1) == " " || txt.substring(0,1) == "　")
txt = txt.substring(1,txt.length);
else
break;
}

for (var i=1; i <= txtLen; i++)
{
if (txt.substring(txt.length-1,txt.length) == " " || txt.substring(txt.length-1,txt.length) == "　")
txt = txt.substring(0,txt.length-1);
else
break;
}

return txt;
}



function logon_check(){
	var frm = document.form1;

    var DateObj=new Date();
	var qazplm = DateObj.getTime() + '_' + Math.floor(Math.random()*999999) + '_' + Math.floor(Math.random()*999999) + Math.floor(Math.random()*999999);


	frm.id_name.value = Trim(frm.id_name.value);

	if(frm.id_name.value.length<=0 || frm.id_name.value=='身分證字號')
		return ShowError("你的身分證未輸入!!",frm.id_name);

	var _num = 0;
	var _err = 0;
	for (var i=0; i<=frm.id_name.value.length-1; i++){
		_asc = frm.id_name.value.charCodeAt(i);
		if (_asc>=48 && _asc<=57){
			_num++;
		}else if ( (_asc>=65 && _asc<=90) || (_asc>=97 && _asc<=122) ){
		}else{
			_err++;

		}
	}
	if (frm.id_name.value.length<=4 ||_err >0 || _num==0)
		return ShowError("請正確填寫您的身份證字號!!",frm.id_name);

	if(frm.password.value=='' || frm.password.value=='個人密碼')
		return ShowError("您的密碼未輸入!!",frm.Password);

	if (frm.http_protocol != null){
		if (!CheckobjNonChecked(frm.http_protocol ,"請先選擇您的資料傳輸方式！"))
			return false;
	}

	if (document.getElementById("http_protocol_http") != null){
		if (document.getElementById("http_protocol_http").checked){
			frm.action = "http://" + document.form_x.cgi_server.value + "/act_login.cfm?qazplm=" + qazplm ;
		}else{
			frm.action = "https://" + document.form_x.cgi_server.value + "/act_login.cfm?qazplm=" + qazplm ;
			//frm.action = "https://" + document.form_x.url_server.value + "/act_login.cfm?qazplm=" + qazplm ;
		}
	}else{
		frm.action = "http://" + document.form_x.cgi_server.value + "/act_login.cfm?qazplm=" + qazplm ;
	}

	frm.id_name.value=Trim(frm.id_name.value.toUpperCase());
	frm.submit();
}



