﻿function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function trim(instr){
  return instr.replace(/^[\s]*/gi,"").replace(/[\s]*$/gi,"");
}


function checkEnter(){
if (window.event.keyCode == 13){
document.getElementById("ibtnOK").focus();
}
}

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 checksingup(txtname,ddlyear,ddlmonth,ddlday,txtPIC1_TITLE,txtPIC1_DESC,txtPIC1_LINK,txtPIC2_TITLE,txtPIC2_DESC,txtPIC2_LINK,txtMETA_DESC){
 var txt;
   	
 	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(txtPIC1_TITLE).value==''){
	txt=document.getElementById(txtPIC1_TITLE);
	alert('請輸入生產醫院 ');
	txt.focus();       
	return false;
	}	
   if (document.getElementById(txtPIC1_DESC).value==''&&document.getElementById(txtPIC1_LINK).value==''&&document.getElementById(txtPIC2_TITLE).value==''){
	txt=document.getElementById(txtPIC1_DESC);
	alert('請輸入聯絡電話');
	txt.focus();       
	return false;
	}	
	
	if (document.getElementById(txtPIC2_DESC).value==''){
	txt=document.getElementById(txtPIC2_DESC);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}	
	
	
 if (document.getElementById(txtPIC2_LINK).value==''){
	    txt=document.getElementById(txtPIC2_LINK);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtPIC2_LINK).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtPIC2_LINK);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
	
	 if (document.getElementById(txtMETA_DESC).value==''){
	txt=document.getElementById(txtMETA_DESC);
	alert('請輸入參加人數');
	txt.focus();       
	return false;
	}	

}

function checkcom(txtNAME,txtPRODUCT_NO,txtSNAME,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtFILE3_DESC,txtFILE1_TITLE){
 var txt;
	
	if (document.getElementById(txtNAME).value==''){
	txt=document.getElementById(txtNAME);
	alert('請輸入企業行號、團體名稱');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtPRODUCT_NO).value==''){
	txt=document.getElementById(txtPRODUCT_NO);
	alert('請輸入主要聯絡人');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtSNAME).value==''){
	txt=document.getElementById(txtSNAME);
	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(ddlAREA_COD);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtFILE3_DESC).value==''){
	txt=document.getElementById(txtFILE3_DESC);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}						
	
 if (document.getElementById(txtFILE1_TITLE).value==''){
	    txt=document.getElementById(txtFILE1_TITLE);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtFILE1_TITLE).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtFILE1_TITLE);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	}	
	
}

function checkdownload_public(txtNAME,txtPRODUCT_NO,txtDATE_year,txtDATE_month,txtDATE_day,txtSNAME,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtFILE3_DESC,txtFILE1_TITLE,ddlyear,ddlMonth,ddlDay,ins_id,hidPIC2){
 var txt;
 
   	if (ins_id=="7"&&document.getElementById(hidPIC2).value=="0"){
   	alert('請選擇您要下載的檔案');	 
	return false;
   	}
 
	
	if (document.getElementById(txtPRODUCT_NO).value==''){
	txt=document.getElementById(txtPRODUCT_NO);
	alert('請輸入姓名');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtDATE_year).value==''){
	txt=document.getElementById(txtDATE_year);
	alert('請輸入生日(年)');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtDATE_month).value==''){
	txt=document.getElementById(txtDATE_month);
	alert('請輸入生日(月)');
	txt.focus();       
	return false;
	}	
	if (document.getElementById(txtDATE_day).value==''){
	txt=document.getElementById(txtDATE_day);
	alert('請輸入生日(日)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtSNAME).value==''){
	txt=document.getElementById(txtSNAME);
	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(ddlAREA_COD);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtFILE3_DESC).value==''){
	txt=document.getElementById(txtFILE3_DESC);
	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(txtFILE1_TITLE).value==''){
	    txt=document.getElementById(txtFILE1_TITLE);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtFILE1_TITLE).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtFILE1_TITLE);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	}
			
			
    	if (document.getElementById(txtNAME).value==''){
	txt=document.getElementById(txtNAME);
	alert('請輸入生產醫院名稱');
	txt.focus();       
	return false;
	}
}


