function select_career()
{
        var career=document.formshenqing.career.value;
        if (career=='保險業')
        {
                var msg = prompt('請填上公司名稱 和 牌照 / 員工編號  e.g. ABC Company [123456]','');
                while (msg == '' || msg == null || msg.length>80)
                {
                        alert('必須填上正確資料.');
                        msg = prompt('公司名稱和 牌照員工編號','');
                }
		alert(msg);
                document.formshenqing.career_msg.value = msg;
        }else{
                document.formshenqing.career_msg.value = '';
        }
        //alert (a);
        //alert (msg);
        return;
}

function doit()
{
	if(window.event.keyCode==13)
	{
		window.event.keyCode=9;
	}
}



function kname()  //對對英文名字的判斷
{
	var a=document.formshenqing.ename.value;
	if(a=="")
	{
		alert("請填寫英文名字!"); 
		document.formshenqing.ename.focus();		
		return false;
	}
	else
	{ 
		var b=document.formshenqing.ename.value;
		document.formshenqing.creditname.value=b;
	} 
}

function commove17()
{
   if(window.event.keyCode==13)
    {
      document.formshenqing.cphone.focus();
   }
}
function commove18()
{
   if(window.event.keyCode==13)
    {
      document.formshenqing.fax.focus();
   }
}
function commove19()
{
   if(window.event.keyCode==13)
    {
      document.formshenqing.ename.focus();
   }
}


function custmove1()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.zname.focus();
    }
}
function custmove2()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.clongname.focus();
    }
}

function custmove3()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.email.focus();
    }
}

function custmove4()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.passw1.focus();
    }
}

function custmove5()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.passw2.focus();
    }
}

function custmove6()
{
   if(window.event.keyCode==13)
   {
     document.formshenqing.fund.focus();
    }
}

function typemove1()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.minfund.focus();
   }
}
function typemove2()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.perfund.focus();
   }
}
function typemove3()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.creditnum1.focus();
   }
}
function typemove4()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.creditdata1.focus();
   }
}
function typemove5()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.creditdata2.focus();
   }
}
function typemove6()
{
if(window.event.keyCode==13)
   {
     document.formshenqing.dd.focus();
   }
}

function handler1()  
{
	var email=document.formshenqing.email.value;
	var emaillen=email.length;
	if ((email=="")||(email.indexOf("@")==-1)||(email.indexOf("@")==0 )||(email.indexOf("@")==emaillen-1))
	{
		alert("請正確填寫您的E-mail地址!"); 
		document.formshenqing.email.focus();	
		return false;
	}
}


function pw()  
{
	var passw1=document.formshenqing.passw1.value;
	var passw2=document.formshenqing.passw2.value;
	if (passw1==""||passw1!=passw2)
	{
		alert("密碼不能為空且兩次密碼要相等！");
		document.formshenqing.passw1.focus();
		document.formshenqing.passw1.select();
		return false;
	}
}



