<script type="text/javascript">
	
var countries = {
	'CA': { //Canada
		'AB' : 'Alberta', 'BC' : 'British Columbia', 'MA' : 'Manitoba', 'NB' : 'New Brunswick', 'NL' : 'Newfoundland and Labrador', 'NT' : 'Northwest Territories', 'NS' : 'Nova Scotia', 'NU' : 'Nunavut', 'ON' : 'Ontario', 'PE' : 'Prince Edward Island', 'QU' : 'Québec', 'SA' : 'Saskatchewan', 'YU' : 'Yukon'
	},
	'US' : { //USA
		'AL' : 'Alabama', 'AK' : 'Alaska', 'AZ' : 'Arizona', 'AR' : 'Arkansas', 'CA' : 'California', 'CO' : 'Colorado', 'CT' : 'Connecticut', 'DE' : 'Delaware', 
		'DC' : 'District of Columbia', 'FL' : 'Florida', 'GA' : 'Georgia', 'HI' : 'Hawaii', 'ID' : 'Idaho', 'IL' : 'Illinois', 'IN' : 'Indiana',
		'IA' : 'Iowa', 'KS' : 'Kansas', 'KY' : 'Kentucky', 'LA' : 'Louisiana', 'ME' : 'Maine', 'MD' : 'Maryland', 'MA' : 'Massachusetts', 'MI' : 'Michigan',
		'MN' : 'Minnesota', 'MS' : 'Mississippi', 'MO' : 'Missouri', 'MT' : 'Montana', 'NE' : 'Nebraska', 'NV' : 'Nevada', 'NH' : 'New Hampshire',
		'NJ' : 'New Jersey', 'NM' : 'New Mexico', 'NY' : 'New York', 'NC' : 'North Carolina', 'ND' : 'North Dakota', 'OH' : 'Ohio', 'OK' : 'Oklahoma',
		'OR' : 'Oregon', 'PA' : 'Pennsylvania', 'RI' : 'Rhode Island', 'SC' : 'South Carolina', 'SD' : 'South Dakota', 'TN' : 'Tennessee', 'TX' : 'Texas',
		'UT' : 'Utah', 'VT' : 'Vermont', 'VA' : 'Virginia', 'WA' : 'Washington', 'WV' : 'West Virginia', 'WI' : 'Wisconsin', 'WY' : 'Wyoming'
	}
	};

//jQuery(document).ready(function() {
	if (jQuery('#country_id')) {
		jQuery('#country_id').change(function () {
			var country_id = jQuery('#country_id').val();

			var region_select = jQuery('#region_id'); //state
			if (region_select) {
				var first_option = jQuery('#region_id option:first');
				region_select.empty();
				region_select.append(first_option);
			}
			var states = countries[country_id];
			if (states) {
				if (region_select) {
					jQuery.each(states, function(key, title) {
						region_select.append(jQuery('<option></option>').attr('value', key).text(title));
					});
					region_select.show();
				}

				// Hides region textbox
				jQuery('#region').hide();
				region_select.val(jQuery('#region_selected_id').val());
			} else {

				// Shows region textbox
				jQuery('#region').show();
				region_select.hide();
			}
			// Region textbox set to blank (always)
			jQuery('#region').val('');
		});
		jQuery('#country_id').change();
		
		jQuery('#region_id').change(function() {
			jQuery('#region').val(jQuery("#region_id option:selected").text());
		});
	}
	
	if (jQuery('#billing_country_id')) {
		jQuery( '#new_billing_area' ).on( 'change', '#billing_country_id', function () {
			var country_id = jQuery('#billing_country_id').val();
			var region_select = jQuery('#billing_region_id'); //state
			if (region_select) {
				var first_option = jQuery('#billing_region_id option:first');
				region_select.empty();
				region_select.append(first_option);
			}
			var states = countries[country_id];
			if (states) {
				if (region_select) {
					jQuery.each(states, function(key, title) {
						region_select.append(jQuery('<option></option>').attr('value', key).text(title));
					});
					region_select.show();
				}

				// Hides region textbox
				jQuery('#billing_region').hide();
				
				region_select.val(jQuery('#billing_region_selected_id').val());
			} else {
				// Shows region textbox
				jQuery('#billing_region').show();
				region_select.hide();
			}
			// Region textbox set to blank
			jQuery('#billing_region').val('');
		} );
		jQuery('#billing_country_id').change();

		jQuery('#billing_region_id').change(function() {
			jQuery('#billing_region').val(jQuery("#billing_region_id option:selected").text());
		} );
	}

	if (jQuery('#shipping_country_id')) {
		jQuery('#shipping_country_id').change(function () {
			var country_id = jQuery('#shipping_country_id').val();

			var region_select = jQuery('#shipping_region_id'); //state
			if (region_select) {
				var first_option = jQuery('#shipping_region_id option:first');
				region_select.empty();
				region_select.append(first_option);
			}
			var states = countries[country_id];
			if (states) {
				if (region_select) {
					jQuery.each(states, function(key, title) {
						region_select.append(jQuery('<option></option>').attr('value', key).text(title));
					});
					region_select.show();
				}

				// Hides region textbox
				jQuery('#shipping_region').hide();
				region_select.val(jQuery('#shipping_region_selected_id').val());
			} else {
				// Shows region textbox
				jQuery('#shipping_region').show();
				region_select.hide();
			}

			// Region textbox set to blank
			jQuery('#shipping_region').val('');
		});
		jQuery('#shipping_country_id').change();

		jQuery('#shipping_region_id').change(function() {
			jQuery('#shipping_region').val(jQuery("#shipping_region_id option:selected").text());
		});
	}
