﻿function ChangeDropDownList(dropDownListId, valueText) {
    $(dropDownListId+" option").removeAttr("selected");
    $(dropDownListId+" option[value='"+valueText+"']").attr("selected", "selected"); 
    $(dropDownListId).change();
}

function ResetDropDownList(dropDownListId) {
    $(dropDownListId+" option").removeAttr("selected");
    $(dropDownListId+" option[value='']").attr("selected", "selected");
    $(dropDownListId).change();
}
var createOption = function(value, text) {
	return "<option value='" + value + "'>" + text + "</option>";
};
var updateProvinces = function() {
	$('select#state').html("");
	var countryCode = $('select#country option:selected').val();
	for(var i in country) {
		if(country[i].code  == countryCode)
		{
			for(var j in country[i].provinces) {
				$(createOption(country[i].provinces[j].code, country[i].provinces[j].name)).appendTo("select#state");
			}
			return;
		}
	}
};