function checksend_friend_new(txtname1,txtC1,txtTel1,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtAdd1,txtemail1,ddlyear,ddlMonth,ddlDay,txtname2,txtyear,txtmonth,txtday,txtday,txtC2,txtTel2,ddlCITY_COD2,ddlAREA_COD2,hidAREA_COD2,txtAdd2,txtemail2){
 var txt;
	if (document.getElementById(txtname1).value==''){
	txt=document.getElementById(txtname1);
	alert('請輸入姓名');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtC1).value==''){
	txt=document.getElementById(txtC1);
	alert('請輸入生產醫院');
	txt.focus();       
	return false;
	}

    if (document.getElementById(txtTel1).value==''){
	txt=document.getElementById(txtTel1);
	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(ddlAREA_COD);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtAdd1).value==''){
	txt=document.getElementById(txtAdd1);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}						
	
 if (document.getElementById(txtemail1).value==''){
	    txt=document.getElementById(txtemail1);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail1).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail1);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                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(txtname2).value==''){
	txt=document.getElementById(txtname2);
	alert('請輸入姓名');
	txt.focus();       
	return false;
	}
	
	/*if (document.getElementById(txtyear).value==''){
	txt=document.getElementById(txtyear);
	alert('請輸入生日(年)');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtmonth).value==''){
	txt=document.getElementById(txtmonth);
	alert('請輸入生日(月)');
	txt.focus();       
	return false;
	}	
	if (document.getElementById(txtday).value==''){
	txt=document.getElementById(txtday);
	alert('請輸入生日(日)');
	txt.focus();       
	return false;
	}
	*/
	
	if (document.getElementById(txtC2).value==''){
	txt=document.getElementById(txtC2);
	alert('請輸入身份證字號');
	txt.focus();       
	return false;
	}else{
	 if (gfcChkID(document.getElementById(txtC2).value)==false){
	 txt=document.getElementById(txtC2);
	alert('請輸入正確的身份證字號');
	txt.focus();       
	return false;
	 }
	}

    if (document.getElementById(txtTel2).value==''){
	txt=document.getElementById(txtTel2);
	alert('請輸入聯絡電話');
	txt.focus();       
	return false;
	}

	    /*if (document.getElementById(ddlCITY_COD2).value=='請選擇'){
	txt=document.getElementById(ddlCITY_COD2);
	alert('請選擇聯絡地址(縣市)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(hidAREA_COD2).value=='請選擇'||document.getElementById(hidAREA_COD2).value==''){
	txt=document.getElementById(ddlAREA_COD2);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtAdd2).value==''){
	txt=document.getElementById(txtAdd2);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}		*/				
	
 if (document.getElementById(txtemail2).value==''){
	    txt=document.getElementById(txtemail2);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail2).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail2);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	}
	}	
}


