// ###########################
// created by: Ben Weeks
// Created Date: 28th October 2005
// Company: webtechy.co.uk
//
// Modified By:
// Modified Date:
// Modified Comment:
//
// Version: 1.00
// ###########################

function AlterPartySelect() {
	var bFound;
	var sString = "";
	//var sPartyID = "_ctl28_idSearch_idParties";
	var sPartyID = "PartySelectSpan";
	aAllowedParties = new Array();
	aAllowedParties[0] = "All";
	aAllowedParties[1] = "Labour";
	aAllowedParties[2] = "Conservative";
	aAllowedParties[3] = "Liberal Democrat";
  	aAllowedParties[4] = "Independent";

	try {
		oPartySelect = document.getElementById(sPartyID).firstChild;

		if (oPartySelect) {
			aOptionsToRemove = new Array();
			var iNumberOfOptions = oPartySelect.children.length;
	
			// Search through the options	
			for (var i = 0; i <= iNumberOfOptions - 1; i++) {
				bFound = false;
				for (var j = 0; j <= aAllowedParties.length - 1; j++) {
					if (oPartySelect.children[i]) { // Just to be on the safe side, should work without this really.
						if (oPartySelect.children[i].innerText == aAllowedParties[j]) {
							// OK, we've found one of the parties that 
							// we want, so set it to found.  could at
							// this point jump out of the for loop 
							// really to speed things up.
							bFound = true;
						}
					}
				}
				if (bFound != true) {
					oPartySelect.children[i].removeNode();
					i--; // We have to go back one because we have just removed one!
					iNumberOfOptions--; // We also have to reduce the total number by one!
				}
			}
			// alert(sString);
		}
		else {
			// alert("Party select list with the ID " + sPartyID + " not found on this page.");
		}
	}
	catch(er) {
		// We'll just have to leave the list as it is.
	}
}

AlterPartySelect();
