// 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;
var preloadFlag = false;
function preloadImages()
{
if (document.images)
{
	pre_btn_order_on = newImage('../images/btn_order-on.gif');
	pre_btn_ctgiftcards_on = newImage('../images/btn_ctgiftcards-on.gif');
	pre_btn_enter_on = newImage('../images/btn_enter-on.gif');
	preloadFlag = true;
}
}
// Code for the popup windows
var popup;
function launchwindow(winURL,winName,w,h,winSpecs)
{
popup = window.open(winURL,winName,
		"Width=" + w + ",Height=" + h + "," + winSpecs);
popup.focus();
}
//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 UserInfo_onsubmit() 
{
 	//Verify the checkout form before submitting
	if (document.testOnlineFormName.PIID_631_0.value.length == "")
	{
		window.alert("Please enter your first name.");
		document.testOnlineFormName.PIID_631_0.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_632_0.value.length == "")
	{
		window.alert("Please enter your last name.");
		document.testOnlineFormName.PIID_632_0.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_634_0.value.length == "")
	{
		window.alert("Please enter your email address.");
		document.testOnlineFormName.PIID_634_0.focus();
		return false;
	}	
	if (document.testOnlineFormName.PIID_635_1.value.length == "")
	{
		window.alert("Please enter your friend's first name.");
		document.testOnlineFormName.PIID_635_1.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_636_1.value.length == "")
	{
		window.alert("Please enter your friend's last name.");
		document.testOnlineFormName.PIID_636_1.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_637_1.value.length == "")
	{
		window.alert("Please enter a valid email address for your friend.");
		document.testOnlineFormName.PIID_637_1.focus();
		return false;
	}
}
function UserInfo_fr_onsubmit() 
{
 	//Verify the checkout form before submitting
	if (document.testOnlineFormName.PIID_631_0.value.length == "")
	{
		window.alert("Veuillez entrer votre prénom.");
		document.testOnlineFormName.PIID_631_0.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_632_0.value.length == "")
	{
		window.alert("Veuillez entrer votre nom.");
		document.testOnlineFormName.PIID_632_0.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_634_0.value.length == "")
	{
		window.alert("Veuillez entrer une adresse courriel valide.");
		document.testOnlineFormName.PIID_634_0.focus();
		return false;
	}	
	if (document.testOnlineFormName.PIID_635_1.value.length == "")
	{
		window.alert("Entrez le prénom de votre ami(e).");
		document.testOnlineFormName.PIID_635_1.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_636_1.value.length == "")
	{
		window.alert("Entrez le nom de votre ami(e).");
		document.testOnlineFormName.PIID_636_1.focus();
		return false;
	}
	if (document.testOnlineFormName.PIID_637_1.value.length == "")
	{
		window.alert("Entrez une adresse courriel valide de votre ami(e).");
		document.testOnlineFormName.PIID_637_1.focus();
		return false;
	}
}
function isValid(pattern, str) 
{
    if ( !pattern.test(str) )
       {
            return false;
       }
    else
            return true;
}
function checkLength(curr, next)
	{
	if (curr.value.length == curr.maxLength && iens6)
		{
		next.focus();
		}
	}	                
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();
	}
}
//-->