function checksend_friend(txtname1,txtC1,txtTel1,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtAdd1,txtemail1,ddlyear,ddlMonth,ddlDay,txtname2,txtyear,txtmonth,txtday,txtday,txtC2,txtTel2,ddlCITY_COD2,ddlAREA_COD2,hidAREA_COD2,txtAdd2,txtemail2,rblPIC10_TITLE_1,rblPIC10_TITLE_2,rblPIC10_TITLE_3){
 var txt;
	if (document.getElementById(txtname1).value==''){
	txt=document.getElementById(txtname1);
	alert('請輸入姓名');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtC1).value==''){
	txt=document.getElementById(txtC1);
	alert('請輸入生產醫院');
	txt.focus();       
	return false;
	}

    if (document.getElementById(txtTel1).value==''){
	txt=document.getElementById(txtTel1);
	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(ddlAREA_COD);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtAdd1).value==''){
	txt=document.getElementById(txtAdd1);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}						
	
 if (document.getElementById(txtemail1).value==''){
	    txt=document.getElementById(txtemail1);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail1).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail1);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                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(txtname2).value==''){
	txt=document.getElementById(txtname2);
	alert('請輸入姓名');
	txt.focus();       
	return false;
	}
	
	/*if (document.getElementById(txtyear).value==''){
	txt=document.getElementById(txtyear);
	alert('請輸入生日(年)');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtmonth).value==''){
	txt=document.getElementById(txtmonth);
	alert('請輸入生日(月)');
	txt.focus();       
	return false;
	}	
	if (document.getElementById(txtday).value==''){
	txt=document.getElementById(txtday);
	alert('請輸入生日(日)');
	txt.focus();       
	return false;
	}
	*/
	
	if (document.getElementById(txtC2).value==''){
	txt=document.getElementById(txtC2);
	alert('請輸入身份證字號');
	txt.focus();       
	return false;
	}else{
	 if (gfcChkID(document.getElementById(txtC2).value)==false){
	 txt=document.getElementById(txtC2);
	alert('請輸入正確的身份證字號');
	txt.focus();       
	return false;
	 }
	}

    if (document.getElementById(txtTel2).value==''){
	txt=document.getElementById(txtTel2);
	alert('請輸入聯絡電話');
	txt.focus();       
	return false;
	}

	    /*if (document.getElementById(ddlCITY_COD2).value=='請選擇'){
	txt=document.getElementById(ddlCITY_COD2);
	alert('請選擇聯絡地址(縣市)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(hidAREA_COD2).value=='請選擇'||document.getElementById(hidAREA_COD2).value==''){
	txt=document.getElementById(ddlAREA_COD2);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtAdd2).value==''){
	txt=document.getElementById(txtAdd2);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}		*/				
	
 if (document.getElementById(txtemail2).value==''){
	    txt=document.getElementById(txtemail2);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtemail2).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtemail2);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	}
	
	if (document.getElementById(rblPIC10_TITLE_1).checked==false&&document.getElementById(rblPIC10_TITLE_2).checked==false&&document.getElementById(rblPIC10_TITLE_3).checked==false){
	txt=document.getElementById(rblPIC10_TITLE_1);
	alert('請選擇贈品選項');
	txt.focus();       
	return false;
	}
	
}


function checkto_send_friend(txtf_email,txtname,txtemail,txtq){
 var txt;		
	
 if (document.getElementById(txtf_email).value==''){
	    txt=document.getElementById(txtf_email);
		alert('請輸入朋友信箱');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtf_email).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtf_email);
                alert("請輸入正確的朋友信箱"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	}
	
	if (document.getElementById(txtname).value==''){
	txt=document.getElementById(txtname);
	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(txtq).value==''){
	txt=document.getElementById(txtq);
	alert('請輸入訊息');
	txt.focus();       
	return false;
	}
}


function checkdownload(txtNAME,txtPRODUCT_NO,txtDATE_year,txtDATE_month,txtDATE_day,txtSNAME,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtFILE3_DESC,txtFILE1_TITLE){
 var txt;
   	
 	if (document.getElementById(txtNAME).value==''){
	txt=document.getElementById(txtNAME);
	alert('請輸入醫院名稱');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtPRODUCT_NO).value==''){
	txt=document.getElementById(txtPRODUCT_NO);
	alert('請輸入聯絡姓名');
	txt.focus();       
	return false;
	}
	
	/*if (document.getElementById(txtDATE_year).value==''){
	txt=document.getElementById(txtDATE_year);
	alert('請輸入生日(年)');
	txt.focus();       
	return false;
	}
	
	if (document.getElementById(txtDATE_month).value==''){
	txt=document.getElementById(txtDATE_month);
	alert('請輸入生日(月)');
	txt.focus();       
	return false;
	}	
	if (document.getElementById(txtDATE_day).value==''){
	txt=document.getElementById(txtDATE_day);
	alert('請輸入生日(日)');
	txt.focus();       
	return false;
	}*/
	
		if (document.getElementById(txtSNAME).value==''){
	txt=document.getElementById(txtSNAME);
	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(ddlAREA_COD);
	alert('請選擇聯絡地址(地區)');
	txt.focus();       
	return false;
	}
	
		if (document.getElementById(txtFILE3_DESC).value==''){
	txt=document.getElementById(txtFILE3_DESC);
	alert('請輸入聯絡地址');
	txt.focus();       
	return false;
	}						
	
 if (document.getElementById(txtFILE1_TITLE).value==''){
	    txt=document.getElementById(txtFILE1_TITLE);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtFILE1_TITLE).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtFILE1_TITLE);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 

}

