//----------------------------------------------------------------
//
// counties list
// last modified: 09-12-09
// © matthew adams
//
//----------------------------------------------------------------

function showcounties() {
	
	cdiv = document.getElementById('UKCountry');			//UK Areas List

//If selceted area = England(EN) show english counties and set selection name to LocationDeliveryRegion
	div = document.getElementById('State(EN)');
	selectname = document.getElementById('ENDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'EN') {
		div.style.display = 'block';
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be open, make sure its not shown and name attribute is set to "blank"
		div.style.display = 'none';
		selectname.name = 'blank';
		selectname.value = 'UndefinedRegion';
	}

//If selceted area = Sctoland(SC) show scotish counties and set selection name to LocationDeliveryRegion
	div = document.getElementById('State(SC)');
	selectname = document.getElementById('SCDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'SC') {
		div.style.display = 'block';
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be open, make sure its not shown and name attribute is set to "blank"
		div.style.display = 'none';
		selectname.name = 'blank';
		selectname.value = 'UndefinedRegion';
	}

//If selceted area = Wales(WL) show welish counties and set selection name to LocationDeliveryRegion
	div = document.getElementById('State(WL)');
	selectname = document.getElementById('WLDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'WL') {
		div.style.display = 'block';
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be open, make sure its not shown and name attribute is set to "blank"
		div.style.display = 'none';
		selectname.name = 'blank';
		selectname.value = 'UndefinedRegion';
	}

//If selceted area = Northen Ireland(NI) show northen ireland counties and set selection name to LocationDeliveryRegion
	div = document.getElementById('State(NI)');
	selectname = document.getElementById('NIDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'NI') {
		div.style.display = 'block';
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be open, make sure its not shown and name attribute is set to "blank"
		div.style.display = 'none';
		selectname.name = 'blank';
		selectname.value = 'UndefinedRegion';
	}

//If selceted area = Channel Islands(CI) set selection name to LocationDeliveryRegion
	selectname = document.getElementById('CIDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'CI') {
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be selected, make sure its the name attribute is set to "blank"
		selectname.name = 'blank';
	}

//If selceted area = Isle Of Man(IM) set selection name to LocationDeliveryRegion
	selectname = document.getElementById('IMDeliveryRegion');
	if (cdiv.options[cdiv.selectedIndex].value == 'IM') {
		selectname.name = 'LocationDeliveryRegion';
	} else {									//if this isn't supposed to be selected, make sure its the name attribute is set to "blank"
		selectname.name = 'blank';
	}

}


function selectedcountry() {
	cdiv = document.getElementById('lstDeliveryCountry');		//Countries List
	div = document.getElementById('showhidearea');			//UK Areas List Area
	uklist = document.getElementById('UKCountry');			//UK Areas List
	nonukdiv = document.getElementById('NoDeliveryRegion');	//Not UK empty state/county value "UndefinedRegion"
	if (cdiv.options[cdiv.selectedIndex].value == 'UK') {		//If United Kingdom is selected show UK Area List
		div.style.visibility = 'visible';
		nonukdiv.name = 'blank';					//set no state/county list name to "blank"
		showcounties();							//Make sure no county lists are open (used mainly for onload)
	} else {
		div.style.visibility = 'hidden';				//If United Kingdom isn't selected hide UK Area List & hide Counties List if any open
		uklist.value = 'Undefined';					//Set UK Area List to "Select Area"
		showcounties();
		nonukdiv.name = 'LocationDeliveryRegion';			//set state/county list name to "LocationDeliveryRegion"
	}

}

