<!-- 
//Hide script contents
//double click protection for form submission
var submitcount = 0;
var formHasChanged = false;
var proceedSubmit = true;

function validateSubmit()	
{
	// called by the onSubmit() event for forms
	// this function checks if we should really submit this form. 
	// - the form submit could have been cancelled (by the setDestination function)
	// - the form has been submitted already and is currently being processed
	// in both cases above we should NOT submit the form
	if ((submitcount == 0) && (proceedSubmit))
	{
		// form has not been submitted previously and is not cancelled.
		submitcount++;
		return true;
	}
	else
	{
		// do not submit the form
		// if proceedSubmit is set to false, the CA did cancel submission by
		// clicking CANCEL in the setDestination function.
		// otherwise, the form has been submitted already. Display a message in that case.
		if (proceedSubmit)
		{
			alert("Your request is being processed. Please select 'OK' to continue.");
		}
		// set proceedSubmit back to true, so that we can try to submit the form again.
		proceedSubmit = true;
		return false;
	}
}

//for sign_in_select onKeyPress event
NS4 = (document.layers) ? true : false;

// Function overloaded with 2 parameters to be used by transactional site
// Currently, lang can only take on the value of "english"

function checkEnter(event)
{ 	
	var code = 0;
	if (NS4){
		code = event.which;
	}else{
		code = event.keyCode;
	}
	if (code==13){
		validateForm2();
	}
}

function validateForm2() 
{
	form = document.temp2;
	var SiteID;
	var value = form.sign_in_select.options[form.sign_in_select.selectedIndex].value ; 
	
	if ( value==2 ) {//pcmc
		if (confirm('\nSelect "OK" to sign out of President'+"'"+'s Choice Financial and go to PC MasterCard.\n\nSelect "Cancel" to return to President'+"'"+'s Choice Financial.')){ 
		openWindow3('https://www.pcmastercard.pcfinancial.ca/rocen/cardapp/contentPG/sign_in_frm.htm', 630, 500);
		document.sidenav.action = "/authentication/signOff.ams?msg=1" ;
		document.sidenav.submit();
		return true;
		} else {
			return false;
		}
	

	}
	if ( value==3 ) {//pc points
		if (confirm('\nSelect "OK" to sign out of President'+"'"+'s Choice Financial and go to PC points.\n\nSelect "Cancel" to return to President'+"'"+'s Choice Financial.')){ 
		document.sidenav.action = "/authentication/signOff.ams?msg=1" ;
		document.sidenav.submit();
		openWindow3('https://www.pcpoints.ca/en/redirect_secure.asp?URL=join_earnPC_frm.asp', 630, 500);
		} else {
			return false;
		}
		
	}
}

function selectLinkChange (form) 
{
	action1 = "/en_ca/login1.jsp";
	action2 = "/en_ca/login2.jsp";
	action3 = "/en_ca/login3.jsp";
	for (var i=0; i < form.sign_in_select.options.length; i++) {
		j = form.sign_in_select.options[i].value;
		if (form.sign_in_select.options[i].selected &&(form.sign_in_select.options[i].value!=0)) {
			document.SignOn.action = eval("action" + j);
		 }
	}
}

function wipeOut()
{
	document.temp.cardNumber.value = "" ;
	document.SignOn.cardNumber.value = "" ;
	document.SignOn.password.value = "" ;
	document.SignOn.reset() ;
	document.temp.reset() ;
}

// removes all occurrences of unwantedChar from the rawString
function removeCharFromString(rawString, unwantedChar) {
	var cleanString = "";
	for (var i=0; i<rawString.length; i++) {
		if (rawString.charAt(i) != unwantedChar) {
			cleanString += rawString.charAt(i);
		}
	}
	return cleanString;
}

// removes leading and trailing whitespace from Strings
function trim(sLine) {
   if( (sLine == "") || (sLine == null) )
     return(sLine);
   else
     return(sLine.replace(/(\s+$|^\s+)/g, ""));
}

function stripBlanks( inputStr )
{
	var outputStr = "";
	for (var i = 0; i < inputStr.length; i++) {
	if (inputStr.charAt(i) != " ") {
		outputStr = outputStr + inputStr.charAt(i);
		}
	}
	return outputStr;
}

function stripDashes( sdinputStr )
{
   var sdoutputStr = "";
   for (var i = 0; i < sdinputStr.length; i++) {
      if (sdinputStr.charAt(i) != "-") {
         sdoutputStr = sdoutputStr + sdinputStr.charAt(i);
      }
   }
   return sdoutputStr;
}

function isEmpty(s) 
{
  // Check whether string s is empty.
  return ((s == null) || (s.length == 0))
}

