$(function() {
	$("#billprovince").hide();
	$("#billstate option").hide();
	$("#billstate option.us").show();
	$("#lblbillstate").text("State/Zip:");
	
	$("#block-shipping").hide();
	
	$("#shipprovince").hide();
	$("#shipstate option").hide();
	$("#shipstate option.us").show();
	$("#lblshipstate").text("State/Zip:");
	
	$("#chksamebilling").click(function(){
		if (this.checked)
			$("#block-shipping").slideUp("slow");
		else
			$("#block-shipping").slideDown("slow")();
			
			
	});

	$("select.country").change(function(){
		var whichone = $(this).attr("id").substr(0,4);
		var country = "#" + whichone + "country";
		var items = "#" + whichone + "items";
		var state = "#" + whichone + "state";
		var province = "#" + whichone + "province";
		var lblstate = "#lbl" + whichone + "state";
		
		switch ($(country).val()) {
		case "US":
			$(items).slideUp("slow", function(){
				$(state).show();
				$(state + " option").hide();
				$(state + " option.us").show();
				$(state).attr('selectedIndex', '0').children("option:selected").removeAttr("selected");
				$(province).hide();
				$(province).val("");
				$(lblstate).text("State/Zip:");
			});
			break;
		case "CA":
			$(items).slideUp("slow", function(){
				$(state).show();
				$(state + " option").hide();
				$(state + " option.ca").show();
				$(state).attr('selectedIndex', '0').children("option:selected").removeAttr("selected");
				$(province).hide();
				$(province).val("");
				$(lblstate).text("Province/Postal:");
			});
			break;
		case "MX":
			$(items).slideUp("slow", function(){
				$(state).show();
				$(state + " option").hide();
				$(state + " option.mx").show();
				$(state).attr('selectedIndex', '0').children("option:selected").removeAttr("selected");
				$(province).hide();
				$(province).val("");
				$(lblstate).text("State/Zip:");
			});
			break;
		default:
			$(items).slideUp("slow", function(){
				$(state).hide();
				$(state).attr('selectedIndex', '0').children("option:selected").removeAttr("selected");
				$(province).show();
				$(province).val("");
				$(lblstate).text("Province/Postal:");
			});
			break;
		}
		$(items).slideDown("slow");
	});
});