function ShowHideFields(country)
{
	var oUsaFormElements = document.getElementById('usaFormFields');
	var oCanadaFormElements = document.getElementById('canadaFormFields');
	var oInternationalFormElements = document.getElementById('internationalFormFields');
	var oSubmitButton = document.getElementById('submitButton');
	if(country == 'USA')
	{
		oUsaFormElements.style.display = 'block';
		oCanadaFormElements.style.display = 'none';
		oInternationalFormElements.style.display = 'none';
		oSubmitButton.style.display = 'block';
	}
	else if(country == 'Canada')
	{
		oUsaFormElements.style.display = 'none';
		oCanadaFormElements.style.display = 'block';
		oInternationalFormElements.style.display = 'none';
		oSubmitButton.style.display = 'block';
	}
	else if(country == 'International')
	{
		oUsaFormElements.style.display = 'none';
		oCanadaFormElements.style.display = 'none';
		oInternationalFormElements.style.display = 'block';
		oSubmitButton.style.display = 'none';
	}
	else
	{
		oUsaFormElements.style.display = 'none';
		oCanadaFormElements.style.display = 'none';
		oInternationalFormElements.style.display = 'none';
		oSubmitButton.style.display = 'none';
	}
}

function ValidateForm()
{   				
	var oCountryField = document.getElementById('strCountry');
	var oZipCodeField = document.getElementById('intZipCode');
	var oPCLField = document.getElementById('strPostalCodeLeft');
	var oPCRField = document.getElementById('strPostalCodeRight');
	var bReturnValue = true;

	if(oCountryField.options[oCountryField.selectedIndex].value == '')
	{
		alert('You must choose a country.');
		bReturnValue = false;
	}
	else
	{
		if(oCountryField.options[oCountryField.selectedIndex].value == 'USA')
		{
			if(!IsNumeric(oZipCodeField.value) || oZipCodeField.value.length != 5)
			{
				alert('You must specify a correct zip code.');
				bReturnValue = false;
			}
		}
		else
		{
			if(oPCLField.value == '' || oPCRField.value == '')
			{
				alert('You must specify a correct postal code.');
				bReturnValue = false;
			}
		}
	}
	return bReturnValue;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var bReturnValue = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && bReturnValue == true; i++)
	  {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)
		 {
		 bReturnValue = false;
		 }
	  }
   return bReturnValue;
}

function CheckCountrySelection()
{
	var oCountryField = document.getElementById('strCountry');
	if(oCountryField.options[oCountryField.selectedIndex].value != '')
	{
		var oUsaFormElements = document.getElementById('usaFormFields');
		var oCanadaFormElements = document.getElementById('canadaFormFields');
		var oInternationalFormElements = document.getElementById('internationalFormFields');
		var oSubmitButton = document.getElementById('submitButton');
		if(oCountryField.options[oCountryField.selectedIndex].value == 'USA')
		{
			oUsaFormElements.style.display = 'block';
			oCanadaFormElements.style.display = 'none';
			oInternationalFormElements.style.display = 'none';
			oSubmitButton.style.display = 'block';
		}
		else if(oCountryField.options[oCountryField.selectedIndex].value == 'Canada')
		{
			oUsaFormElements.style.display = 'none';
			oCanadaFormElements.style.display = 'block';
			oInternationalFormElements.style.display = 'none';
			oSubmitButton.style.display = 'block';
		}
		else if(oCountryField.options[oCountryField.selectedIndex].value == 'International')
		{
			oUsaFormElements.style.display = 'none';
			oCanadaFormElements.style.display = 'none';
			oInternationalFormElements.style.display = 'block';
			oSubmitButton.style.display = 'none';
		}
		else
		{
			oUsaFormElements.style.display = 'none';
			oCanadaFormElements.style.display = 'none';
			oInternationalFormElements.style.display = 'none';
			oSubmitButton.style.display = 'none';
		}	
	}
}