function checksubmitdata()
{
         
	//公司資訊
	var company=document.formshenqing.company.value;
    var zcompany=document.formshenqing.zcompany.value;
	if ((company=="")&&(zcompany==""))
	{
		alert("請填寫貴公司的名稱!"); 
		document.formshenqing.company.focus();		
		return false;
	}

	var regcode=document.formshenqing.regcode.value;
	if ((regcode=="")||(regcode.indexOf(" ")==0))
	{
		alert("請填寫商業號碼!"); 
		document.formshenqing.regcode.focus();
		return false;
	}

	var comcate=document.formshenqing.comcate.value;
	if ((comcate=="")||(comcate.indexOf(" ")==0))
	{
	    alert("請填寫公司的業務性質!"); 
		document.formshenqing.comcate.focus();
		return false;
	}

	var a=document.formshenqing.type[0].checked
	var b=document.formshenqing.type[1].checked
	if(a==true)
	{
		var zarea=document.formshenqing.zarea.value;
		if(zarea=="")
		{
			alert("請選擇地區"); 
			document.formshenqing.zarea.focus();
			return false;
		}

		var zstree=document.formshenqing.zstree.value;
		if(zstree=="")
  		{
			alert("請選擇或填寫街道"); 
			document.formshenqing.zstree.focus();
			return false;
		}
	}
	if(b==true)
	{
		var earea=document.formshenqing.earea.value;
		if(earea=="")
		{
			alert("Please select Area"); 
			document.formshenqing.earea.focus();
			return false;
		}
		var estree=document.formshenqing.estree.value;
		if(estree=="")
		{
			alert("Please select or full street"); 
			document.formshenqing.estree.focus();
			return false;
		}
	}
	var contact=document.formshenqing.contact.value;
	if ((contact=="")||(contact.indexOf(" ")==0))
	{
		alert("請填寫聯系人!"); 
		document.formshenqing.contact.focus();	
		return false;
	}
	var cphone=document.formshenqing.cphone.value;
///200607 
               if( (cphone.substring(0, 1)=="U")  &&  ( !isNaN( cphone.substring(1,2) )) ){
                     //-- ok by chris U9999999 
	    // alert("U請 U - MONTHLY A/C !"); 
              }else{ 
                      if ((cphone=="")||(cphone.indexOf(" ")==0)||(isNaN(cphone))){
		alert("請填寫電話號碼!"); 
		document.formshenqing.cphone.focus();
		return false;
                      }
                }     

	var fax=document.formshenqing.fax.value;
	if ((fax=="" )|| (fax.indexOf(" ")==0 )||( isNaN(fax)))
	{
		alert("請填寫傳真號碼!"); 
		document.formshenqing.fax.focus();
		return false;
	}
	var ename=document.formshenqing.ename.value;
	if ((ename=="")|| (ename.indexOf(" ")==0))
	{
		alert("請填寫您的英文姓名!");
		document.formshenqing.ename.focus();
		return false;
	}
	var zname=document.formshenqing.zname.value;
	if ((zname=="" )||( zname.indexOf(" ")==0))
	{
		alert("請填寫您的中文姓名！");
		document.formshenqing.zname.focus();
		return false;
	}
	var clongname=document.formshenqing.clongname.value;
	if (clongname=="")
	{
		alert("請填寫登錄名稱!");
		document.formshenqing.clongname.focus();
		return false;
	}
	var email=document.formshenqing.email.value;
	var emaillen=email.length;
	if ((email=="" )||( email.indexOf("@")==-1) ||( email.indexOf("@")==0 )||(email.indexOf("@")==(emaillen-1)))
	{
		alert("請正確填寫您的E-mail地址!"); 
		document.formshenqing.email.focus();	
		return false;
	}
	var passw1=document.formshenqing.passw1.value;
	if ((passw1=="") || (passw1.indexOf(" ")==0 )||( passw1.length<6))
	{
		alert("請填寫您的密碼(要求密碼大于等于六位數！)");
		document.formshenqing.passw1.focus();		
		return false;
	}
	var passw2=document.formshenqing.passw2.value;
	if (passw1!=passw2)
	{
		alert("請確認兩次密碼是否相符！");
		document.formshenqing.passw2.select();
		return false;
	}
	var career=document.formshenqing.career.value;
        if (career == ''){
                alert("請選擇行業");
                document.formshenqing.career.focus();
                return false;
        }

    //資金資訊
	var fundIndex=document.formshenqing.fund.selectedIndex;
	var fund=parseFloat(document.formshenqing.fund.options[fundIndex].text.substring(5,12));
	if (fundIndex==0)
	{
		alert("首次預付金額未選!");
		document.formshenqing.fund.focus();
		return false;
	}
	var minfundIndex=document.formshenqing.minfund.selectedIndex;
	var minfund=parseFloat(document.formshenqing.minfund.options[minfundIndex].text.substring(5,12));
	if (minfundIndex==0)
	{
		alert("提示增值線未選!");
		document.formshenqing.minfund.focus();
		return false;
	}
	//支付方式
	if (document.formshenqing.checkfund.checked==false)
	{
		var perfundIndex=document.formshenqing.perfund.selectedIndex;
		var perfund=parseFloat(document.formshenqing.perfund.options[perfundIndex].text.substring(5,12));
		if (perfundIndex==0)
		{
			alert("每次自動增值額未選!"); 
			document.formshenqing.perfund.focus();
			return false;
		}
        var creditnum1=document.formshenqing.creditnum1.value;
		if ((creditnum1=="" )||(creditnum1.indexOf(" ")==0)||(creditnum1.length!=4))
		{			
			alert("請填寫信用卡號!"); 
			document.formshenqing.creditnum1.focus();
			return false;
		}
		var creditnum2=document.formshenqing.creditnum2.value;
		if ((creditnum2=="" )|| (creditnum2.indexOf(" ")==0 )||(creditnum2.length!=4))
		{
			alert("請正確填寫信用卡號!"); 
			document.formshenqing.creditnum2.focus();
			return false;
		}
		var creditnum3=document.formshenqing.creditnum3.value;
		if ((creditnum3=="" )|| (creditnum3.indexOf(" ")==0) ||(creditnum3.length!=4))
		{
			alert("請正確填寫信用卡號!");
			document.formshenqing.creditnum3.focus();
			return false;
		}
		var creditnum4=document.formshenqing.creditnum4.value;
		if ((creditnum4=="" )||(creditnum4.indexOf(" ")==0)||(creditnum4.length!=4))
		{
			alert("請正確填寫信用卡號!");
			document.formshenqing.creditnum4.focus();
			return false;
		}
		var creditname=document.formshenqing.creditname.value;
		if ((creditname=="")||(creditname.indexOf(" ")==0)||(creditname!=ename))
		{
			alert("持卡人名應於您的英文姓名相符！");
			document.formshenqing.creditname.focus();
            document.formshenqing.creditname.select();	
			return false;
		}

		var creditdata1Index=document.formshenqing.creditdata1.selectedIndex;
		var creditdata1=parseFloat(document.formshenqing.creditdata1.options[creditdata1Index].text);
		var creditdata2Index=document.formshenqing.creditdata2.selectedIndex;
		var creditdata2=parseFloat(document.formshenqing.creditdata2.options[creditdata2Index].text);
		var creditdata=creditdata1+"/"+creditdata2;
		var now=new Date();
		var year=now.getYear();
		var month=now.getMonth()+1;
		month=""+month;
		if (month.length==1){
			month="0"+month;
		}
		var nowday=year+"/"+month;
		if (creditdata<nowday)
		{
			alert("信用卡有效期已過!");
			return false;
		}

	}
	document.formshenqing.action="apply1st.php";
	document.formshenqing.submit();
	return true;
}
function echecksubmitdata()
{
	//公司資訊
	var company=document.formshenqing.company.value;
    var zcompany=document.formshenqing.zcompany.value;
	if ((company=="")&&(zcompany==""))
	{
		alert("請填寫貴公司的名稱!"); 
		document.formshenqing.company.focus();		
		return false;
	}

	var regcode=document.formshenqing.regcode.value;
	if ((regcode=="")||(regcode.indexOf(" ")==0))
	{
		alert("請填寫商業號碼!"); 
		document.formshenqing.regcode.focus();
		return false;
	}

	var comcate=document.formshenqing.comcate.value;
	if ((comcate=="")||(comcate.indexOf(" ")==0))
	{
	    alert("請填寫公司的業務性質!"); 
		document.formshenqing.comcate.focus();
		return false;
	}

	var a=document.formshenqing.type[0].checked
	var b=document.formshenqing.type[1].checked
	if(a==true)
	{
		var zarea=document.formshenqing.zarea.value;
		if(zarea=="")
		{
			alert("請選擇地區"); 
			document.formshenqing.zarea.focus();
			return false;
		}

		var zstree=document.formshenqing.zstree.value;
		if(zstree=="")
  		{
			alert("請選擇或填寫街道"); 
			document.formshenqing.zstree.focus();
			return false;
		}
	}
	if(b==true)
	{
		var earea=document.formshenqing.earea.value;
		if(earea=="")
		{
			alert("Please select Area"); 
			document.formshenqing.earea.focus();
			return false;
		}
		var estree=document.formshenqing.estree.value;
		if(estree=="")
		{
			alert("Please select or full street"); 
			document.formshenqing.estree.focus();
			return false;
		}
	}
	var contact=document.formshenqing.contact.value;
	if ((contact=="")||(contact.indexOf(" ")==0))
	{
		alert("請填寫聯系人!"); 
		document.formshenqing.contact.focus();	
		return false;
	}
	var cphone=document.formshenqing.cphone.value;

///200607 
               if( (cphone.substring(0, 1)=="U")  &&  ( !isNaN( cphone.substring(1,2) )) ){
                     //-- ok by chris U9999999 
	    // alert("U請 U - MONTHLY A/C !"); 
              }else{ 
                      if ((cphone=="")||(cphone.indexOf(" ")==0)||(isNaN(cphone))){
		alert("請填寫電話號碼!"); 
		document.formshenqing.cphone.focus();
		return false;
                      }
                }     

	var fax=document.formshenqing.fax.value;
	if ((fax=="" )|| (fax.indexOf(" ")==0 )||( isNaN(fax)))
	{
		alert("請填寫傳真號碼!"); 
		document.formshenqing.fax.focus();
		return false;
	}
	var ename=document.formshenqing.ename.value;
	if ((ename=="")|| (ename.indexOf(" ")==0))
	{
		alert("請填寫您的英文姓名!");
		document.formshenqing.ename.focus();
		return false;
	}
	var zname=document.formshenqing.zname.value;
	if ((zname=="" )||( zname.indexOf(" ")==0))
	{
		alert("請填寫您的中文姓名！");
		document.formshenqing.zname.focus();
		return false;
	}
	var clongname=document.formshenqing.clongname.value;
	if (clongname=="")
	{
		alert("請填寫登錄名稱!");
		document.formshenqing.clongname.focus();
		return false;
	}
	var email=document.formshenqing.email.value;
	var emaillen=email.length;
	if ((email=="" )||( email.indexOf("@")==-1) ||( email.indexOf("@")==0 )||(email.indexOf("@")==(emaillen-1)))
	{
		alert("請正確填寫您的E-mail地址!"); 
		document.formshenqing.email.focus();	
		return false;
	}
	var passw1=document.formshenqing.passw1.value;
	if ((passw1=="") || (passw1.indexOf(" ")==0 )||( passw1.length<6))
	{
		alert("請填寫您的密碼(要求密碼大于等于六位數！)");
		document.formshenqing.passw1.focus();		
		return false;
	}
	var passw2=document.formshenqing.passw2.value;
	if (passw1!=passw2)
	{
		alert("請確認兩次密碼是否相符！");
		document.formshenqing.passw2.select();
		return false;
	}
	var career=document.formshenqing.career.value;
        if (career == ''){
                alert("請選擇行業");
                document.formshenqing.career.focus();
                return false;
        }

    //資金資訊
	var fundIndex=document.formshenqing.fund.selectedIndex;
	var fund=parseFloat(document.formshenqing.fund.options[fundIndex].text.substring(5,12));
	if (fundIndex==0)
	{
		alert("首次預付金額未選!");
		document.formshenqing.fund.focus();
		return false;
	}
	var minfundIndex=document.formshenqing.minfund.selectedIndex;
	var minfund=parseFloat(document.formshenqing.minfund.options[minfundIndex].text.substring(5,12));
	if (minfundIndex==0)
	{
		alert("提示增值線未選!");
		document.formshenqing.minfund.focus();
		return false;
	}
	//支付方式
	if (document.formshenqing.checkfund.checked==false)
	{
		var perfundIndex=document.formshenqing.perfund.selectedIndex;
		var perfund=parseFloat(document.formshenqing.perfund.options[perfundIndex].text.substring(5,12));
		if (perfundIndex==0)
		{
			alert("每次自動增值額未選!"); 
			document.formshenqing.perfund.focus();
			return false;
		}
        var creditnum1=document.formshenqing.creditnum1.value;
		if ((creditnum1=="" )||(creditnum1.indexOf(" ")==0)||(creditnum1.length!=4))
		{			
			alert("請填寫信用卡號!"); 
			document.formshenqing.creditnum1.focus();
			return false;
		}
		var creditnum2=document.formshenqing.creditnum2.value;
		if ((creditnum2=="" )|| (creditnum2.indexOf(" ")==0 )||(creditnum2.length!=4))
		{
			alert("請正確填寫信用卡號!"); 
			document.formshenqing.creditnum2.focus();
			return false;
		}
		var creditnum3=document.formshenqing.creditnum3.value;
		if ((creditnum3=="" )|| (creditnum3.indexOf(" ")==0) ||(creditnum3.length!=4))
		{
			alert("請正確填寫信用卡號!");
			document.formshenqing.creditnum3.focus();
			return false;
		}
		var creditnum4=document.formshenqing.creditnum4.value;
		if ((creditnum4=="" )||(creditnum4.indexOf(" ")==0)||(creditnum4.length!=4))
		{
			alert("請正確填寫信用卡號!");
			document.formshenqing.creditnum4.focus();
			return false;
		}
		var creditname=document.formshenqing.creditname.value;
		if ((creditname=="")||(creditname.indexOf(" ")==0)||(creditname!=ename))
		{
			alert("持卡人名應於您的英文姓名相符！");
			document.formshenqing.creditname.focus();
            document.formshenqing.creditname.select();	
			return false;
		}

		var creditdata1Index=document.formshenqing.creditdata1.selectedIndex;
		var creditdata1=parseFloat(document.formshenqing.creditdata1.options[creditdata1Index].text);
		var creditdata2Index=document.formshenqing.creditdata2.selectedIndex;
		var creditdata2=parseFloat(document.formshenqing.creditdata2.options[creditdata2Index].text);
		var creditdata=creditdata1+"/"+creditdata2;
		var now=new Date();
		var year=now.getYear();
		var month=now.getMonth()+1;
		month=""+month;
		if (month.length==1){
			month="0"+month;
		}
		var nowday=year+"/"+month;
		if (creditdata<nowday)
		{
			alert("信用卡有效期已過!");
			return false;
		}

	}
	document.formshenqing.action="eapply1st.php";
	document.formshenqing.submit();
	return true;
}
//好的操作
function movefocus1()
{
	var creditnum1=document.formshenqing.creditnum1.value;
	if (creditnum1.length==4)
	{
		document.formshenqing.creditnum2.focus();
	}
}

