// Place custom js here
function showdiv(on, off){

document.getElementById(on).style.display = "block";
document.getElementById(off).style.display = "none";

if(document.addnew.canadapost.checked = "true"){
document.addnew.address.id="address";
document.addnew.city.id="city";
document.addnew.province.id="province";
document.addnew.country.id="country";
}

}


function postal(chk){
if(chk.checked == 1){
document.addnew.address.id="address";
document.addnew.city.id="city";
document.addnew.province.id="province";
document.addnew.country.id="country";
document.addnew.phone.id="phone";
document.editform.address.id="address";
document.editform.city.id="city";
document.editform.province.id="province";
document.editform.country.id="country";

}
else if(chk.checked == 0){

document.addnew.address.id="no";
document.addnew.city.id="no";
document.addnew.province.id="no";
document.addnew.country.id="no";
document.addnew.phone.id="no";
document.editform.address.id="no";
document.editform.city.id="no";
document.editform.province.id="no";
document.editform.country.id="no";
}

}
function formatpostal(x)
{	

		if (x.value != "")
		{
			var postalcodevalue = x.value
			
			postalcodevalue = postalcodevalue.replace(" ","");
			
			x.value = postalcodevalue;
			
			if (postalcodevalue.length > 6 || postalcodevalue.length < 6)
			{
					alert("Invalid Canadian postal code format. Please Correct.");
					x.focus();
					return;
			}
			else
			{
				postalcodevalue = postalcodevalue.substr(0,3) + " " + postalcodevalue.substr(3,3);
				x.value = postalcodevalue;
	
			}
		}

}