$(document).ready(function(){
	$("#regions").change(onSelectChange);
	$('#offstage #state').swap('form #statePlaceholder');
});
function onSelectChange(){
	var selected = $("#regions option:selected");		
	if(selected.val() == 102){
		$('#offstage #state').swap('form #statePlaceholder');
		$('#offstage #provincePlaceholder').swap('form #province');
	}else if (selected.val() == 100){
		$('#offstage #province').swap('form #provincePlaceholder');
		$('#offstage #statePlaceholder').swap('form #state');
	}else{
		$('#offstage #provincePlaceholder').swap('form #province');
		$('#offstage #statePlaceholder').swap('form #state');
	}
	
}

jQuery.fn.swap = function(b){
try{
   b = jQuery(b)[0];
   var a = this[0];
   var t = a.parentNode.insertBefore(document.createTextNode(''), a);
   b.parentNode.insertBefore(a, b);
   t.parentNode.insertBefore(b, t);
   t.parentNode.removeChild(t);
   return this;
   }
   catch(err){
   //don't fail if there is nothing to swap with
   }
};