function countryChkFunc()
{
	document.signupForm.postalcode.value="";
	if (document.signupForm.country.value!="United States") document.signupForm.province.value="Other";
	if (document.signupForm.country.value=="Canada") document.signupForm.province.value="ON";
	if (document.signupForm.country.value=="United States") document.signupForm.province.value="CA";
}

function provinceChkFunc()
{
	var Prov;
	document.signupForm.postalcode.value="";
	Prov=document.signupForm.province.value;

	if (document.signupForm.country.value=="Canada" && Prov=="Other") {
		document.signupForm.province.value="ON";
		return;
	}
	else if (document.signupForm.country.value=="United States" && Prov=="Other") {
		document.signupForm.province.value="CA";
		return;
	}

	if (Prov=="AB" || Prov=="BC" || Prov=="MB" || Prov=="NB" || Prov=="NF" || Prov=="NS" || Prov=="NT" || Prov=="ON" || Prov=="PE" || Prov=="QC" || Prov=="SK" || Prov=="YT" || Prov=="NU") {
		document.signupForm.country.value="Canada";
	}
	else if (Prov=="Other" || Prov=="") return;

	else document.signupForm.country.value="United States";
}

function postalcodeChkFunc()
{

	var word_temp=document.signupForm.postalcode.value;
	var length=word_temp.length;
	var char_length=word_temp.length-1;
	var char_ascii=word_temp.charCodeAt(char_length);

	var canada_temp;

	//If the United States
	if (document.signupForm.country.value=="United States")
	{
		//Check each letter typed in
		if (char_ascii<48 || char_ascii>57) {
			document.signupForm.postalcode.value=word_temp.substring(0,length-1);
			return;
		}
		document.signupForm.postalcode.value=word_temp.substring(0,5);
	}

	//If Canada
	if (document.signupForm.country.value=="Canada")
	{
		//Letter Check
		if ((length==1 || length==3 || length==5) && ((char_ascii>=65 && char_ascii<=90) || (char_ascii>=97 && char_ascii<=122))) {
			word_temp=word_temp.toUpperCase();
			document.signupForm.postalcode.value=word_temp.substring(0,6);
			return;
		}
		if (length==1 || length==3 || length==5) {
			document.signupForm.postalcode.value=word_temp.substring(0,length-1);
			return;
		}
		if ((length==2 || length==4 || length==6) && (char_ascii>=48 && char_ascii<=57))
		{
			word_temp=word_temp.toUpperCase();
			document.signupForm.postalcode.value=word_temp.substring(0,6);
			return;
		}
		if (length==2 || length==4 || length==6) {
			document.signupForm.postalcode.value=word_temp.substring(0,length-1);
			return;
		}
		word_temp=word_temp.toUpperCase();
		document.signupForm.postalcode.value=word_temp.substring(0,6);
	}
}