function movefocus2()
{
	var creditnum2=document.formshenqing.creditnum2.value;
	if (creditnum2.length==4)
	{
		document.formshenqing.creditnum3.focus();
	}
}

function movefocus3()
{
	var creditnum3=document.formshenqing.creditnum3.value;
	if (creditnum3.length==4)
	{
		document.formshenqing.creditnum4.focus();
	}
}

function movefocus4()
{
	var creditnum4=document.formshenqing.creditnum4.value;
	if (creditnum4.length==4)
	{
		document.formshenqing.creditname.focus();
	}
}



//根據選擇"支票付款"還是"信用卡付款"來操作
function clickcheckfocus()
{
	var fund0=document.formshenqing.checkfund.checked;
	var fund1=document.formshenqing.checkfund.unchecked;
	if (fund1==true)
	{
		alert("        您選擇了信用卡付款方式，無須填寫支票號碼了。\n請選擇您要預付的總額。");
		document.formshenqing.checknum.focus();
	}
}

function clickcreditfocus()
{
	var fund0=document.formshenqing.checkfund.checked;
	var fund1=document.formshenqing.checkfund.unchecked;
	if (fund0==true)
	{
		alert("        您選擇了支票付款方式，無須填寫信用卡資料。\n請填寫您的支票號碼。");
		document.formshenqing.checknum.focus();
	}
}

function selectfund()
{
	var fund0=document.formshenqing.checkfund.checked;
	var fund1=document.formshenqing.checkfund.unchecked;
	if (fund0==true)
	{								//支票付款
		document.formshenqing.checknum.disabled=false;
		document.formshenqing.creditnum1.value="";
		document.formshenqing.creditnum2.value="";
		document.formshenqing.creditnum3.value="";
		document.formshenqing.creditnum4.value="";
		document.formshenqing.creditname.value="";
		document.formshenqing.checknum.focus();
		document.formshenqing.perfund.disabled=true;
		document.formshenqing.credittype[0].checked=false;
		document.formshenqing.credittype[1].checked=false;
	}
	if(fund0==false)
	{	document.formshenqing.perfund.disabled=false;						//信用卡付款
		document.formshenqing.checknum.value="";
		document.formshenqing.creditnum1.focus();
        document.formshenqing.credittype[0].checked=true;
        document.formshenqing.checknum.disabled=true;
	}
}
