var collegeForm_lastTown=-1;
var collegeForm_lastPostcode=-1;


// Hide given town column, clear value of <select> and redraw the label
function collegeForm_hideTown(CountryID){
	var TownColumn=document.getElementById("Town_"+CountryID);
	if(TownColumn){
		var TownColumnLabel=document.getElementById("Town_"+CountryID+"_label");
		TownColumnLabel.style.display="none";
		TownColumn.style.display="none";
	}
}

// Hide given town postcode area, clear value of <select> and redraw the label
function collegeForm_hidePostcode(CountryID, TownID){
	var PostcodeColumn=document.getElementById("Postcode_"+CountryID+"_"+TownID);
	if(PostcodeColumn){
		var PostcodeColumnLabel=document.getElementById("Postcode_"+CountryID+"_"+TownID+"_label");
		PostcodeColumnLabel.style.display="none";
		PostcodeColumn.style.display="none";
	}
}


// Show town column for country dropdown (automatically hides any that are currently displayed)
function collegeForm_showTown(FormObject){
	var CountryID=FormObject.value;
	
	if(collegeForm_lastTown>-1) collegeForm_hideTown(collegeForm_lastTown);
	
	
	var TownColumn=document.getElementById("Town_"+CountryID);
	if(TownColumn){
		var TownDropdown=document.getElementById("nTown"+CountryID);
		if(TownDropdown.value) collegeForm_showPostcode(TownDropdown, CountryID); // Try to show Postcode column if a city is already selected
		TownColumn.style.display="block";
		collegeForm_lastTown=CountryID;
	}else{
		collegeForm_lastTown=-1;
	}
}

// Show postcode column for town dropdown (automatically hides any that are currently displayed)
function collegeForm_showPostcode(FormObject, CountryID){
	var TownID=FormObject.value;
	
	if(collegeForm_lastPostcode>-1) collegeForm_hidePostcode(CountryID, collegeForm_lastPostcode);
	
	var PostcodeColumn=document.getElementById("Postcode_"+CountryID+"_"+TownID);

	if(PostcodeColumn){
		PostcodeColumn.style.display="block";
		collegeForm_lastPostcode=TownID;
	}else{
		collegeForm_lastPostcode=-1;
	}
}