// 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;

function RogersCare_onsubmit() 
{	
	if ( document.ContactUs.FName.value == "" )
	{
		window.alert("Please enter your first name.");
		document.ContactUs.FName.focus();
		return false;
	}
	if ( document.ContactUs.LName.value == "" )
	{
		window.alert("Please enter your last name.");
		document.ContactUs.LName.focus();
		return false;
	}
	if ( document.ContactUs.Postal.value == "" )
	{
		window.alert("Please fill in your Postal Code");
		document.ContactUs.Postal.focus();
		return false;
	}
	else
	{
        if (!/[A-Z][0-9][A-Z][0-9][A-Z][0-9]/i.test(document.ContactUs.Postal.value))
        {
			alert("The Postal Code entered is invalid. Please enter it in one of the following formats: M4S2G9 ");
			document.ContactUs.Postal.focus();
			return false;
        }
    } 	
	if (document.ContactUs.Email.value == "" || !(/[\w-_]+@[\w-_]+\.\w{2,}/i.test(document.ContactUs.Email.value)))
	{
		window.alert("Please enter a valid email address!");
		document.ContactUs.Email.focus();
		return false;
	}	
	else
	{
		var atsymbol = parseInt(document.ContactUs.Email.value.indexOf("@"));
		var periodchar = parseInt(document.ContactUs.Email.value.indexOf("."));
		var courriel_len = parseInt(document.ContactUs.Email.value.length);
		if (document.ContactUs.Email.value == "" || atsymbol < 0 || periodchar < 0 || periodchar == (atsymbol + 1) || (courriel_len - 1) == periodchar)  
		{
			alert("Please enter a valid email address");
			document.ContactUs.Email.focus();
			return (false);
		}
	}	
	if ( String(document.ContactUs.areacode.value + document.ContactUs.phone1.value + document.ContactUs.phone2.value ).length != 10 || !(/\d{10}/.test(String(document.ContactUs.areacode.value + document.ContactUs.phone1.value + document.ContactUs.phone2.value))))
	{
		window.alert("Please enter a valid 10 digit day phone number");
		document.ContactUs.areacode.focus();
		return false;
	}
	return true;
}

function RogersCareFR_onsubmit() 
{	
	if ( document.ContactUs.FName.value == "" )
	{
		window.alert("Veuillez entrer votre prénom.");
		document.ContactUs.FName.focus();
		return false;
	}
	if ( document.ContactUs.LName.value == "" )
	{
		window.alert("Veuillez entrer votre nom.");
		document.ContactUs.LName.focus();
		return false;
	}
	if ( document.ContactUs.Postal.value == "" )
	{
		window.alert("Veuillez entrer votre code postal.");
		document.ContactUs.Postal.focus();
		return false;
	}
	else
	{
        if (!/[A-Z][0-9][A-Z][0-9][A-Z][0-9]/i.test(document.ContactUs.Postal.value))
        {
			alert("Le code postal entré est invalide. Veuillez l’entrer selon l’un des formats suivants : M4S2G9 ");
			document.ContactUs.Postal.focus();
			return false;
        }
    } 	
	if (document.ContactUs.Email.value == "" || !(/[\w-_]+@[\w-_]+\.\w{2,}/i.test(document.ContactUs.Email.value)))
	{
		window.alert("Veuillez entrer une adresse de courriel valable.");
		document.ContactUs.Email.focus();
		return false;
	}	
	else
	{
		var atsymbol = parseInt(document.ContactUs.Email.value.indexOf("@"));
		var periodchar = parseInt(document.ContactUs.Email.value.indexOf("."));
		var courriel_len = parseInt(document.ContactUs.Email.value.length);
		if (document.ContactUs.Email.value == "" || atsymbol < 0 || periodchar < 0 || periodchar == (atsymbol + 1) || (courriel_len - 1) == periodchar)  
		{
			alert("Veuillez entrer une adresse de courriel valable.");
			document.ContactUs.Email.focus();
			return (false);
		}
	}	
	if ( String(document.ContactUs.areacode.value + document.ContactUs.phone1.value + document.ContactUs.phone2.value ).length != 10 || !(/\d{10}/.test(String(document.ContactUs.areacode.value + document.ContactUs.phone1.value + document.ContactUs.phone2.value))))
	{
		window.alert("Veuillez entrer les 10 chiffres de votre numéro de téléphone.");
		document.ContactUs.areacode.focus();
		return false;
	}
	return true;
}


function isValid(pattern, str) 
{
    if ( !pattern.test(str) )
       {
            return false;
       }
    else
            return true;
}
	                
function ltrim( cStr )
{
	cStr	=	String(cStr);
	if ( cStr == "0" || cStr == 'null' || cStr.substr(0,3) == '000' )
		return "";
	var oReg = /^(\s+)/;
	return cStr.replace(oReg,'');
}


function rtrim( cStr )
{
	cStr	=	String(cStr);
	var oReg = /(\s+)$/;
	return cStr.replace(oReg,'');
}


function alltrim( cStr )
{
	if (String(cStr) == 'null' )
		return "";
	else
		return ltrim(rtrim(cStr));
}

function strtran( cStr )
{
	cStr	=	String(cStr);
	if ( cStr == '')
		return "";
		
	var oReg = /\s/g;
	return cStr.replace(oReg,'');

}

function checkLength(curr, next)
	{
	if (curr.value.length == curr.maxLength && iens6)
		{
		next.focus();
		}
	}
//-->