<link href="https://data.chinahighlights.com/css/min.php?f=/css/flatpickr-4.4.4.min.css" rel="stylesheet">
<script src="https://data.chinahighlights.com/js/min.php?f=/js/flatpickr-4.6.1.min.js"></script>

<div class="tmbottom">
    <h3 style="text-align: center; padding-top: 0;padding-bottom: 0;">Quick Test: Will My Route Qualify for China 72/144-Hour Visa-Free Transit?</h3>
        <div class="InquiryBox">
    <form action="" method="post" novalidate="" id="qualification_tester_form">
        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">1. I will depart from (only applies to direct or connected flight): </p>
        <select id="depart_from" name="depart_from" class="country_code" style="width: 100%;  margin-bottom: 10px;
        border-radius: 6px;
        height: 40px;">
            <option value="United States ">United States</option>
            <option value="United Kingdom ">United Kingdom</option>
            <option value="Australia ">Australia</option>
            <option value="Canada ">Canada</option>
            <option value="France ">France</option>
            <option value="Germany ">Germany</option>
            <option value="Italy ">Italy</option>
            <option value="Mexico ">Mexico</option>
            <option value="Netherlands ">Netherlands</option>
            <option value="Singapore ">Singapore</option>
            <option value="Hong Kong ">Hong Kong</option>

            <option value="Afghanistan ">Afghanistan </option>
            <option value="Albania ">Albania </option>
            <option value="Algeria ">Algeria</option>
            <option value="American Samoa">American Samoa</option>
            <option value="Andorra ">Andorra</option>
            <option value="Angola ">Angola</option>
            <option value="Anguilla ">Anguilla</option>
            <option value="Antigua and Barbuda ">Antigua and Barbuda</option>
            <option value="Argentina ">Argentina</option>
            <option value="Armenia ">Armenia </option>
            <option value="Aruba ">Aruba</option>
            <option value="Ascension Island ">Ascension Island</option>
            <option value="Australia ">Australia</option>
            <option value="Austria ">Austria</option>
            <option value="Azerbaijan ">Azerbaijan</option>
            <option value="Bahamas ">Bahamas</option>
            <option value="Bahrain ">Bahrain</option>
            <option value="Bangladesh ">Bangladesh</option>
            <option value="Barbados ">Barbados</option>
            <option value="Belarus ">Belarus</option>
            <option value="Belgium ">Belgium</option>
            <option value="Belize ">Belize</option>
            <option value="Benin ">Benin</option>
            <option value="Bermuda ">Bermuda</option>
            <option value="Bhutan ">Bhutan</option>
            <option value="Bolivia ">Bolivia</option>
            <option value="Bosnia and Herzegovina ">Bosnia and Herzegovina</option>
            <option value="Botswana ">Botswana267</option>
            <option value="Brazil ">Brazil55</option>
            <option value="British Indian Ocean Territory ">British Indian Ocean Territory</option>
            <option value="British Virgin Islands ">British Virgin Islands</option>
            <option value="Brunei ">Brunei</option>
            <option value="Bulgaria ">Bulgaria</option>
            <option value="Burkina Faso ">Burkina Faso</option>
            <option value="Burundi">Burundi</option>
            <option value="Cambodia ">Cambodia</option>
            <option value="Cameroon ">Cameroon</option>
            <option value="Canada ">Canada</option>
            <option value="Cape Verde ">Cape Verde</option>
            <option value="Caribbean Netherlands ">Caribbean Netherlands</option>
            <option value="Cayman Islands ">Cayman Islands</option>
            <option value="Central African Republic ">Central African Republic</option>
            <option value="Chad ">Chad</option>
            <option value="Chile ">Chile</option>
            <option value="China ">China</option>
            <option value="Christmas Island ">Christmas Island</option>
            <option value="Cocos Islands ">Cocos Islands</option>
            <option value="Colombia ">Colombia</option>
            <option value="Comoros ">Comoros</option>
            <option value="Congo ">Congo (DRC)</option>
            <option value="Congo ">Congo (Republic)</option>
            <option value="Cook Islands ">Cook Islands</option>
            <option value="Costa Rica ">Costa Rica</option>
            <option value="Côte d'Ivoire ">Côte d'Ivoire</option>
            <option value="Croatia ">Croatia</option>
            <option value="Cuba ">Cuba</option>
            <option value="Curaçao ">Curaçao</option>
            <option value="Cyprus ">Cyprus</option>
            <option value="Czech Republic ">Czech Republic</option>
            <option value="Denmark ">Denmark</option>
            <option value="Djibouti ">Djibouti</option>
            <option value="Dominica">Dominica1</option>
            <option value="Dominican Republic ">Dominican Republic</option>
            <option value="Ecuador ">Ecuador</option>
            <option value="Egypt ">Egypt</option>
            <option value="El Salvador ">El Salvador</option>
            <option value="Equatorial Guinea ">Equatorial Guinea</option>
            <option value="Eritrea ">Eritrea</option>
            <option value="Estonia ">Estonia</option>
            <option value="Eswatini ">Eswatini</option>
            <option value="Ethiopia ">Ethiopia</option>
            <option value="Falkland Islands ">Falkland Islands</option>
            <option value="Faroe Islands ">Faroe Islands</option>
            <option value="Fiji ">Fiji</option>
            <option value="Finland ">Finland</option>
            <option value="France ">France</option>
            <option value="French Guiana ">French Guiana</option>
            <option value="French Polynesia ">French Polynesia</option>
            <option value="Gabon ">Gabon</option>
            <option value="Gambia ">Gambia</option>
            <option value="Georgia ">Georgia</option>
            <option value="Germany ">Germany</option>
            <option value="Ghana ">Ghana</option>
            <option value="Gibraltar ">Gibraltar</option>
            <option value="Greece ">Greece</option>
            <option value="Greenland ">Greenland</option>
            <option value="Grenada ">Grenada</option>
            <option value="Guadeloupe ">Guadeloupe</option>
            <option value="Guam ">Guam</option>
            <option value="Guatemala ">Guatemala</option>
            <option value="Guernsey ">Guernsey</option>
            <option value="Guinea ">Guinea</option>
            <option value="Guinea-Bissau ">Guinea-Bissau</option>
            <option value="Guyana ">Guyana</option>
            <option value="Haiti ">Haiti</option>
            <option value="Honduras ">Honduras</option>
            <option value="Hong Kong ">Hong Kong</option>
            <option value="Hungary ">Hungary</option>
            <option value="Iceland ">Iceland</option>
            <option value="India ">India</option>
            <option value="Indonesia ">Indonesia</option>
            <option value="Iran ">Iran</option>
            <option value="Iraq ">Iraq</option>
            <option value="Ireland ">Ireland</option>
            <option value="Isle of Man ">Isle of Man</option>
            <option value="Israel ">Israel</option>
            <option value="Italy ">Italy</option>
            <option value="Jamaica ">Jamaica</option>
            <option value="Japan ">Japan</option>
            <option value="Jersey ">Jersey4</option>
            <option value="Jordan ">Jordan</option>
            <option value="Kazakhstan ">Kazakhstan</option>
            <option value="Kenya ">Kenya</option>
            <option value="Kiribati ">Kiribati</option>
            <option value="Kosovo ">Kosovo</option>
            <option value="Kuwait ">Kuwait</option>
            <option value="Kyrgyzstan ">Kyrgyzstan</option>
            <option value="Laos ">Laos</option>
            <option value="Latvia ">Latvia</option>
            <option value="Lebanon ">Lebanon</option>
            <option value="Lesotho ">Lesotho</option>
            <option value="Liberia ">Liberia</option>
            <option value="Libya ">Libya</option>
            <option value="Liechtenstein ">Liechtenstein</option>
            <option value="Lithuania ">Lithuania</option>
            <option value="Luxembourg ">Luxembourg</option>
            <option value="Macau ">Macau</option>
            <option value="Macedonia ">Macedonia</option>
            <option value="Madagascar ">Madagascar</option>
            <option value="Malawi ">Malawi</option>
            <option value="Malaysia ">Malaysia</option>
            <option value="Maldives ">Maldives</option>
            <option value="Mali ">Mali</option>
            <option value="Malta ">Malta</option>
            <option value="Marshall ">Marshall Islands</option>
            <option value="Martinique ">Martinique</option>
            <option value="Mauritania ">Mauritania</option>
            <option value="Mauritius ">Mauritius</option>
            <option value="Mayotte ">Mayotte</option>
            <option value="Mexico ">Mexico</option>
            <option value="Micronesia ">Micronesia</option>
            <option value="Moldova ">Moldova</option>
            <option value="Monaco ">Monaco</option>
            <option value="Mongolia ">Mongolia</option>
            <option value="Montenegro ">Montenegro</option>
            <option value="Montserrat ">Montserrat</option>
            <option value="Morocco ">Morocco</option>
            <option value="Mozambique ">Mozambique</option>
            <option value="Myanmar ">Myanmar5</option>
            <option value="Namibia ">Namibia</option>
            <option value="Nauru ">Nauru</option>
            <option value="Nepal ">Nepal</option>
            <option value="New Caledonia ">New Caledonia</option>
            <option value="New Zealand ">New Zealand</option>
            <option value="Nicaragua ">Nicaragua</option>
            <option value="Niger ">Niger</option>
            <option value="Nigeria ">Nigeria</option>
            <option value="Niue ">Niue</option>
            <option value="Norfolk Island ">Norfolk Island</option>
            <option value="North Korea ">North Korea</option>
            <option value="Northern Mariana Islands ">Northern Mariana Islands</option>
            <option value="Norway ">Norway</option>
            <option value="Oman ">Oman</option>
            <option value="Pakistan ">Pakistan</option>
            <option value="Palau ">Palau</option>
            <option value="Palestine ">Palestine</option>
            <option value="Panama ">Panama</option>
            <option value="Papua New Guinea ">Papua New Guinea</option>
            <option value="Paraguay ">Paraguay</option>
            <option value="Peru ">Peru</option>
            <option value="Philippines ">Philippines</option>
            <option value="Poland ">Poland</option>
            <option value="Portugal ">Portugal</option>
            <option value="Puerto Rico ">Puerto Rico</option>
            <option value="Qatar ">Qatar</option>
            <option value="Réunion ">Réunion</option>
            <option value="Romania ">Romania</option>
            <option value="Russia ">Russia</option>
            <option value="Rwanda ">Rwanda</option>
            <option value="Saint Barthélemy ">Saint Barthélemy</option>
            <option value="Saint Helena ">Saint Helena</option>
            <option value="Saint Kitts and Nevis ">Saint Kitts and Nevis</option>
            <option value="Saint Lucia ">Saint Lucia</option>
            <option value="Saint Martin ">Saint Martin</option>
            <option value="Saint Pierre and Miquelon ">Saint Pierre and Miquelon</option>
            <option value="Saint Vincent and the Grenadines ">Saint Vincent and the Grenadines</option>
            <option value="Samoa ">Samoa</option>
            <option value="San Marino ">San Marino</option>
            <option value="São Tomé and Príncipe ">São Tomé and Príncipe</option>
            <option value="Saudi Arabia ">Saudi Arabia</option>
            <option value="Senegal ">Senegal</option>
            <option value="Serbia ">Serbia</option>
            <option value="Seychelles ">Seychelles</option>
            <option value="Sierra Leone ">Sierra Leone</option>
            <option value="Singapore ">Singapore</option>
            <option value="Sint Maarten ">Sint Maarten</option>
            <option value="Slovakia ">Slovakia</option>
            <option value="Slovenia ">Slovenia</option>
            <option value="Solomon Islands ">Solomon Islands</option>
            <option value="Somalia ">Somalia</option>
            <option value="South Africa ">South Africa</option>
            <option value="South Korea ">South Korea</option>
            <option value="South Sudan ">South Sudan</option>
            <option value="Spain ">Spain</option>
            <option value="Sri Lanka ">Sri Lanka</option>
            <option value="Sudan ">Sudan</option>
            <option value="Suriname">Suriname</option>
            <option value="Svalbard and Jan Mayen ">Svalbard and Jan Mayen</option>
            <option value="Sweden ">Sweden</option>
            <option value="Switzerland ">Switzerland</option>
            <option value="Syria ">Syria</option>
            <option value="Taiwan ">Taiwan</option>
            <option value="Tajikistan ">Tajikistan</option>
            <option value="Tanzania ">Tanzania</option>
            <option value="Thailand ">Thailand</option>
            <option value="Timor-Leste ">Timor-Leste</option>
            <option value="Togo ">Togo</option>
            <option value="Tokelau ">Tokelau</option>
            <option value="Tonga ">Tonga</option>
            <option value="Trinidad and Tobago ">Trinidad and Tobago</option>
            <option value="Tunisia ">Tunisia</option>
            <option value="Turkey ">Turkey</option>
            <option value="Turkmenistan ">Turkmenistan</option>
            <option value="Turks and Caicos Islands ">Turks and Caicos Islands</option>
            <option value="Tuvalu ">Tuvalu</option>
            <option value="U.S. Virgin Islands ">U.S. Virgin Islands</option>
            <option value="Uganda ">Uganda</option>
            <option value="Ukraine ">Ukraine</option>
            <option value="United Arab Emirates ">United Arab Emirates</option>
            <option value="United Kingdom ">United Kingdom</option>
            <option value="United States ">United States</option>
            <option value="Uruguay ">Uruguay</option>
            <option value="Uzbekistan ">Uzbekistan</option>
            <option value="Vanuatu ">Vanuatu</option>
            <option value="Vatican City ">Vatican City</option>
            <option value="Venezuela ">Venezuela</option>
            <option value="Vietnam ">Vietnam</option>
            <option value="Wallis and Futuna">Wallis and Futuna</option>
            <option value="Western Sahara ">Western Sahara</option>
            <option value="Yemen ">Yemen</option>
            <option value="Zambia ">Zambia</option>
            <option value="Zimbabwe ">Zimbabwe</option>
            <option value="Åland Islands">Åland Islands</option>
        </select>
        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">2. I will arrive in China at [city], [airport / railway station / port].</p>
        <select id="arrive_at_city" name="arrive_at_city" class="country_code" style=" margin-bottom: 10px;
        border-radius: 6px;
        height: 40px;">
            <option value="Beijing">Beijing</option>
            <option value="Shanghai">Shanghai</option>
            <option value="Guangzhou">Guangzhou</option>
            <option value="Chengdu">Chengdu</option>
            <option value="Chongqing">Chongqing</option>
            <option value="Guilin">Guilin</option>
            <option value="Xi'an">Xi'an</option>
            <option value="Kunming">Kunming</option>
            <option value="Qingdao">Qingdao</option>
            <option value="Xiamen">Xiamen</option>
            <option value="Wuhan">Wuhan</option>
            <option value="Harbin">Harbin</option>
            <option value="Changsha">Changsha</option>
            <option value="Tianjin">Tianjin</option>
            <option value="Shijiazhuang">Shijiazhuang</option>
            <option value="Qinhuangdao">Qinhuangdao</option>
            <option value="Shenzhen">Shenzhen</option>
            <option value="Hangzhou">Hangzhou</option>
            <option value="Nanjing">Nanjing</option>
            <option value="Ningbo">Ningbo</option>
            <option value="Shenyang">Shenyang</option>
            <option value="Dalian">Dalian</option>
        </select>

        <select id="airport_or_railway_station" name="airport_or_railway_station" class="country_code" style=" margin-bottom: 10px;
        border-radius: 6px;
        height: 40px;">
            <option data-hour="144" value="Beijing Capital International Airport">Beijing Capital International Airport, PEK</option>
            <option data-hour="144" value="Beijingxi Railway Station">Beijingxi Railway Station</option>
            <option data-hour="144" value="Beijing Daxing International Airport">Beijing Daxing International Airport, PKX</option>
        </select>

        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">3. My arrival date is...</p>
        <input id="arrival_date" name="arrival_date" type="date" class="date_pick">
        <span id="arrival_date_errmsg" style="display: none;">
          <span class="requiredArea">Please select your arrival date.</span>
        </span>
        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">4. I will leave for [country/region] from China (the bounding destination on the air ticket):</p>
        <select id="leave_for_country" name="leave_for_country" class="country_code" style="width: 100%; margin-bottom: 10px;
        border-radius: 6px;
        height: 40px;">
            <option value="United States ">United States</option>
            <option value="United Kingdom ">United Kingdom</option>
            <option value="Australia ">Australia</option>
            <option value="Canada ">Canada</option>
            <option value="France ">France</option>
            <option value="Germany ">Germany</option>
            <option value="Italy ">Italy</option>
            <option value="Mexico ">Mexico</option>
            <option value="Netherlands ">Netherlands</option>
            <option value="Singapore ">Singapore</option>
            <option value="Hong Kong ">Hong Kong</option>
            <option value="Afghanistan ">Afghanistan </option>
            <option value="Albania ">Albania </option>
            <option value="Algeria ">Algeria</option>
            <option value="American Samoa">American Samoa</option>
            <option value="Andorra ">Andorra</option>
            <option value="Angola ">Angola</option>
            <option value="Anguilla ">Anguilla</option>
            <option value="Antigua and Barbuda ">Antigua and Barbuda</option>
            <option value="Argentina ">Argentina</option>
            <option value="Armenia ">Armenia </option>
            <option value="Aruba ">Aruba297</option>
            <option value="Ascension Island ">Ascension Island</option>
            <option value="Australia ">Australia</option>
            <option value="Austria ">Austria</option>
            <option value="Azerbaijan ">Azerbaijan</option>
            <option value="Bahamas ">Bahamas</option>
            <option value="Bahrain ">Bahrain</option>
            <option value="Bangladesh ">Bangladesh</option>
            <option value="Barbados ">Barbados</option>
            <option value="Belarus ">Belarus</option>
            <option value="Belgium ">Belgium</option>
            <option value="Belize ">Belize</option>
            <option value="Benin ">Benin</option>
            <option value="Bermuda ">Bermuda</option>
            <option value="Bhutan ">Bhutan</option>
            <option value="Bolivia ">Bolivia</option>
            <option value="Bosnia and Herzegovina ">Bosnia and Herzegovina</option>
            <option value="Botswana ">Botswana267</option>
            <option value="Brazil ">Brazil55</option>
            <option value="British Indian Ocean Territory ">British Indian Ocean Territory</option>
            <option value="British Virgin Islands ">British Virgin Islands</option>
            <option value="Brunei ">Brunei</option>
            <option value="Bulgaria ">Bulgaria</option>
            <option value="Burkina Faso ">Burkina Faso</option>
            <option value="Burundi">Burundi</option>
            <option value="Cambodia ">Cambodia</option>
            <option value="Cameroon ">Cameroon</option>
            <option value="Canada ">Canada</option>
            <option value="Cape Verde ">Cape Verde</option>
            <option value="Caribbean Netherlands ">Caribbean Netherlands</option>
            <option value="Cayman Islands ">Cayman Islands</option>
            <option value="Central African Republic ">Central African Republic</option>
            <option value="Chad ">Chad</option>
            <option value="Chile ">Chile</option>
            <option value="China ">China</option>
            <option value="Christmas Island ">Christmas Island</option>
            <option value="Cocos Islands ">Cocos Islands</option>
            <option value="Colombia ">Colombia</option>
            <option value="Comoros ">Comoros</option>
            <option value="Congo ">Congo (DRC)</option>
            <option value="Congo ">Congo (Republic)</option>
            <option value="Cook Islands ">Cook Islands</option>
            <option value="Costa Rica ">Costa Rica</option>
            <option value="Côte d'Ivoire ">Côte d'Ivoire</option>
            <option value="Croatia ">Croatia</option>
            <option value="Cuba ">Cuba</option>
            <option value="Curaçao ">Curaçao</option>
            <option value="Cyprus ">Cyprus</option>
            <option value="Czech Republic ">Czech Republic</option>
            <option value="Denmark ">Denmark</option>
            <option value="Djibouti ">Djibouti</option>
            <option value="Dominica">Dominica1</option>
            <option value="Dominican Republic ">Dominican Republic</option>
            <option value="Ecuador ">Ecuador</option>
            <option value="Egypt ">Egypt</option>
            <option value="El Salvador ">El Salvador</option>
            <option value="Equatorial Guinea ">Equatorial Guinea</option>
            <option value="Eritrea ">Eritrea</option>
            <option value="Estonia ">Estonia</option>
            <option value="Eswatini ">Eswatini</option>
            <option value="Ethiopia ">Ethiopia</option>
            <option value="Falkland Islands ">Falkland Islands</option>
            <option value="Faroe Islands ">Faroe Islands</option>
            <option value="Fiji ">Fiji</option>
            <option value="Finland ">Finland</option>
            <option value="France ">France</option>
            <option value="French Guiana ">French Guiana</option>
            <option value="French Polynesia ">French Polynesia</option>
            <option value="Gabon ">Gabon</option>
            <option value="Gambia ">Gambia</option>
            <option value="Georgia ">Georgia</option>
            <option value="Germany ">Germany</option>
            <option value="Ghana ">Ghana</option>
            <option value="Gibraltar ">Gibraltar</option>
            <option value="Greece ">Greece</option>
            <option value="Greenland ">Greenland</option>
            <option value="Grenada ">Grenada</option>
            <option value="Guadeloupe ">Guadeloupe</option>
            <option value="Guam ">Guam</option>
            <option value="Guatemala ">Guatemala</option>
            <option value="Guernsey ">Guernsey</option>
            <option value="Guinea ">Guinea</option>
            <option value="Guinea-Bissau ">Guinea-Bissau</option>
            <option value="Guyana ">Guyana</option>
            <option value="Haiti ">Haiti</option>
            <option value="Honduras ">Honduras</option>
            <option value="Hong Kong ">Hong Kong</option>
            <option value="Hungary ">Hungary</option>
            <option value="Iceland ">Iceland</option>
            <option value="India ">India</option>
            <option value="Indonesia ">Indonesia</option>
            <option value="Iran ">Iran</option>
            <option value="Iraq ">Iraq</option>
            <option value="Ireland ">Ireland</option>
            <option value="Isle of Man ">Isle of Man</option>
            <option value="Israel ">Israel</option>
            <option value="Italy ">Italy</option>
            <option value="Jamaica ">Jamaica</option>
            <option value="Japan ">Japan</option>
            <option value="Jersey ">Jersey4</option>
            <option value="Jordan ">Jordan</option>
            <option value="Kazakhstan ">Kazakhstan</option>
            <option value="Kenya ">Kenya</option>
            <option value="Kiribati ">Kiribati</option>
            <option value="Kosovo ">Kosovo</option>
            <option value="Kuwait ">Kuwait</option>
            <option value="Kyrgyzstan ">Kyrgyzstan</option>
            <option value="Laos ">Laos</option>
            <option value="Latvia ">Latvia</option>
            <option value="Lebanon ">Lebanon</option>
            <option value="Lesotho ">Lesotho</option>
            <option value="Liberia ">Liberia</option>
            <option value="Libya ">Libya</option>
            <option value="Liechtenstein ">Liechtenstein</option>
            <option value="Lithuania ">Lithuania</option>
            <option value="Luxembourg ">Luxembourg</option>
            <option value="Macau ">Macau</option>
            <option value="Macedonia ">Macedonia</option>
            <option value="Madagascar ">Madagascar</option>
            <option value="Malawi ">Malawi</option>
            <option value="Malaysia ">Malaysia</option>
            <option value="Maldives ">Maldives</option>
            <option value="Mali ">Mali</option>
            <option value="Malta ">Malta</option>
            <option value="Marshall ">Marshall Islands</option>
            <option value="Martinique ">Martinique</option>
            <option value="Mauritania ">Mauritania</option>
            <option value="Mauritius ">Mauritius</option>
            <option value="Mayotte ">Mayotte</option>
            <option value="Mexico ">Mexico</option>
            <option value="Micronesia ">Micronesia</option>
            <option value="Moldova ">Moldova</option>
            <option value="Monaco ">Monaco</option>
            <option value="Mongolia ">Mongolia</option>
            <option value="Montenegro ">Montenegro</option>
            <option value="Montserrat ">Montserrat</option>
            <option value="Morocco ">Morocco</option>
            <option value="Mozambique ">Mozambique</option>
            <option value="Myanmar ">Myanmar5</option>
            <option value="Namibia ">Namibia</option>
            <option value="Nauru ">Nauru</option>
            <option value="Nepal ">Nepal</option>
            <option value="New Caledonia ">New Caledonia</option>
            <option value="New Zealand ">New Zealand</option>
            <option value="Nicaragua ">Nicaragua</option>
            <option value="Niger ">Niger</option>
            <option value="Nigeria ">Nigeria</option>
            <option value="Niue ">Niue</option>
            <option value="Norfolk Island ">Norfolk Island</option>
            <option value="North Korea ">North Korea</option>
            <option value="Northern Mariana Islands ">Northern Mariana Islands</option>
            <option value="Norway ">Norway</option>
            <option value="Oman ">Oman</option>
            <option value="Pakistan ">Pakistan</option>
            <option value="Palau ">Palau</option>
            <option value="Palestine ">Palestine</option>
            <option value="Panama ">Panama</option>
            <option value="Papua New Guinea ">Papua New Guinea</option>
            <option value="Paraguay ">Paraguay</option>
            <option value="Peru ">Peru</option>
            <option value="Philippines ">Philippines</option>
            <option value="Poland ">Poland</option>
            <option value="Portugal ">Portugal</option>
            <option value="Puerto Rico ">Puerto Rico</option>
            <option value="Qatar ">Qatar</option>
            <option value="Réunion ">Réunion</option>
            <option value="Romania ">Romania</option>
            <option value="Russia ">Russia</option>
            <option value="Rwanda ">Rwanda</option>
            <option value="Saint Barthélemy ">Saint Barthélemy</option>
            <option value="Saint Helena ">Saint Helena</option>
            <option value="Saint Kitts and Nevis ">Saint Kitts and Nevis</option>
            <option value="Saint Lucia ">Saint Lucia</option>
            <option value="Saint Martin ">Saint Martin</option>
            <option value="Saint Pierre and Miquelon ">Saint Pierre and Miquelon</option>
            <option value="Saint Vincent and the Grenadines ">Saint Vincent and the Grenadines</option>
            <option value="Samoa ">Samoa</option>
            <option value="San Marino ">San Marino</option>
            <option value="São Tomé and Príncipe ">São Tomé and Príncipe</option>
            <option value="Saudi Arabia ">Saudi Arabia</option>
            <option value="Senegal ">Senegal</option>
            <option value="Serbia ">Serbia</option>
            <option value="Seychelles ">Seychelles</option>
            <option value="Sierra Leone ">Sierra Leone</option>
            <option value="Singapore ">Singapore</option>
            <option value="Sint Maarten ">Sint Maarten</option>
            <option value="Slovakia ">Slovakia</option>
            <option value="Slovenia ">Slovenia</option>
            <option value="Solomon Islands ">Solomon Islands</option>
            <option value="Somalia ">Somalia</option>
            <option value="South Africa ">South Africa</option>
            <option value="South Korea ">South Korea</option>
            <option value="South Sudan ">South Sudan</option>
            <option value="Spain ">Spain</option>
            <option value="Sri Lanka ">Sri Lanka</option>
            <option value="Sudan ">Sudan</option>
            <option value="Suriname">Suriname</option>
            <option value="Svalbard and Jan Mayen ">Svalbard and Jan Mayen</option>
            <option value="Sweden ">Sweden</option>
            <option value="Switzerland ">Switzerland</option>
            <option value="Syria ">Syria</option>
            <option value="Taiwan ">Taiwan</option>
            <option value="Tajikistan ">Tajikistan</option>
            <option value="Tanzania ">Tanzania</option>
            <option value="Thailand ">Thailand</option>
            <option value="Timor-Leste ">Timor-Leste</option>
            <option value="Togo ">Togo</option>
            <option value="Tokelau ">Tokelau</option>
            <option value="Tonga ">Tonga</option>
            <option value="Trinidad and Tobago ">Trinidad and Tobago</option>
            <option value="Tunisia ">Tunisia</option>
            <option value="Turkey ">Turkey</option>
            <option value="Turkmenistan ">Turkmenistan</option>
            <option value="Turks and Caicos Islands ">Turks and Caicos Islands</option>
            <option value="Tuvalu ">Tuvalu</option>
            <option value="U.S. Virgin Islands ">U.S. Virgin Islands</option>
            <option value="Uganda ">Uganda</option>
            <option value="Ukraine ">Ukraine</option>
            <option value="United Arab Emirates ">United Arab Emirates</option>
            <option value="United Kingdom ">United Kingdom</option>
            <option value="United States ">United States</option>
            <option value="Uruguay ">Uruguay</option>
            <option value="Uzbekistan ">Uzbekistan</option>
            <option value="Vanuatu ">Vanuatu</option>
            <option value="Vatican City ">Vatican City</option>
            <option value="Venezuela ">Venezuela</option>
            <option value="Vietnam ">Vietnam</option>
            <option value="Wallis and Futuna">Wallis and Futuna</option>
            <option value="Western Sahara ">Western Sahara</option>
            <option value="Yemen ">Yemen</option>
            <option value="Zambia ">Zambia</option>
            <option value="Zimbabwe ">Zimbabwe</option>
            <option value="Åland Islands">Åland Islands</option>
        </select>

        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">5. My departure date is...</p>
        <input id="departure_date" name="departure_date" type="date" class="date_pick">
        <span id="departure_date_errmsg" style="display: none;">
          <span class="requiredArea">Please select your departure date.</span>
        </span>
       

        <p style="font-weight: 400;
    font-size: 20px;
    text-align: left;
    clear: both !important;
    padding-bottom: 10px;
    margin-top: 20px;">6. My nationality is... <!--and my passport expiry date is--></p>
        <select id="nationality" name="nationality" class="country_code" style="width: 100%; margin-bottom: 10px;
        border-radius: 6px;
        height: 40px;">
          <option data-qualify="enable" value="United States ">United States</option>
          <option data-qualify="enable" value="United Kingdom ">United Kingdom</option>
          <option data-qualify="enable" value="Australia ">Australia</option>
          <option data-qualify="enable" value="Canada ">Canada</option>
          <option data-qualify="enable" value="France ">France</option>
          <option data-qualify="enable" value="Germany ">Germany</option>
          <option data-qualify="enable" value="Italy ">Italy</option>
          <option data-qualify="enable" value="Mexico ">Mexico</option>
          <option data-qualify="enable" value="Netherlands ">Netherlands</option>
          <option data-qualify="enable" value="Singapore ">Singapore</option>
          <option value="Afghanistan ">Afghanistan </option>
          <option data-qualify="enable" value="Albania ">Albania </option>
          <option value="Algeria ">Algeria</option>
          <option value="American Samoa">American Samoa</option>
          <option value="Andorra ">Andorra</option>
          <option value="Angola ">Angola</option>
          <option value="Anguilla ">Anguilla</option>
          <option value="Antigua and Barbuda ">Antigua and Barbuda</option>
          <option data-qualify="enable" value="Argentina ">Argentina</option>
          <option value="Armenia ">Armenia </option>
          <option value="Aruba ">Aruba</option>
          <option value="Ascension Island ">Ascension Island</option>
          <option data-qualify="enable" value="Australia ">Australia</option>
          <option data-qualify="enable" value="Austria ">Austria</option>
          <option value="Azerbaijan ">Azerbaijan</option>
          <option value="Bahamas ">Bahamas</option>
          <option value="Bahrain ">Bahrain</option>
          <option value="Bangladesh ">Bangladesh</option>
          <option value="Barbados ">Barbados</option>
          <option data-qualify="enable" value="Belarus ">Belarus</option>
          <option data-qualify="enable" value="Belgium ">Belgium</option>
          <option value="Belize ">Belize</option>
          <option value="Benin ">Benin</option>
          <option value="Bermuda ">Bermuda</option>
          <option value="Bhutan ">Bhutan</option>
          <option value="Bolivia ">Bolivia</option>
          <option data-qualify="enable" value="Bosnia and Herzegovina ">Bosnia and Herzegovina</option>
          <option value="Botswana ">Botswana</option>
          <option data-qualify="enable" value="Brazil ">Brazil</option>
          <option value="British Indian Ocean Territory ">British Indian Ocean Territory</option>
          <option value="British Virgin Islands ">British Virgin Islands</option>
          <option data-qualify="enable" value="Brunei ">Brunei</option>
          <option data-qualify="enable" value="Bulgaria ">Bulgaria</option>
          <option value="Burkina Faso ">Burkina Faso</option>
          <option value="Burundi">Burundi</option>
          <option value="Cambodia ">Cambodia</option>
          <option value="Cameroon ">Cameroon</option>
          <option data-qualify="enable" value="Canada ">Canada</option>
          <option value="Cape Verde ">Cape Verde</option>
          <option value="Caribbean Netherlands ">Caribbean Netherlands</option>
          <option value="Cayman Islands ">Cayman Islands</option>
          <option value="Central African Republic ">Central African Republic</option>
          <option value="Chad ">Chad</option>
          <option data-qualify="enable" value="Chile ">Chile</option>
          <option value="China ">China</option>
          <option value="Christmas Island ">Christmas Island</option>
          <option value="Cocos Islands ">Cocos Islands</option>
          <option value="Colombia ">Colombia</option>
          <option value="Comoros ">Comoros</option>
          <option value="Congo ">Congo (DRC)</option>
          <option value="Congo ">Congo (Republic)</option>
          <option value="Cook Islands ">Cook Islands</option>
          <option value="Costa Rica ">Costa Rica</option>
          <option value="Côte d'Ivoire ">Côte d'Ivoire</option>
          <option data-qualify="enable" value="Croatia ">Croatia</option>
          <option value="Cuba ">Cuba</option>
          <option value="Curaçao ">Curaçao</option>
          <option data-qualify="enable" value="Cyprus ">Cyprus</option>
          <option data-qualify="enable" value="Czech Republic ">Czech Republic</option>
          <option data-qualify="enable" value="Denmark ">Denmark</option>
          <option value="Djibouti ">Djibouti</option>
          <option value="Dominica">Dominica1</option>
          <option value="Dominican Republic ">Dominican Republic</option>
          <option value="Ecuador ">Ecuador</option>
          <option value="Egypt ">Egypt</option>
          <option value="El Salvador ">El Salvador</option>
          <option value="Equatorial Guinea ">Equatorial Guinea</option>
          <option value="Eritrea ">Eritrea</option>
          <option data-qualify="enable" value="Estonia ">Estonia</option>
          <option value="Eswatini ">Eswatini</option>
          <option value="Ethiopia ">Ethiopia</option>
          <option value="Falkland Islands ">Falkland Islands</option>
          <option value="Faroe Islands ">Faroe Islands</option>
          <option value="Fiji ">Fiji</option>
          <option data-qualify="enable" value="Finland ">Finland</option>
          <option data-qualify="enable" value="France ">France</option>
          <option value="French Guiana ">French Guiana</option>
          <option value="French Polynesia ">French Polynesia</option>
          <option value="Gabon ">Gabon</option>
          <option value="Gambia ">Gambia</option>
          <option value="Georgia ">Georgia</option>
          <option data-qualify="enable" value="Germany ">Germany</option>
          <option value="Ghana ">Ghana</option>
          <option value="Gibraltar ">Gibraltar</option>
          <option data-qualify="enable" value="Greece ">Greece</option>
          <option value="Greenland ">Greenland</option>
          <option value="Grenada ">Grenada</option>
          <option value="Guadeloupe ">Guadeloupe</option>
          <option value="Guam ">Guam</option>
          <option value="Guatemala ">Guatemala</option>
          <option value="Guernsey ">Guernsey</option>
          <option value="Guinea ">Guinea</option>
          <option value="Guinea-Bissau ">Guinea-Bissau</option>
          <option value="Guyana ">Guyana</option>
          <option value="Haiti ">Haiti</option>
          <option value="Honduras ">Honduras</option>
          <option value="Hong Kong ">Hong Kong</option>
          <option data-qualify="enable" value="Hungary ">Hungary</option>
          <option data-qualify="enable" value="Iceland ">Iceland</option>
          <option value="India ">India</option>
          <option value="Indonesia ">Indonesia</option>
          <option value="Iran ">Iran</option>
          <option value="Iraq ">Iraq</option>
          <option data-qualify="enable" value="Ireland ">Ireland</option>
          <option value="Isle of Man ">Isle of Man</option>
          <option value="Israel ">Israel</option>
          <option data-qualify="enable" value="Italy ">Italy</option>
          <option value="Jamaica ">Jamaica</option>
          <option data-qualify="enable" value="Japan ">Japan</option>
          <option value="Jersey ">Jersey</option>
          <option value="Jordan ">Jordan</option>
          <option value="Kazakhstan ">Kazakhstan</option>
          <option value="Kenya ">Kenya</option>
          <option value="Kiribati ">Kiribati</option>
          <option value="Kosovo ">Kosovo</option>
          <option value="Kuwait ">Kuwait</option>
          <option value="Kyrgyzstan ">Kyrgyzstan</option>
          <option value="Laos ">Laos</option>
          <option data-qualify="enable" value="Latvia ">Latvia</option>
          <option value="Lebanon ">Lebanon</option>
          <option value="Lesotho ">Lesotho</option>
          <option value="Liberia ">Liberia</option>
          <option value="Libya ">Libya</option>
          <option value="Liechtenstein ">Liechtenstein</option>
          <option data-qualify="enable" value="Lithuania ">Lithuania</option>
          <option data-qualify="enable" value="Luxembourg ">Luxembourg</option>
          <option value="Macau ">Macau</option>
          <option data-qualify="enable" value="Macedonia ">Macedonia</option>
          <option value="Madagascar ">Madagascar</option>
          <option value="Malawi ">Malawi</option>
          <option value="Malaysia ">Malaysia</option>
          <option value="Maldives ">Maldives</option>
          <option value="Mali ">Mali</option>
          <option data-qualify="enable" value="Malta ">Malta</option>
          <option value="Marshall ">Marshall Islands</option>
          <option value="Martinique ">Martinique</option>
          <option value="Mauritania ">Mauritania</option>
          <option value="Mauritius ">Mauritius</option>
          <option value="Mayotte ">Mayotte</option>
          <option data-qualify="enable" value="Mexico ">Mexico</option>
          <option value="Micronesia ">Micronesia</option>
          <option value="Moldova ">Moldova</option>
          <option data-qualify="enable" value="Monaco ">Monaco</option>
          <option value="Mongolia ">Mongolia</option>
          <option data-qualify="enable" value="Montenegro ">Montenegro</option>
          <option value="Montserrat ">Montserrat</option>
          <option value="Morocco ">Morocco</option>
          <option value="Mozambique ">Mozambique</option>
          <option value="Myanmar ">Myanmar5</option>
          <option value="Namibia ">Namibia</option>
          <option value="Nauru ">Nauru</option>
          <option data-qualify="enable" value="Netherlands ">Netherlands</option>
          <option value="Nepal ">Nepal</option>     
          <option value="New Caledonia ">New Caledonia</option>
          <option data-qualify="enable" value="New Zealand ">New Zealand</option>
          <option value="Nicaragua ">Nicaragua</option>
          <option value="Niger ">Niger</option>
          <option value="Nigeria ">Nigeria</option>
          <option value="Niue ">Niue</option>
          <option value="Norfolk Island ">Norfolk Island</option>
          <option value="North Korea ">North Korea</option>
          <option value="Northern Mariana Islands ">Northern Mariana Islands</option>
          <option value="Norway ">Norway</option>
          <option value="Oman ">Oman</option>
          <option value="Pakistan ">Pakistan</option>
          <option value="Palau ">Palau</option>
          <option value="Palestine ">Palestine</option>
          <option value="Panama ">Panama</option>
          <option value="Papua New Guinea ">Papua New Guinea</option>
          <option value="Paraguay ">Paraguay</option>
          <option value="Peru ">Peru</option>
          <option value="Philippines ">Philippines</option>
          <option data-qualify="enable" value="Poland ">Poland</option>
          <option data-qualify="enable" value="Portugal ">Portugal</option>
          <option value="Puerto Rico ">Puerto Rico</option>
          <option data-qualify="enable" value="Qatar ">Qatar</option>
          <option value="Réunion ">Réunion</option>
          <option data-qualify="enable" value="Romania ">Romania</option>
          <option data-qualify="enable" value="Russia ">Russia</option>
          <option value="Rwanda ">Rwanda</option>
          <option value="Saint Barthélemy ">Saint Barthélemy</option>
          <option value="Saint Helena ">Saint Helena</option>
          <option value="Saint Kitts and Nevis ">Saint Kitts and Nevis</option>
          <option value="Saint Lucia ">Saint Lucia</option>
          <option value="Saint Martin ">Saint Martin</option>
          <option value="Saint Pierre and Miquelon ">Saint Pierre and Miquelon</option>
          <option value="Saint Vincent and the Grenadines ">Saint Vincent and the Grenadines</option>
          <option value="Samoa ">Samoa</option>
          <option value="San Marino ">San Marino</option>
          <option value="São Tomé and Príncipe ">São Tomé and Príncipe</option>
          <option value="Saudi Arabia ">Saudi Arabia</option>
          <option value="Senegal ">Senegal</option>
          <option data-qualify="enable" value="Serbia ">Serbia</option>
          <option value="Seychelles ">Seychelles</option>
          <option value="Sierra Leone ">Sierra Leone</option>
          <option data-qualify="enable" value="Singapore ">Singapore</option>
          <option value="Sint Maarten ">Sint Maarten</option>
          <option data-qualify="enable" value="Slovakia ">Slovakia</option>
          <option data-qualify="enable" value="Slovenia ">Slovenia</option>
          <option value="Solomon Islands ">Solomon Islands</option>
          <option value="Somalia ">Somalia</option>
          <option value="South Africa ">South Africa</option>
          <option data-qualify="enable" value="South Korea ">South Korea</option>
          <option value="South Sudan ">South Sudan</option>
          <option data-qualify="enable" value="Spain ">Spain</option>
          <option value="Sri Lanka ">Sri Lanka</option>
          <option value="Sudan ">Sudan</option>
          <option value="Suriname">Suriname</option>
          <option value="Svalbard and Jan Mayen ">Svalbard and Jan Mayen</option>
          <option data-qualify="enable" value="Sweden ">Sweden</option>
          <option data-qualify="enable" value="Switzerland ">Switzerland</option>
          <option value="Syria ">Syria</option>
          <option value="Taiwan ">Taiwan</option>
          <option value="Tajikistan ">Tajikistan</option>
          <option value="Tanzania ">Tanzania</option>
          <option value="Thailand ">Thailand</option>
          <option value="Timor-Leste ">Timor-Leste</option>
          <option value="Togo ">Togo</option>
          <option value="Tokelau ">Tokelau</option>
          <option value="Tonga ">Tonga</option>
          <option value="Trinidad and Tobago ">Trinidad and Tobago</option>
          <option value="Tunisia ">Tunisia</option>
          <option value="Turkey ">Turkey</option>
          <option value="Turkmenistan ">Turkmenistan</option>
          <option value="Turks and Caicos Islands ">Turks and Caicos Islands</option>
          <option value="Tuvalu ">Tuvalu</option>
          <option value="U.S. Virgin Islands ">U.S. Virgin Islands</option>
          <option value="Uganda ">Uganda</option>
          <option data-qualify="enable" value="Ukraine ">Ukraine</option>
          <option data-qualify="enable" value="United Arab Emirates ">United Arab Emirates</option>
          <option data-qualify="enable" value="United Kingdom ">United Kingdom</option>
          <option data-qualify="enable" value="United States ">United States</option>
          <option value="Uruguay ">Uruguay</option>
          <option value="Uzbekistan ">Uzbekistan</option>
          <option value="Vanuatu ">Vanuatu</option>
          <option value="Vatican City ">Vatican City</option>
          <option value="Venezuela ">Venezuela</option>
          <option value="Vietnam ">Vietnam</option>
          <option value="Wallis and Futuna">Wallis and Futuna</option>
          <option value="Western Sahara ">Western Sahara</option>
          <option value="Yemen ">Yemen</option>
          <option value="Zambia ">Zambia</option>
          <option value="Zimbabwe ">Zimbabwe</option>
          <option value="Åland Islands">Åland Islands</option>
        </select>
        <!--
        <input id="expiry_date" name="expiry_date" type="date" >
        <span id="expiry_date_errmsg" style="display: none;">
          <span class="requiredArea">Please select your passport expiry date.</span>
        </span>-->
       <!-- <p >8. I have Chinese visa refusal stamps in my passport.</p>
