﻿<!--//Public Function
function pwchk(s) {
	var b = "0123456789qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP";
	for(var i = 0; i < s.length ; i++){
		if (b.indexOf(s.substring(i,i+1)) == -1 ){
			return false;
			break;
		}
	}
	return true;
}
//-->

<!--//Self Submit
function goSelf(theform,thelink)
{
 theform.action = thelink;
 theform.submit();
}
//-->

function selfSUB(theform)
{
 theform.show.value = 'Y';
 theform.submit();
}

<!--//換頁
function goPage(theform,page)
{
 theform.page.value = page;
 theform.act.value = "search";
 theform.submit();
}
//-->

<!--//搜尋
function goSh(theform,page,theBTN,theType)
{
 theform.page.value = page;

  if (theType == 'PIC')
  {
   theform.shBtn.style.display = 'none';
  }
  else if (theType == 'BUTTON')
  {
   theform.elements[theBTN].disabled = true;
  }

 theform.submit();
}
//-->


<!--//清除(form name,which function)
function Clear_FRM(theform,thefunc)
 {

  if(thefunc == 'TAR_SET_SEARCH')
  {
	 theform.sKey.value = '';
	 theform.sArea.value = 'ALL';
	 theform.sUnit.value = '';
	 theform.sCha_M.value = '';
	 theform.sCha_S.value = '';
	 theform.sPer.value = '';
  }

 }
//-->

<!--//刪除選取
function REV_CEL(theform)
{
 theform.ACID.value = '0';
 theform.ACT.value = 'REVALL';
 theform.action = 'ACTION.asp';
 theform.submit();
}
//-->

<!--//送出選取
function SUB_CEL(theform)
{
 theform.ACID.value = '0';
 theform.ACT.value = 'SUBALL';
 theform.action = 'ACTION.asp';
 theform.submit();
}
//-->

<!-- //表單Check
function FRM_CHK(theform,thepage,theBTN,theType)
{
  var ErrString = '錯誤訊息 >>>>>' + unescape('%0D%0A');
  var ErrCnt = 0;

  <!--//
  if(thepage == 'LOGIN')
  {
	if(theform.login_id.value=="")
	 {
	   ErrString = ErrString + '◎請填寫帳號' + unescape('%0D%0A');
	   ErrCnt = ErrCnt + 1;
	 }
	if(theform.login_pwd.value=="")
	 {
	   ErrString = ErrString + '◎請填寫密碼' + unescape('%0D%0A');
	   ErrCnt = ErrCnt + 1;
	 }

  }

  // -->

  <!--//
  if(thepage == 'DataUpd')
  {
	if(theform.tel_code.value=="" || theform.tel.value=="")
	 {
	   ErrString = ErrString + '◎請填寫電話' + unescape('%0D%0A');
	   ErrCnt = ErrCnt + 1;
	 }
	if(theform.fax_code.value=="" || theform.fax.value=="")
	 {
	   ErrString = ErrString + '◎請填寫傳真' + unescape('%0D%0A');
	   ErrCnt = ErrCnt + 1;
	 }
	if(theform.email.value=="" )
	 {
	   ErrString = ErrString + '◎請填寫email' + unescape('%0D%0A');
	   ErrCnt = ErrCnt + 1;
	 }

	if(theform.email.value != "")
	 {
       mailcheck = checkemail(theform.email);
	   if(mailcheck == false){return false;} 
	 }

  }

  // -->

  <!--//FAQ
  if(thepage == 'FAQ')
  {
    if(theform.F1.value == '')
    {
	  ErrString = ErrString + '◎請填寫標題' + unescape('%0D%0A');
      ErrCnt = ErrCnt + 1;
    }
    else
	{
	  if(theform.F1.value.length > 50 )
		{
		  ErrString=ErrString + "◎標題至多可填寫50字" + unescape('%0D%0A') ;
		  ErrCnt = ErrCnt + 1;  
		}
	}
	

    if(theform.F4.value == '')
    {
	  ErrString = ErrString + '◎請填寫內文' + unescape('%0D%0A');
      ErrCnt = ErrCnt + 1;
    }
    else
	{
	  if(theform.F4.value.length > 3000 )
		{
		  ErrString=ErrString + "◎內文至多可填寫3000字" + unescape('%0D%0A') ;
		  ErrCnt = ErrCnt + 1;  
		}
	}
  
  }
  //-->

  if (ErrCnt != 0)
  {
   alert(ErrString);
   return false;
  }
  
  if (theType == 'PIC')
  {
   theform.sbBtn.style.display = 'none';
  }
  else if (theType == 'BUTTON')
  {
   theform.elements[theBTN].disabled = true;
  }

  theform.submit();
}
//-->

<!--// Number Check
 function NumberCHK(theform,thefield,theval)
  {
    if(isNaN(theval))
    {
     alert('請填入數字!!');
     theform.elements[thefield].focus();
     selectWord(thefield);
     return false;
    }
  }

// -->


<!-- //同上(客戶)
function CopyUP(theform)
{
 theform.address0_A.value = theform.address0.value;
 theform.address1_A.value = theform.address1.value;
 theform.ZIPCODE_A.value = theform.ZIPCODE.value;
 theform.ADDR_A.value = theform.ADDR.value;
}
//-->

function checkemail(InField) {
	var email = InField.value;
	invalidChars = " /:,;"
	if (email != "") {
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) != -1) {
				alert("E-mail 格式錯誤!");
	      InField.focus();
	      InField.select();				
				return false;
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) {
			alert("E-mail 格式錯誤!");
	    InField.focus();
	    InField.select();				
			return false;
		}
		if (email.indexOf("@",atPos+1) != -1) {
			alert("E-mail 格式錯誤!");
	    InField.focus();
	    InField.select();	
			return false;
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			alert("E-mail 格式錯誤!");
	    InField.focus();
	    InField.select();	
			return false;
		}
		if (periodPos+3 > email.length)	{
			alert("E-mail 格式錯誤!");
	    InField.focus();
	    InField.select();	
			return false;
		}
	}	
	return true;
}