﻿function checktxt_1(type){
var txt;
 		
   if (document.getElementById("txtUSER_ID_1").value==''){
	    txt=document.getElementById("txtUSER_ID_1");
		alert('請輸入身分證字號');
		txt.focus();       
		return false;
		}else{
		   if (gfcChkID(document.getElementById("txtUSER_ID_1").value)==false){
		    txt=document.getElementById("txtUSER_ID_1");
		alert('請輸入正確身分證字號');
		txt.focus();       
		return false;
		   }
		}
		
if (type=='true'){
	if (document.getElementById("txtPASSWORD_1").value==''){
	txt=document.getElementById("txtPASSWORD_1");
	alert('請輸入密碼');
	txt.focus();       
	return false;
	}		
	
	if (document.getElementById("txtPASSWORD_R_1").value==''){
	    txt=document.getElementById("txtPASSWORD_R_1");
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}
	}
	
	
	if (document.getElementById("txtPASSWORD_1").value!=document.getElementById("txtPASSWORD_R_1").value){
	    txt=document.getElementById("txtPASSWORD_1");
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById("txtNAME_1").value==''){
	    txt=document.getElementById("txtNAME_1");
		alert('請輸入姓名');
		txt.focus();       
		return false;
		}
	
		
   	if (document.getElementById("rblM_1").checked==false&&document.getElementById("rblF_1").checked==false){
	    txt=document.getElementById("rblM_1");
		alert('請選擇性別');
		txt.focus();       
		return false;
		}
  
     if (document.getElementById("ddlyear").value=='請選擇'){
	    txt=document.getElementById("ddlyear");
		alert('請選擇生日(年)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById("ddlmonth").value=='請選擇'){
	    txt=document.getElementById("ddlmonth");
		alert('請選擇生日(月)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById("ddlday").value=='請選擇'){
	    txt=document.getElementById("ddlday");
		alert('請選擇生日(日)');
		txt.focus();       
		return false;
		}
		
	
		if (document.getElementById("txtCELLPHONE1_1").value!=''){
			 if (document.getElementById("txtCELLPHONE1_1").value.charAt(0)!='0'){
		    alert('請輸入正確行動電話格式');
		    return false;
		  }
		  if (document.getElementById("txtCELLPHONE1_1").value.charAt(1)!='9'){
		    alert('請輸入正確行動電話格式');
		    return false;
		  }
		  if (document.getElementById("txtCELLPHONE1_1").value.length!=10){
		    alert('請輸入正確行動電話格式');
		    return false;
		  }
		}	
		
		
	 if (document.getElementById("txtTELEPHONE1_1").value==''){
	    txt=document.getElementById("txtTELEPHONE1_1");
		alert('請輸入聯絡電話');
		txt.focus();       
		return false;
		}
	
	/* if (document.getElementById("txtFAX1_1").value==''){
	    txt=document.getElementById("txtFAX1_1");
		alert('請輸入傳真');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById("txtTELEPHONE2_1").value==''){
	    txt=document.getElementById("txtTELEPHONE2_1");
		alert('請輸入聯絡電話(夜) 格式如:03-3269369');
		txt.focus();       
		return false;
		}	
		if (document.getElementById("txtTELEPHONE2_2").value==''){
	    txt=document.getElementById("txtTELEPHONE2_2");
		alert('請輸入聯絡電話(夜) 格式如:03-3269369');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入統一編號');
		txt.focus();       
		return false;
		}else{
		if (document.getElementById(txtUSER_ID).value.length!=8||isNaN(document.getElementById(txtUSER_ID).value)==true){
		txt=document.getElementById(txtUSER_ID);
		alert('請輸入正確的統一編號');
		txt.focus();
		return false;   
		}
		}	
	
	
	
		
			 if (document.getElementById("ddlANTECEDENT").value=='0'){
	    txt=document.getElementById("ddlANTECEDENT");
		alert('請選擇學歷');
		txt.focus();       
		return false;
		}
		
		
		if (document.getElementById("rblCONNUBIALITY_False").checked==false&&document.getElementById("rblCONNUBIALITY_True").checked==false){
	    txt=document.getElementById("rblCONNUBIALITY_False");
		alert('請選擇婚姻狀況');
		txt.focus();       
		return false;
		}
		
			/*if (document.getElementById("rblCHILD_False").checked==false&&document.getElementById("rblCHILD_True").checked==false){
	    txt=document.getElementById("rblCHILD_False");
		alert('請選擇子女');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById("ddlOCCUPATION").value=='00'){
	    txt=document.getElementById("ddlOCCUPATION");
		alert('請選擇職業');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById("ddlTITLE").value=='00'){
	    txt=document.getElementById("ddlTITLE");
		alert('請選擇職稱');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById("txtTELEPHONE1").value==''){
	    txt=document.getElementById("txtTELEPHONE1");
		alert('請輸入聯絡電話');
		txt.focus();       
		return false;
		}
		
	
		
	
	
	
		
	/*	
			if (document.getElementById("ddlCITY_COD").value=='請選擇'){
	    txt=document.getElementById("ddlCITY_COD");
		alert('請選擇通訊地址縣市');
		txt.focus();       
		return false;
		}				
	
		if (document.getElementById("hidAREA_COD").value=='請選擇'||document.getElementById("hidAREA_COD").value==''){
	    txt=document.getElementById("hidAREA_COD");
		alert('請選擇通訊地址地區');
		txt.focus();       
		return false;
		}				
		*/
		
			if (document.getElementById("txtemail_1").value==''){
	    txt=document.getElementById("txtemail_1");
		alert('請輸入E-Mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById("txtemail_1").value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById("txtemail_1");
                alert("請輸入正確的E-Mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
		if (document.getElementById("txtADDRESS_1").value==''){
	    txt=document.getElementById("txtADDRESS_1");
		alert('請選擇通訊地址');
		txt.focus();       
		return false;
		}
	
	
}

function checktxt_2(type){
var txt;
 		
   if (document.getElementById("txtUSER_ID_2").value==''){
	    txt=document.getElementById("txtUSER_ID_2");
		alert('請輸入統一編號');
		txt.focus();       
		return false;
		}
		
if (type=='true'){
	if (document.getElementById("txtPASSWORD_2").value==''){
	txt=document.getElementById("txtPASSWORD_2");
	alert('請輸入密碼');
	txt.focus();       
	return false;
	}		
	
	if (document.getElementById("txtPASSWORD_R_2").value==''){
	    txt=document.getElementById("txtPASSWORD_R_2");
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}
	}
	
	
	if (document.getElementById("txtPASSWORD_2").value!=document.getElementById("txtPASSWORD_R_2").value){
	    txt=document.getElementById("txtPASSWORD_2");
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById("txtname_2").value==''){
	    txt=document.getElementById("txtname_2");
		alert('請輸入公司名稱');
		txt.focus();       
		return false;
		}
	
	if (document.getElementById("txtename_2").value==''){
	    txt=document.getElementById("txtename_2");
		alert('請輸入公司簡稱');
		txt.focus();       
		return false;
		}
	
			if (document.getElementById("txtSNAME_2").value==''){
	    txt=document.getElementById("txtSNAME_2");
		alert('請輸入聯絡人');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById("txtCELLPHONE2_2").value==''){
	    txt=document.getElementById("txtCELLPHONE2_2");
		alert('請輸入聯絡人職稱');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById("txtTELEPHONE1_2").value==''){
	    txt=document.getElementById("txtTELEPHONE1_2");
		alert('請輸入公司電話');
		txt.focus();       
		return false;
		}
		
			
		if (document.getElementById("txtemail_2").value==''){
	    txt=document.getElementById("txtemail_2");
		alert('請輸入E-Mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById("txtemail_2").value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById("txtemail_2");
                alert("請輸入正確的E-Mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
		if (document.getElementById("txtADDRESS_2").value==''){
	    txt=document.getElementById("txtADDRESS_2");
		alert('請輸入公司地址');
		txt.focus();       
		return false;
		}
	
}

function trim(instr){
  return instr.replace(/^[\s]*/gi,"").replace(/[\s]*$/gi,"");
}


function checkEnter(){

if (window.event.keyCode == 13){

  switch (window.event.srcElement.id){  
	     case "txtUSER_ID":document.getElementById("ibtnLogin").focus();break;
	     case "txtPASSWORD":document.getElementById("ibtnLogin").focus();break;	   
	     case "Search1_txtemail":document.getElementById("Search1_ibtnOK").focus();break;
	     case "Search1_txtsearch":document.getElementById("Search1_asearch").click();
	     window.event.keyCode = 0;     
         window.event.returnValue=false ;
	     break;
	     default:
	     // document.getElementById("Login1_ibtnLogin").focus();          
	     break;	 
	    }		

}
}

function getByteLength(strIN){
//計算byte
  var i, cnt=0;
  for (i=0; i<strIN.length; i++){
    if (escape(strIN.charAt(i)).length >= 4) cnt+=2;
    else cnt++;
  }
  return cnt;
}
function checklogin(txtUSER_ID,txtPASSWORD){
var txt;			
	if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入帳號');
		txt.focus();       
		return false;
		}		
	if (document.getElementById(txtPASSWORD).value==''){
	    txt=document.getElementById(txtPASSWORD);
		alert('請輸入密碼');
		txt.focus();       
		return false;
		}		
}

function checkforget(txtUSER_ID,txtemail){
var txt;			
	if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入帳號');
		txt.focus();       
		return false;
		}		
	if (document.getElementById(txtemail).value==''){
	    txt=document.getElementById(txtemail);
		alert('請輸入電子信箱');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail);
                alert("請輸入正確的電子信箱"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
}

function checkcontact(txtUSER_ID,txttel,txtemail,txtsubject,txtq){
var txt;			
	if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入帳號');
		txt.focus();       
		return false;
		}		
	if (document.getElementById(txttel).value==''){
	    txt=document.getElementById(txttel);
		alert('請輸入連絡電話');
		txt.focus();       
		return false;
		}
	if (document.getElementById(txtemail).value==''){
	    txt=document.getElementById(txtemail);
		alert('請輸入連絡信箱');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail);
                alert("請輸入正確的連絡信箱"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
		if (document.getElementById(txtsubject).value==''){
	    txt=document.getElementById(txtsubject);
		alert('請輸入主旨');
		txt.focus();       
		return false;
		}
			if (document.getElementById(txtq).value==''){
	    txt=document.getElementById(txtq);
		alert('請輸入說明');
		txt.focus();       
		return false;
		}
}

function checkddl(ddlyear,ddlmonth){
var txt;
var yy="";
var mm="";
	if (document.getElementById(ddlyear).value=='請選擇'){
	    txt=document.getElementById(ddlyear);
		alert('請選擇(年)');
		txt.focus();       
		return false;
		}else{
		yy=document.getElementById(ddlyear).value;
		}	
	if (document.getElementById(ddlmonth).value=='請選擇'){
	    /*txt=document.getElementById(ddlmonth);
		alert('請選擇(月)');
		txt.focus();       
		return false;*/
		}else{
		mm=document.getElementById(ddlmonth).value;
		}	
location.href='news.aspx?year='+yy+'&month='+mm;								
return false;

}



function checkjoin(txtUSER_ID,txtPASSWORD,txtR_PASSWORD,txtemail,txtNAME,ddlyear,ddlmonth,ddlday,rblF,rblM,txtimgcheck,ddlMember){
var txt;	    
	if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入帳號');
		txt.focus();       
		return false;
		}
			
	if (document.getElementById(txtPASSWORD).value==''){
	    txt=document.getElementById(txtPASSWORD);
		alert('請輸入密碼');
		txt.focus();       
		return false;
		}		
	if (document.getElementById(txtR_PASSWORD).value==''){
	    txt=document.getElementById(txtR_PASSWORD);
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}			
	
		if (document.getElementById(txtPASSWORD).value!=document.getElementById(txtR_PASSWORD).value){
	    txt=document.getElementById(txtPASSWORD);
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}	
		
		if (document.getElementById(txtemail).value==''){
	    txt=document.getElementById(txtemail);
		alert('請輸入電子信箱');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail);
                alert("請輸入正確的電子信箱"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
	
	if (document.getElementById(ddlMember).value=='請選擇'){
	    txt=document.getElementById(ddlMember);
		alert('請選擇成員身分');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtNAME).value==''){
	    txt=document.getElementById(txtNAME);
		alert('請輸入網路代稱');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(ddlyear).value=='請選擇'){
	    txt=document.getElementById(ddlyear);
		alert('請選擇生日(年)');
		txt.focus();       
		return false;
		}		
	   if (document.getElementById(ddlmonth).value=='請選擇'){
	    txt=document.getElementById(ddlmonth);
		alert('請選擇生日(月)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(ddlday).value=='請選擇'){
	    txt=document.getElementById(ddlday);
		alert('請選擇生日(月)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(rblF).checked==false&&document.getElementById(rblM).checked==false){
				 txt=document.getElementById(rblF);
		alert('請選擇性別');
		txt.focus();       
		return false;
		}			
		
			if (document.getElementById(txtimgcheck).value==''){
	    txt=document.getElementById(txtimgcheck);
		alert('請輸入圖片驗證');
		txt.focus();       
		return false;
		}
				

}


function checkinfo(txtPASSWORD,txtR_PASSWORD,txtemail,txtNAME,ddlyear,ddlmonth,ddlday,rblF,rblM,ddlMember){
var txt;	
if (document.getElementById(txtPASSWORD).value!=''||document.getElementById(txtR_PASSWORD).value!=''){
if (document.getElementById(txtPASSWORD).value==''){
	    txt=document.getElementById(txtPASSWORD);
		alert('請輸入密碼');
		txt.focus();       
		return false;
		}		
	if (document.getElementById(txtR_PASSWORD).value==''){
	    txt=document.getElementById(txtR_PASSWORD);
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}			
	
		if (document.getElementById(txtPASSWORD).value!=document.getElementById(txtR_PASSWORD).value){
	    txt=document.getElementById(txtPASSWORD);
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}	
}
	
		
		if (document.getElementById(txtemail).value==''){
	    txt=document.getElementById(txtemail);
		alert('請輸入電子信箱');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail);
                alert("請輸入正確的電子信箱"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
	if (document.getElementById(ddlMember).value=='請選擇'){
	    txt=document.getElementById(ddlMember);
		alert('請選擇成員身分');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtNAME).value==''){
	    txt=document.getElementById(txtNAME);
		alert('請輸入網路代稱');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(ddlyear).value=='請選擇'){
	    txt=document.getElementById(ddlyear);
		alert('請選擇生日(年)');
		txt.focus();       
		return false;
		}		
	   if (document.getElementById(ddlmonth).value=='請選擇'){
	    txt=document.getElementById(ddlmonth);
		alert('請選擇生日(月)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(ddlday).value=='請選擇'){
	    txt=document.getElementById(ddlday);
		alert('請選擇生日(月)');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(rblF).checked==false&&document.getElementById(rblM).checked==false){
				 txt=document.getElementById(rblF);
		alert('請選擇性別');
		txt.focus();       
		return false;
		}	
}

//檢查身份證
function gfcChkID(pID)
{
    //var tobjRtn = new Object();
    var tobjRtn = true;
    var ixI;
    var tAreaNo;
    var tSum;
    var tAreaCode;
    var tSecondID;         //身份證第二碼

    if (pID == "" || pID == null)
    {
        //tobjRtn.eErr = false;
        tobjRtn = false;
        return tobjRtn;
    }
    tobjRtn.eErr = true;
    pID = pID.toUpperCase(); 
    if (pID.length != 10)//確定身份證字號有10碼
    {   
        //tobjRtn.eErrDesc = gfcGetErrDesc('S010');
        tobjRtn = false;
        return tobjRtn;             
    }       
    tAreaCode = pID.substr(0,1);
    if (tAreaCode.valueOf() < "A" || tAreaCode.valueOf() > "Z")//確定首碼在A-Z之間
    {   
        //tobjRtn.eErrDesc = gfcGetErrDesc('S011');
        tobjRtn = false;
        return tobjRtn;
    }  
    if (isNaN(parseInt(pID.substring(1,10),10)) == true) //確定2-10碼是數字
    {   
        //tobjRtn.eErrDesc = gfcGetErrDesc('S012');
        tobjRtn = false;
        return tobjRtn;
    }   
    //身份證號碼第 2 碼必須為 1 或 2
    tSecondID = pID.substr(1,1);
    if (tSecondID != "1" && tSecondID != "2")
    {   
        //tobjRtn.eErrDesc = gfcGetErrDesc('S013');
        tobjRtn = false;
        return tobjRtn;
    }
    //取得首碼對應的區域碼，A ->10, B->11, ..H->17,I->34, J->18...
    tAreaNo = "ABCDEFGHJKLMNPQRSTUVXYWZIO".search(tAreaCode) + 10;
    pID = tAreaNo.toString(10) + pID.substring(1,10);   
   
    //  取得CheckSum的值
    //  核對身份證號碼是否正確
    //  A  = 身份證號碼區域碼第 1碼
    //  A0 = 身份證號碼區域碼第 2碼 * (10 - 1)
    //  A1 = 身份證號碼第 2碼 * (10 - 2)
    //  A2 = 身份證號碼第 3碼 * (10 - 3)
    //  A3 = 身份證號碼第 4碼 * (10 - 4)
    //  A4 = 身份證號碼第 5碼 * (10 - 5)
    //  A5 = 身份證號碼第 6碼 * (10 - 6)
    //  A6 = 身份證號碼第 7碼 * (10 - 7)
    //  A7 = 身份證號碼第 8碼 * (10 - 8)
    //  A8 = 身份證號碼第 9碼 * (10 - 9)
    //  CheckSum = A + A0 + A1 + A2 + ........ + A7 + A8

    tSum = parseInt(pID.substr(0,1),10) + parseInt(pID.substr(10,1),10);   

    for(ixI=1;ixI<=9;ixI++)
    {   
        tSum = tSum + parseInt(pID.substr(ixI,1),10)*(10-ixI);
    }  
	
    if ((tSum % 10) != 0)
    {
        //tobjRtn.eErrDesc = gfcGetErrDesc('S013');
        tobjRtn = false;
        return tobjRtn;
    }
    //tobjRtn.eErr = false;
    tobjRtn = true;
    return tobjRtn;
}

function testNu2m(){
//48~57是數字0~9
//40~57是數字0~9跟一些電話號碼符號
//35是#號
if ( !(window.event.keyCode>=35 && window.event.keyCode<=57 ))
      window.event.keyCode = 0;
}

function r_imgcheck(id){
document.getElementById(id).outerHTML='<img style="cursor:hand" id=imgcheck onclick="r_imgcheck(this.id);" src=imgcheck.aspx>';
}

