var states = [];

states[0] = [
	[0, 'Select a State']
];

states[1] = [
	[0, 'Select a Province']
];

states[2] = [
	[0, 'Select a State']
	];
states[3] = [
	[0, '                 ']
];

function switch_state_select()
{
	country = parseInt($('#meeting_country_select').val());
	$('#meeting_state_select').empty();
	for(i in states[country]) {
		op = $(document.createElement('option')).val(states[country][i][0]).text(states[country][i][1]);
		$('#meeting_state_select').append(op);
	}
	
	
}

$(function(){
	arrs = [];
	var ci = 1;
	var ai = 1;
	$('#meeting_state_select option').each(function(){
		val = $(this).val();
		text = $(this).text();
		
		if (val>0) {
			if (val>51) {
				//	canada
				states[1][ci++] = [val, text];
			} else {
				states[2][ai++] = [val, text];
			}
		}
	});
	
	$('#meeting_country_select').change(function(){
		val = '';
		$(this).find('option').each(function(){
			if ($(this).attr('selected') && $(this).val()!='0') {
				val = $(this).text();
			}
		});
		if (val!='') {
			$('#meeting_country').val(val);
		}
		
		switch_state_select();
	});	
});