//});
	</script>{"id":2415,"date":"2012-11-04T14:40:43","date_gmt":"2012-11-04T19:40:43","guid":{"rendered":"http:\/\/prod.publicationsnunavik.com:8888\/?page_id=2415"},"modified":"2012-11-04T14:40:43","modified_gmt":"2012-11-04T19:40:43","slug":"address","status":"publish","type":"page","link":"https:\/\/publicationsnunavik.com\/iu\/address\/","title":{"rendered":"Address"},"content":{"rendered":"\t\t\t<p>\n\t\t\tYou need to login to see your address.\t\t\t<\/p>\n\t\t\t\n<div id=\"tcp_login\">\n\t<form id=\"loginform\" method=\"post\" action=\"https:\/\/publicationsnunavik.com\/wp-content\/plugins\/thecartpress\/checkout\/login.php\" name=\"loginform\">\n\t\t\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"tcp_register_and_login\" \/>\n\n\t\t<div class=\"form-group\">\n\t\t\t<div class=\"tcp_login_username_label\">\n\t\t\t\t<label for=\"user_login\">Username<\/label>\n\t\t\t<\/div>\n\n\t\t\t<div class=\"tcp_login_username\">\n\t\t\t\t<input id=\"user_login\" class=\"input\" type=\"text\" size=\"20\" value=\"\" name=\"tcp_log\" \/>\n\t\t\t<\/div>\n\t\t<\/div>\n\n\t\t<div class=\"form-group\">\n\t\t\t<div class=\"tcp_login_password_label\">\n\t\t\t\t<label for=\"user_pass\">Password<\/label>\n\t\t\t<\/div>\n\n\t\t\t<div class=\"form-group tcp_login_password\">\n\t\t\t\t<input id=\"user_pass\" class=\"input\" type=\"password\" size=\"20\" value=\"\" name=\"tcp_pwd\" \/>\n\t\t\t<\/div>\n\t\t<\/div>\n\n\t\t<input type=\"hidden\" name=\"_wp_original_http_referer\" value=\"\/iu\/wp-json\/wp\/v2\/pages\/2415\" \/>\n\t\t<div class=\"form-group tcp_login_submit\">\n\t\t\t<button id=\"wp-submit\" class=\"tcp_checkout_button tcp-btn tcp-btn tcp-btn-info\" type=\"submit\" value=\"\" name=\"tcp_submit\">Log In<\/button>\n\t\t\t\t\t\t<input type=\"hidden\" value=\"\" name=\"tcp_redirect_to\" \/>\n\t\t<\/div>\n\n\t\t<div class=\"form-group tcp_login_remember\">\n\t\t\t<input id=\"rememberme\" type=\"checkbox\" value=\"forever\" name=\"tcp_rememberme\" \/>\n\t\t\t<label for=\"rememberme\" class=\"tcp_login_remember_label\">Remember Me<\/label>\n\t\t<\/div>\n\n\t\t<div class=\"form-group tcp_lost_password\">\n\t\t\t<a id=\"tcp_lost_password\" href=\"https:\/\/publicationsnunavik.com\/iu\/login-nunavik\/?action=lostpassword\" title=\"Password Lost and Found\">Lost your password?<\/a>\n\t\t\t\t\t\t<\/div>\n\n\t\t\t<\/form>\n<\/div><!-- .tcp_login -->\n\t\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":596,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-Address.php","meta":[],"_links":{"self":[{"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/pages\/2415"}],"collection":[{"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/comments?post=2415"}],"version-history":[{"count":0,"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/pages\/2415\/revisions"}],"wp:attachment":[{"href":"https:\/\/publicationsnunavik.com\/iu\/wp-json\/wp\/v2\/media?parent=2415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}