<div class="checkYes">
    <input type="radio" value="I have no Chinese visa refusal stamps in my passport." name="visa_refusal_stamps" id="visa_refusal_stamps_yes" class="checkBorder">
    <label for="visa_refusal_stamps_yes">Yes</label>
</div>
<div class="checkYes">
    <input type="radio" value="I have Chinese visa refusal stamps in my passport." name="visa_refusal_stamps" id="visa_refusal_stamps_no" class="checkBorder">
    <label for="visa_refusal_stamps_no">No</label>
</div>-->
        <button class="sendButton" id="take_a_test_button" name="take_a_test_button" type="button" style="width: 100%; margin-top: 70px;">Take a Test</button>
      </div>
    </form>
    <div id="result_box" style="display: none; padding: 0 20px; text-align: left; font-size: 19px; ">
      <h3 style="text-align: left; padding-bottom: 0;">Result:</h3>
      <p id="qualify_72hours" style="display: none"><strong>You qualify to enjoy China's 72-hour visa-free policy.</strong></p>
      <p id="qualify_144hours" style="display: none"><strong>You qualify to enjoy China's 144-hour visa-free policy.</strong></p>
      <p id="qualify_no" style="display: none"><strong>You don't qualify to enjoy China's 72-hour or 144-hour visa-free policy.</strong></p>
    </div>
    <div id="reason_box" style="display: none; padding: 0 20px; text-align: left; font-size: 19px; font-weight: 400;">
      <p>Reason you don't qualify:</p>
        <ul class="infolist">
            
          <li id="error_transit" style="display: none">You must be in transit to a third country or region.</li>
          <li id="error_72hours" style="display: none">You must leave the city area (prefecture or municipality) after the 72/144 hours (the 72/144-hour limit is calculated starting from 00:00 on the day after arrival, i.e. 24:00 on the arrival date).</li>
         <!--<li id="error_3months" style="display: none">Your passport must be valid for more than 3 months at the time of entry into China.</li>-->
          <li id="error_eligible" style="display: none">Your passport nationality is not eligible for the 72/144-hour visa exemption program.</li>
         <!-- <li id="error_refusal" style="display: none">You have Chinese visa refusal stamps in your passport.</li>-->
        </ul>  
      
    </div>
    <p id="tip_box" style="display: none; padding:0 20px; text-align: left; font-weight: 400; font-size: 19px;">
    <strong >Important notes:</strong> <br>
    1. You are only allowed to remain within and depart China from  <span id="allowed_area" style="font-weight:600;">Beijing</span>.<br>
    2. Your passport must be valid for <strong>more than 3 months</strong> at the time of entry into China. <br>
    3. You dont't have Chinese visa refusal stamps in your passport.<br>
    4. Please bring your <strong>China hotel reservation</strong> in case it is needed at the time of entry into China. 
    <br>
    <br>
    More questions please feel free to <a href="/contactus/">contact us</a>. 
    <br>
    <br>
    <strong>To any visa-related questions, you can get an answer fast by joining our Going to China Facebook Group with 16.7k active memebers.</strong> It is where people talk about China entry policy everyday with real experience. Some who have entered China smoothly woud share their experience as well. Simply click the link and join: <a href="https://www.facebook.com/groups/going2china" target="_blank">Going to China Facebook Group</a>.<br>
    <a href="https://www.facebook.com/login/?next=https%3A%2F%2Fwww.facebook.com%2Fgroups%2Fgoing2china%2F" target="_blank"><img alt="join us to China" class="img-responsive" src="https://data.chinahighlights.com/image/forms/thank-you-going-to-china.jpg" style=" border-radius: 6px;margin-top: 20px;" /></a>
  </p>