function isNumber( inputStr )
{
   var c = "?";
   for (var i = 0; i < inputStr.length; i++) {
      var c = inputStr.charAt(i);
      if (c != " ") {
         if ((c < "0") || (c > "9")) {
            return false;
         }
      }
   }
   return true;
}

function isCardNumberValid( cardNumber )
{
   if (isEmpty( cardNumber )) {
      alert( '\nThe bank card number is missing.\n\nSelect "OK" to enter the number.' );
      return false;
   }
   if (!isNumber( cardNumber )) {
      alert( '\nYou have entered "' + cardNumber + '" as the bank card number.\n\nThe bank card number can only contain numbers.\n\nSelect "OK" to re-enter the number.');
      return false;
   }
   return true;
}

function validDate( year, month, day)
{
	var intYear = parseInt(year);
	var userDate = new Date(intYear, month - 1, day);
	if ( day != userDate.getDate() )
		return false;
	var tmpNum = userDate.getYear();
	if ( tmpNum < 1000 )
		tmpNum += 1900;
  	if ( tmpNum != intYear )
  		return false;
  	tmpNum = userDate.getMonth();
  	if ( tmpNum != month - 1 )
  		return false;
	return true;
}





// forward slashes have to be pre-appended and post-appended to the siteName
// before passing it as a parameter
// e.g. siteName='/english/'
var pdfpop;
function openPDFFile(siteName,pdfFile)
{
	pdfpop = window.open( siteName+pdfFile ,"pdfpop","width=700,height=560,toolbar,scrollbars,menubar,resizable,top=100,left=100");
}

//for mkt pages to CIBCMutualFunds pages
function getServlet( servletName )
{
   document.CIBCMutualFunds.action="/ams/servlet/" + servletName;
   document.CIBCMutualFunds.submit();
}

// isCommaFormattedFloat implements the following input edit rules:
// 1. The first character on the left can be '-' but is not mandatory.  That is, negative values are allowed.
// 2. Only allows commas every 3 digits from the right of either another comma, a period
//	or the furthest right of the string.
// 3. Allows only 1 period but is not mandatory.
// 4. All other characters must be numeric.
function isCommaFormattedFloat ( inputStr )
{
   var foundNumeric = false;
   if ((inputStr != null) && (inputStr != ""))
   {
      var minusSignPosition = 0;
	var numberOfPeriods = 0;
      var c = '?';
      for (var i = 0, commaPosition = 1, j = inputStr.length - 1; j >= 0; i++, j--, commaPosition++)
      {
         c = inputStr.charAt( j );
         if ((c == '.') && (numberOfPeriods == 0))
         {
            commaPosition = 0;
		numberOfPeriods++;
            continue;
         }
         if ((commaPosition == 4) && (c == ','))
         {
            commaPosition = 0;
            continue;
         }
         if ((j == minusSignPosition ) && (c == '-'))
         {
            continue;
         }
         if ((c >= '0') && (c <= '9'))
         {
            foundNumeric = true;
         }
         else
         {
            return false;
         }
      }
   }
   return foundNumeric;
}

function isInclusivelyInRange(numberString, numericalLowerLimit, numericalUpperLimit) {
	var number = numberString-0;
	return (number>=numericalLowerLimit && number<=numericalUpperLimit);
}

function isExclusivelyInRange(numberString, numericalLowerLimit, numericalUpperLimit) {
	var number = numberString-0;
	return (number>numericalLowerLimit && number<numericalUpperLimit);
}

// verifies the invalid characters listed in the 'if' statement will not be submitted
function isSpecialChars (inputStr) {
var badString = false;
var i=0;

while (!badString && i<inputStr.length)  {
  var ch = inputStr.charAt(i);
  if (ch=='^' || ch=='\"' || ch=='&' || ch=='>' || ch=='<' )
    badString = true;
  i++;
}

if (badString)
  return true;
else
  return false;
}
//function for setting value in target offer page
function setValue(paramValue){
	
	if(paramValue == 1)	{
		document.TargetOfferDetailForm.outcome.value = "Defer";	
	}
	else if(paramValue == 2){	   
	    document.TargetOfferDetailForm.outcome.value = "Decline";
	}
	else if(paramValue == 3)	{
		document.TargetOfferDetailForm.outcome.value = "Accept";			
	}
	else if(paramValue == 4)	{
		document.TargetOfferDetailForm.outcome.value = "SummaryAccept";			
	}		
	else if(paramValue == 5)	{
		document.TargetOfferDetailForm.outcome.value = "BillAccept";			
	}					    
}
// end hiding script ----->