﻿var provinceStartIndex = 0;
var provinceEndIndex = 12;
var defaultProvinceIndex = 0;
var stateStartIndex = 13;
var stateEndIndex = 63;
var defaultStateIndex = 60;
var otherIndex = 64;

function OnCountrySelectedIndexChanged() {
    var stateDropDownList = document.getElementById('ddlProvince');
    switch (document.getElementById('ddlCountry').value) {
        case 'CA':
            //document.getElementById('BYPASS_QAS_VERIFICATION').value = false;
            if (stateDropDownList.selectedIndex < provinceStartIndex || stateDropDownList.selectedIndex > provinceEndIndex) {
                stateDropDownList.selectedIndex = defaultProvinceIndex;
            }
            break;
        case 'US':
            //document.getElementById('BYPASS_QAS_VERIFICATION').value = false;
            if (stateDropDownList.selectedIndex < stateStartIndex || stateDropDownList.selectedIndex > stateEndIndex) {
                stateDropDownList.selectedIndex = defaultStateIndex;
            }
            break;
        default:
            //document.getElementById('BYPASS_QAS_VERIFICATION').value = true;
            stateDropDownList.selectedIndex = otherIndex;
            break;
    }
}

function OnStateSelectedIndexChanged() {
    var stateDropDownList = document.getElementById('ddlProvince');
    var countryDropDownList = document.getElementById('ddlCountry');

    if (stateDropDownList.selectedIndex >= provinceStartIndex && stateDropDownList.selectedIndex <= provinceEndIndex) {
        countryDropDownList.value = 'CA'
    }
    else {
        if (stateDropDownList.selectedIndex >= stateStartIndex && stateDropDownList.selectedIndex <= stateEndIndex) {
            countryDropDownList.value = 'US'
        }
        else {
            countryDropDownList.value = ''
        }
    }
}