</div>
<script>
function ready(fn) {
  const el = (elementId) => {
    var element = document.getElementById(elementId);
    if (element === null) console.error('element is null: ' + elementId);
    element.on = (event, fn) => {
      element.addEventListener(event, fn);
    }
    element.addClass = (className) => {
      element.classList.add(className);
    }
    element.removeClass = (className) => {
      element.classList.remove(className);
    }
    element.show = () => {
      element.style.display = 'block';
    }
    element.hide = () => {
      element.style.display = 'none';
    }
    return element;
  }

  document.addEventListener('DOMContentLoaded', () => {
    fn(el);
  });
}

function calcDiffInDays(fromDate, thruDate) {
  const diffInMs = Math.abs(thruDate - fromDate);
  const diffInDays = Math.ceil(diffInMs / (1000 * 60 * 60 * 24));
  return diffInDays;
}

ready(el => {

  flatpickr("#arrival_date", {
    dateFormat: "Y-m-d",
    altInput: true,
    altFormat: "F j, Y",
    disableMobile: true,
    minDate: "today"
  });

  flatpickr("#departure_date", {
    dateFormat: "Y-m-d",
    altInput: true,
    altFormat: "F j, Y",
    disableMobile: true,
    minDate: "today"
  });

  const takeATestButton = el('take_a_test_button');
  const result_box = el('result_box');
  const reason_box = el('reason_box');
  const tip_box = el('tip_box');

  const error_transit = el('error_transit');
  const error_72hours = el('error_72hours');
  const error_eligible = el('error_eligible');
  
  const qualify_72hours = el('qualify_72hours');
  const qualify_144hours = el('qualify_144hours');
  const qualify_no = el('qualify_no');

  const arriveAtCitySelect = el('arrive_at_city');
  const allowedAreaSpan = el('allowed_area');
  let selectedCity = arriveAtCitySelect.options[arriveAtCitySelect.selectedIndex].value;

  const departure_date_errmsg = el('departure_date_errmsg');
  const arrival_date_errmsg = el('arrival_date_errmsg');

  const cityAirportMap = new Map([
    ['Beijing', [
        {text: 'Beijing Capital International Airport, PEK', hour: '144'},
        {text: 'Beijingxi Railway Station', hour: '144'},
        {text: 'Beijing Daxing International Airport, PKX', hour: '144'},
      ]
    ],
    ['Shanghai', [
        {text: 'Shanghai Pudong International Airport, PVG', hour: '144'},
        {text: 'Shanghai Hongqiao International Airport, SHA', hour: '144'},
        {text: 'Shanghai Port International Cruise Terminal', hour: '144'},
        {text: 'Shanghai Wusongkou International Cruise Terminal', hour: '144'},
        {text: 'Shanghai Railway Station', hour: '144'},
        {text: 'Shanghainan Railway Station', hour: '144'},
        {text: 'Shanghaixi Railway Station', hour: '144'},
        {text: 'Shanghai Hongqiao Railway Station', hour: '144'},
      ]
    ],
    ['Guangzhou', [
        {text: 'Guangzhou Baiyun International Airport, CAN', hour: '72,144'},
      ]
    ],
    ['Chengdu', [
        {text: 'Chengdu Shuangliu International Airport, CTU', hour: '72,144'},
        {text: 'Chengdu Tianfu International Airport, TFU', hour: '144'},
      ]
    ],
    ['Chongqing', [
        {text: 'Chongqing Jiangbei International Airport, CKG', hour: '72,144'},
        {text: 'Chongqing Wanzhou Wuqiao Airport, WXN', hour: '144'},
      ]
    ],
    ['Guilin', [
        {text: 'Guilin Liangjiang International Airport, KWL', hour: '72'},
      ]
    ],
    ["Xi'an", [
        {text: "Xi'an Xianyang International Airport, XIY", hour: '72,144'},
      ]
    ],
    ["Kunming", [
        {text: "Kunming Changshui International Airport, KMG", hour: '72,144'},
      ]
    ],
    ["Qingdao", [
        {text: "Qingdao Liuting International Airport, TAO", hour: '72'},
        {text: "Qingdao Jiaodong International Airport, TAO", hour: '144'},
        {text: "Qingdao Port", hour: '144'},
      ]
    ],
    ["Xiamen", [
        {text: "Xiamen Gaoqi International Airport, XMN", hour: '72'},
        {text: "Xiamen Wutong Wharf", hour: '144'},
      ]
    ],
    ["Wuhan", [
        {text: "Wuhan Tianhe International Airport, WUH", hour: '72,144'},
      ]
    ],
    ["Harbin", [
        {text: "Harbin Taiping International Airport, HRB", hour: '72'},
      ]
    ],
    ["Changsha", [
        {text: "Changsha Huanghua International Airport, CSX", hour: '72'},
      ]
    ],
    ["Tianjin", [
        {text: "Tianjin Binhai International Airport, TSN", hour: '144'},
        {text: "Tianjin International Cruise Home Port", hour: '144'},
      ]
    ],
    ["Shijiazhuang", [
        {text: "Shijiazhuang Zhengding International Airport, SJW", hour: '144'},
      ]
    ],
    ["Qinhuangdao", [
        {text: "Qinhuangdao Port", hour: '144'},
      ]
    ],
    ["Shenzhen", [
        {text: "Shenzhen Bao'an International Airport, SZX", hour: '144'},
      ]
    ],
    ["Hangzhou", [
        {text: "Hangzhou International Airport, HGH", hour: '144'},
      ]
    ],
    ["Nanjing", [
        {text: "Nanjing Lukou International Airport, NKG", hour: '144'},
      ]
    ],
    ["Ningbo", [
        {text: "Ningbo Lishe International Airport, NGB", hour: '144'},
      ]
    ],
    ["Shenyang", [
        {text: "Shenyang Taoxian International Airport, SHE", hour: '144'},
      ]
    ],
    ["Jieyang", [
        {text: "Jieyang Chaoshan International Airport, SWA", hour: '144'},
      ]
    ],
    ["Dalian", [
        {text: "Dalian Zhoushuizi International Airport, DLC", hour: '144'},
      ]
    ],
  ]);
  
// Chengdu: Chengdu 72小时
// Chengdu: Sichuan Province 144小时
  const cityProvinceMap = new Map([
    ['Beijing', 'Beijing, Tianjin, Hebei Province'],
    ['Shanghai', 'Shanghai, Jiangsu Province, Zhejiang Province'],
    ['Hangzhou', 'Shanghai, Jiangsu Province, Zhejiang Province'],
    ['Shenyang', 'Liaoning Province'],
    ['Dalian', 'Liaoning Province'],
    ['Ningbo', 'Shanghai, Jiangsu Province, Zhejiang Province'],
    ['Nanjing', 'Shanghai, Jiangsu Province, Zhejiang Province'],
    ['Qinhuangdao', 'Beijing, Tianjin, Hebei Province'],
    ['Shijiazhuang', 'Beijing, Tianjin, Hebei Province'],
    ['Tianjin', 'Beijing, Tianjin, Hebei Province'],
    ['Changsha', 'Hunan Province'],
    ['Harbin', 'Harbin'],
    ['Wuhan', 'Wuhan'],
    ['Xiamen', 'Xiamen'],
    ['Qingdao', 'Shandong Province'],
    ['Kunming', 'Kunming'],
    ["Xi'an", "Xi'an, Xianyang"],
    ['Guilin', 'Guilin'],
    ['Chongqing', 'Chongqing'],
    ['Jieyang', 'Guangdong province'],
    ['Shenzhen', 'Guangdong province'],
    ['Guangzhou', 'Guangdong province'],
  ]);

  const airportSelect = el('airport_or_railway_station');
  arriveAtCitySelect.on('change', () => {
    selectedCity = arriveAtCitySelect.options[arriveAtCitySelect.selectedIndex].value;
    const airportList = cityAirportMap.get(selectedCity)
    airportSelect.options.length = 0;
    airportList.forEach(element => {
      let opt = new Option(element.text, element.text);
      opt.setAttribute('data-hour', element.hour);
      airportSelect.options.add(opt); 
    });
  });

  takeATestButton.on('click', () => {

    var validateSuccess = true;
    var thirdCountry = true;
    var qualify2China = true;
    var visa72hours = true;
    var visa144hours = true;
    const departFrom = el('depart_from').value.trim();
    const leave4Country = el('leave_for_country').value.trim();

    const arrivalDateVal = el('arrival_date').value;
    const departureDateVal = el('departure_date').value;

    error_transit.hide();
    error_72hours.hide();
    error_eligible.hide();
    qualify_72hours.hide();
    qualify_144hours.hide();
    qualify_no.hide();
    departure_date_errmsg.hide();
    arrival_date_errmsg.hide();

    if (arrivalDateVal === '')  {
      arrival_date_errmsg.show();
    }
    if (departureDateVal === '')  {
      departure_date_errmsg.show();
    }

    if (arrivalDateVal === '' || departureDateVal === '') return;

    if (departFrom === leave4Country) {
      thirdCountry = false;
      error_transit.show();
    }

    const nationality = el('nationality');
    const selectedCountry = nationality.options[nationality.selectedIndex];
    const qualifyCountry = selectedCountry.getAttribute('data-qualify');
    if (qualifyCountry == null || qualifyCountry != 'enable') {
      qualify2China = false;
      error_eligible.show();
    }

    const arrivalDate = new Date(arrivalDateVal);
    const departureDate = new Date(departureDateVal);

    const diffInDays = calcDiffInDays(arrivalDate, departureDate);

    const airportOrRailwayStation = el('airport_or_railway_station');
    const selectedOption = airportOrRailwayStation.options[airportOrRailwayStation.selectedIndex];
    const indexOf72 = selectedOption.getAttribute('data-hour').indexOf('72');
    const indexOf144 = selectedOption.getAttribute('data-hour').indexOf('144');
    
    if (diffInDays < 1 || diffInDays > 3 || indexOf72 == -1) {
      visa72hours = false;
      error_72hours.show();
    }

    if (diffInDays < 1 || diffInDays > 6 || indexOf144 == -1) {
      visa144hours = false;
      error_72hours.show();
    }
    
    validateSuccess = (visa144hours || visa72hours) && qualify2China && thirdCountry;
    result_box.show();
    if (validateSuccess) {
      tip_box.show();
      reason_box.hide();

      const allowedArea = cityProvinceMap.get(selectedCity);
      if (allowedArea != null && allowedArea != 'Chengdu') {
        allowedAreaSpan.innerText = allowedArea;
      }
      
      if (visa72hours) {
        qualify_72hours.show();

        if (selectedCity == 'Chengdu') {
          allowedAreaSpan.innerText = 'Chengdu';
        }
      }

      if (visa144hours) {
        qualify_144hours.show();

        if (selectedCity == 'Chengdu') {
          allowedAreaSpan.innerText = 'Sichuan Province';
        }
      }
    } else {
      tip_box.hide();
      qualify_no.show();
      reason_box.show();
    }
  });
});
</script>
<style>
.date_pick {    width: 92% !important;
    background: url(https://data.chinahighlights.com/pic/top10/tour-calendar.png) no-repeat 15px #fff;
    padding-left: 50px !important;
    border-radius: 6px !important;
    height: 40px !important;}
        @media (max-width: 750px) {
          .date_pick {width: 87% !important;}      
        }
</style>