function checkforget(txtname,txtIDENTITY,ddlyear,ddlMonth,ddlDay){
 var txt;
 
 if (trim(document.getElementById(txtname).value)==''){
	    txt=document.getElementById(txtname);
		alert('請輸入中文姓名');
		txt.focus();       
		return false;
	    }else{	    
	     if ((trim(document.getElementById(txtname).value).length*2)!=getByteLength(document.getElementById(txtname).value)){
	      txt=document.getElementById(txtname);
		  alert('請輸入正確中文姓名\n請勿輸入其他字元');
		  txt.focus();       
		  return false;
	     }
	    }
	    
 if (document.getElementById(txtIDENTITY).value==''){
	    txt=document.getElementById(txtIDENTITY);
		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;
		}		
			
}

function checktxt(txtUSER_ID,txtPASSWORD,txtPASSWORD_r,txtIDENTITY,rblNAONALITY_Y,rblNAONALITY_N,txtname,rblM,rblF,ddlyear,ddlMonth,ddlDay,txtTELEPHONE1_1,txtTELEPHONE1_2,txtTELEPHONE2_1,txtTELEPHONE2_2,txtCELLPHONE1,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtADDRESS){
var txt;

   if (document.getElementById(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入E-mail 帳號');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtUSER_ID).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtUSER_ID);
                alert("請輸入正確的E-mail 帳號"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
	
	if (document.getElementById(txtPASSWORD).value==''){
	txt=document.getElementById(txtPASSWORD);
	alert('請輸入密碼');
	txt.focus();       
	return false;
	}		
	
	if (document.getElementById(txtPASSWORD_r).value==''){
	    txt=document.getElementById(txtPASSWORD_r);
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}
	
	if (document.getElementById(txtPASSWORD).value!=document.getElementById(txtPASSWORD_r).value){
	    txt=document.getElementById(txtPASSWORD);
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById(txtIDENTITY).value==''){
	    txt=document.getElementById(txtIDENTITY);
		alert('請輸入身分證字號');
		txt.focus();       
		return false;
		}else{ 
		  
				if (gfcChkID(trim(document.getElementById(txtIDENTITY).value))==false&&document.getElementById(rblNAONALITY_Y).checked==true){
				txt=document.getElementById(txtIDENTITY);
				alert('帳號(身份證字號不正確)');
				txt.focus(); 
				return false;
				}
		}		
			

       if (document.getElementById(rblNAONALITY_Y).checked==false&&document.getElementById(rblNAONALITY_N).checked==false){
	    txt=document.getElementById(rblNAONALITY_Y);
		alert('請選擇您是台灣人士或外籍人士');
		txt.focus();       
		return false;
		}	
			
		if (trim(document.getElementById(txtname).value)==''){
	    txt=document.getElementById(txtname);
		alert('請輸入中文姓名');
		txt.focus();       
		return false;
	    }else{	    
	     if ((trim(document.getElementById(txtname).value).length*2)!=getByteLength(document.getElementById(txtname).value)){
	      txt=document.getElementById(txtname);
		  alert('請輸入正確中文姓名\n請勿輸入其他字元');
		  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(rblM).checked==false&&document.getElementById(rblF).checked==false){
	    txt=document.getElementById(rblM);
		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(txtTELEPHONE1_1).value==''){
	    txt=document.getElementById(txtTELEPHONE1_1);
		alert('請輸入聯絡電話(日) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE1_2).value==''){
	    txt=document.getElementById(txtTELEPHONE1_2);
		alert('請輸入聯絡電話(日)電話號碼');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById(txtTELEPHONE2_1).value==''){
	    txt=document.getElementById(txtTELEPHONE2_1);
		alert('請輸入聯絡電話(夜) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE2_2).value==''){
	    txt=document.getElementById(txtTELEPHONE2_2);
		alert('請輸入聯絡電話(夜)電話號碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtCELLPHONE1).value==''){
	    txt=document.getElementById(txtCELLPHONE1);
		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(ddlAREA_COD);
		alert('請選擇居住地址(鄉鎮市區)');
		txt.focus();       
		return false;
		}								
			
		if (document.getElementById(txtADDRESS).value==''){
	    txt=document.getElementById(txtADDRESS);
		alert('請選擇居住地址(地址)');
		txt.focus();       
		return false;
		}
			

}

function checktxt_u(txtPASSWORD_old,txtPASSWORD,txtPASSWORD_r,rblM,rblF,ddlyear,ddlMonth,ddlDay,txtTELEPHONE1_1,txtTELEPHONE1_2,txtTELEPHONE2_1,txtTELEPHONE2_2,txtCELLPHONE1,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtADDRESS){
var txt;		
	
	
	if (document.getElementById(txtPASSWORD_old).value==''){
	txt=document.getElementById(txtPASSWORD_old);
	alert('請輸入網路會友密碼');
	txt.focus();       
	return false;
	}		
	
	if (document.getElementById(txtPASSWORD).value==''){
	txt=document.getElementById(txtPASSWORD);
	alert('請輸入密碼');
	txt.focus();       
	return false;
	}		
	
	if (document.getElementById(txtPASSWORD_r).value==''){
	    txt=document.getElementById(txtPASSWORD_r);
		alert('請輸入確認密碼');
		txt.focus();       
		return false;
		}
	
	if (document.getElementById(txtPASSWORD).value!=document.getElementById(txtPASSWORD_r).value){
	    txt=document.getElementById(txtPASSWORD);
		alert('密碼與確認密碼不符');
		txt.focus();       
		return false;
		}
		

	
		if (document.getElementById(rblM).checked==false&&document.getElementById(rblF).checked==false){
	    txt=document.getElementById(rblM);
		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(txtTELEPHONE1_1).value==''){
	    txt=document.getElementById(txtTELEPHONE1_1);
		alert('請輸入聯絡電話(日) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE1_2).value==''){
	    txt=document.getElementById(txtTELEPHONE1_2);
		alert('請輸入聯絡電話(日)電話號碼');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById(txtTELEPHONE2_1).value==''){
	    txt=document.getElementById(txtTELEPHONE2_1);
		alert('請輸入聯絡電話(夜) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE2_2).value==''){
	    txt=document.getElementById(txtTELEPHONE2_2);
		alert('請輸入聯絡電話(夜)電話號碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtCELLPHONE1).value==''){
	    txt=document.getElementById(txtCELLPHONE1);
		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(ddlAREA_COD);
		alert('請選擇居住地址(鄉鎮市區)');
		txt.focus();       
		return false;
		}								
			
		if (document.getElementById(txtADDRESS).value==''){
	    txt=document.getElementById(txtADDRESS);
		alert('請選擇居住地址(地址)');
		txt.focus();       
		return false;
		}
}


function checkCart(txtmoney,txtname,rblM,rblF,txtUSER_ID,ddlyear,ddlMonth,ddlDay,txtTELEPHONE1_1,txtTELEPHONE1_2,txtTELEPHONE2_1,txtTELEPHONE2_2,txtCELLPHONE1,ddlCITY_COD,ddlAREA_COD,hidAREA_COD,txtADDRESS,rblTITLE,rblOCCUPATION,rblscrip_y,rblscrip_n,rblscrip_y_man,rblscrip_y_co,txtscrip_id,txtscrip_y_NAME,rblscrip_y_m,rblscrip_y_f,txtscrip_y_ADDRESS){

var txt;
   	if (document.getElementById(txtmoney).value==''){
	txt=document.getElementById(txtmoney);
	alert('請輸入急難救濟金');
	txt.focus();       
	return false;
	}else{
	 if (isNaN(document.getElementById(txtmoney).value)==true){
	  txt=document.getElementById(txtmoney);
	  alert('急難救濟金請以阿拉伯數字輸入');
	  txt.focus();       
	  return false;
	 }
	 	if (document.getElementById(txtmoney).value=='0'){
	txt=document.getElementById(txtmoney);
	alert('急難救濟金必須大於0元以上');
	txt.focus();       
	return false;
	}
	}		
	
		if (document.getElementById(rblM).checked==false&&document.getElementById(rblF).checked==false){
	    txt=document.getElementById(rblM);
		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(txtUSER_ID).value==''){
	    txt=document.getElementById(txtUSER_ID);
		alert('請輸入E-mail');
		txt.focus();       
		return false;
		}else{
		    var fobj=document.getElementById(txtUSER_ID).value;
            var check=/.+@.+\..+/;
            if (fobj.match(check) ==null ){
                txt=document.getElementById(txtUSER_ID);
                alert("請輸入正確的E-mail"); 
                txt.focus(); 
                txt.value="";
                return false;
              } 
	
	} 
				
		if (trim(document.getElementById(txtname).value)==''){
	    txt=document.getElementById(txtname);
		alert('請輸入中文姓名');
		txt.focus();       
		return false;
	    }
	    /*
	    else{	    
	     if ((trim(document.getElementById(txtname).value).length*2)!=getByteLength(document.getElementById(txtname).value)){
	      txt=document.getElementById(txtname);
		  alert('請輸入正確中文姓名\n請勿輸入其他字元');
		  txt.focus();       
		  return false;
	     }
	    }*/	
				
		
		
		if (document.getElementById(txtTELEPHONE1_1).value==''){
	    txt=document.getElementById(txtTELEPHONE1_1);
		alert('請輸入聯絡電話(日) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE1_2).value==''){
	    txt=document.getElementById(txtTELEPHONE1_2);
		alert('請輸入聯絡電話(日)電話號碼');
		txt.focus();       
		return false;
		}
		
			if (document.getElementById(txtTELEPHONE2_1).value==''){
	    txt=document.getElementById(txtTELEPHONE2_1);
		alert('請輸入聯絡電話(夜) 區碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtTELEPHONE2_2).value==''){
	    txt=document.getElementById(txtTELEPHONE2_2);
		alert('請輸入聯絡電話(夜)電話號碼');
		txt.focus();       
		return false;
		}
		
		if (document.getElementById(txtCELLPHONE1).value==''){
	    txt=document.getElementById(txtCELLPHONE1);
		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(ddlAREA_COD);
		alert('請選擇居住地址(鄉鎮市區)');
		txt.focus();       
		return false;
		}								
			
		if (document.getElementById(txtADDRESS).value==''){
	    txt=document.getElementById(txtADDRESS);
		alert('請選擇居住地址(地址)');
		txt.focus();       
		return false;
		}
		
		
		if (document.getElementById(rblscrip_y).checked==false&&document.getElementById(rblscrip_n).checked==false){
	    txt=document.getElementById(rblscrip_y);
		alert('請選擇需不需要開立收據');
		txt.focus();       
		return false;
		}
		
	if (document.getElementById(rblscrip_y).checked==true){	  
	//需要的話
	
	    if (document.getElementById(rblscrip_y_man).checked==false&&document.getElementById(rblscrip_y_co).checked==false){	    
	       txt=document.getElementById(rblscrip_y_man);
		   alert('請選擇開立收據屬個人或公司');
		   txt.focus();       
		   return false;
		  } 
		   
		   if (document.getElementById(rblscrip_y_co).checked==true){
				if (document.getElementById(txtscrip_id).value==""){
				txt=document.getElementById(txtscrip_id);
				alert('請輸入開立收據公司統一編號');
				txt.focus();       
				return false;
				}else{
				if (document.getElementById(txtscrip_id).value.length!=8||isNaN(document.getElementById(txtscrip_id).value)==true){
					txt=document.getElementById(txtscrip_id);
					alert('請輸入正確的公司統一編號');
					txt.focus();
					return false;  
				}
		     }		   
		   }
		   
		   //捐款人收據資料
		   if (document.getElementById(txtscrip_y_NAME).value==''){
			txt=document.getElementById(txtscrip_y_NAME);
			alert('請輸入捐款收據收件人姓名');
			txt.focus();       
			return false;
			}
			
				if (document.getElementById(rblscrip_y_m).checked==false&&document.getElementById(rblscrip_y_f).checked==false){
			txt=document.getElementById(rblscrip_y_m);
			alert('請選擇捐款收據收件人性別');
			txt.focus();       
			return false;
			}
			
			 if (document.getElementById(txtscrip_y_ADDRESS).value==''){
			txt=document.getElementById(txtscrip_y_ADDRESS);
			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 testNum(){
if ( !(window.event.keyCode>=48 && window.event.keyCode<=57 ))
      window.event.keyCode = 0;
}
