function showHide(id) {
    obj = document.getElementsByTagName("div");
	if (obj[id].style.display == 'block')
	{
		obj[id].style.display = 'none';
	}
	else
	{
		obj[id].style.display = 'block';
	}
} 

function regionSelect(id, ieurl, ukurl) {
	if (document.getElementById(id).value == "ie")
	{
		//alert(ieurl + location.pathname + "?site=ie");
		window.location = ieurl + location.pathname + "?site=ie";
	}
	else if (document.getElementById(id).value == "ni")
	{
		//alert(ukurl +  location.pathname + "?site=ni");
		window.location = ukurl + location.pathname + "?site=ni";
	}
	else
	{
		//alert(ieurl +  location.pathname);
		window.location = ieurl + location.pathname;
	}
}

function updateCheckoutCountry()
{
	if ((document.savehistory.county.value == "Antrim") || (document.savehistory.county.value == "Armagh") ||
		(document.savehistory.county.value == "Down") || (document.savehistory.county.value == "Fermanagh") || 
		(document.savehistory.county.value == "Londonderry") || (document.savehistory.county.value == "Tyrone"))
	{
		document.savehistory.country.value = "Northern Ireland";
	} 
	else 
	{
		document.savehistory.country.value = "Ireland";
	}
}

function validateDetails() {
	var cname = document.savehistory.cname;
	var address1 = document.savehistory.address1;
	var city = document.savehistory.city;
	var county = document.savehistory.county;
	var email = document.savehistory.email;
	var cphone = document.savehistory.cphone;

	if(cname.value == "")
	{
		alert("You must enter your name before continuing.");
		cname.focus();
		return false;
	}
	else if(address1.value == "")
	{
		alert("You must enter your address before continuing.");
		address1.focus();
		return false;
	}
	else if(city.value == "")
	{
		alert("You must enter your city before continuing.");
		city.focus();
		return false;
	}
	else if(county.value == "")
	{
		alert("Please select a county from the list.");
		county.focus();
		return false;
	}
	else if(email.value == "")
	{
		alert("You must enter a valid email address before continuing.");
		email.focus();
		return false;
	}
	else if(!isValidEmail(email.value))
	{
		alert("You must enter a valid email address before continuing.");
		email.focus();
		return false;
	}
	else if(cphone.value == "")
	{
		alert("You must enter your contact number before continuing.");
		cphone.focus();
		return false;
	}

	return true;
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}