﻿var ddlCountryType;
var ddlStateType;

function refreshStateList(countryList, stateList) {
    
    ddlCountryType = document.getElementById(countryList);
    ddlStateType = document.getElementById(stateList);
    
    ddlStateType.options.length = 0;
    var countryCode = ddlCountryType.value;
    if (countryCode) {
        var url = "/FindStates/" + countryCode;
        getContent(url, bindOptionResults);
    }
}

function refreshPlayerStateList(countryList, stateList) {

    ddlCountryType = document.getElementById(countryList);
    ddlStateType = document.getElementById(stateList);

    ddlStateType.options.length = 0;
    var countryCode = ddlCountryType.value;
    if (countryCode) {
        var url = "/FindPlayerStates/" + countryCode;
        getContent(url, bindOptionResults);
    }
}

function bindOptionResults(data) {
    var newOption;
    for (var k = 0; k < data.length; k++) {
        newOption = new Option(data[k].Text, data[k].Code);
        ddlStateType.options.add(newOption);
    }
}