// Valid canadian postal code
var pcodeexp = /^[g,h,j,k,l,m,n,p,t,v][0-9][a-z][0-9][a-z][0-9]$/i ;
var iens6 = document.all || document.getElementById ? true : false;
var ns4 = document.layers ? true : false;

//Place focus on the first form element
function placeFocus()
{
	if (document.forms.length > 0)
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++)
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
			document.forms[0].elements[i].focus();
			break;
         }
      }
   }
}

function eFlyer_onsubmit() 
{
	if ( document.eFlyer.postalcode_1.value == "" )
	{
		window.alert("Please enter the first three digits of your postal code.");
		document.eFlyer.postalcode_1.focus();
		return false;
	}
	else
	{
        if (!/[A-Z][0-9][A-Z]/i.test(document.eFlyer.postalcode_1.value))
        {
			alert("The postal code entered is invalid. Please enter it in the following format : Z9Z ");
			document.eFlyer.postalcode_1.focus();
			return false;
        }
    }
	if ( document.eFlyer.postalcode_2.value == "" )
	{
		window.alert("Please enter the last three digits of your postal code.");
		document.eFlyer.postalcode_2.focus();
		return false;
	}
	else
	{
        if (!/[0-9][A-Z][0-9]/i.test(document.eFlyer.postalcode_2.value))
        {
			alert("The postal code entered is invalid. Please enter it in the following format : 9Z9 ");
			document.eFlyer.postalcode_2.focus();
			return false;
        }
    } 	
}

function checkLength(curr, next)
{
if (curr.value.length == curr.maxLength && iens6)
	{
	next.focus();
	}
}
//-->