var logoImage="<img src=\"/ca/img/mm-popup-cibc-logo.gif\" alt=\"CIBC\" width=\"75\" height=\"68\" border=\"0\">";
var topBarImage="<img src=\"/ca/img/acc-sel-page-hdr-en.gif\" alt=\"Choose an Account\"  border=\"0\">";
//var applyNowImage="<img src=\"/ca/img/account-selector/rightside-openaccount-en.gif\" alt=\"Apply online\"  border=\"0\">";

var leftImage="<img src=\"/ca/img/account-selector/acc-sel-image.jpg\" border=\"0\">";
var labelImage="<img src=\"/ca/img/account-selector/acc-sel-page1-hdr-en.gif\"  alt=\"Not sure which CIBC personal bank account is right for you? Let us help.\"  border=\"0\">";
var stepOneImage="<img src=\"/ca/img/account-selector/step-1-en.gif\" alt=\"Step 1\">";
var stepTwoImage="<img src=\"/ca/img/account-selector/step-2-en.gif\" alt=\"Step 2\">";
var stepThirdImage="<img src=\"/ca/img/account-selector/step-3-en.gif\" alt=\"Step 3\">";
		
//var nextStepsArray = new Array();

//nextStepsArray[0] = {img:"<img src=\"/ca/img/account-selector/rightside-openaccount-en.gif\" alt=\"Apply online\" border=\"0\">", url:"javascript:newApplyWindow(' https://www.cibconline.cibc.com/bvtrx01/script-root-tran/authentication/PreSignOn.cibc?locale=en_CA');"};
//nextStepsArray[1] = {img:"<img src=\"/ca/img/account-selector/rightside-accountcallus-en.gif\" alt=\"Give us a call. Call toll free to speak with a Telephone Banking representative for more information and to apply. If you don't already have a CIBC personal bank account, you will need to visit a CIBC branch to complete the process. 1-866-525-8622\" border=\"0\">", url:""};
//nextStepsArray[2] = {img:"<img src=\"/ca/img/account-selector/rightside-visitbranch-en.gif\" alt=\"Visit a branch. A CIBC Advisor can help you get what matters to you. Find a branch\" border=\"0\">", url:"/ca/redirect/locator.html\" onclick=\"newCustStatusWindow('/ca/redirect/locator.html', 745, 545);return false;"};	

var errorMessageArray = new Array();
errorMessageArray['AgeGroup'] = "Please select one category.";		  
errorMessageArray['WhatLookingFor'] = "Please indicate what you are  looking for in a bank account.";
errorMessageArray['MonthlyBalance'] = "Please select the monthly balance you will likely have on this account.";
errorMessageArray['MonthlyTransactions'] = "Limit number of transactions to be between 0 and 99.";
errorMessageArray['MonthlyTransactionsInvalid'] = "Please enter a numeric value.";
errorMessageArray['savingGoals'] = "Please indicate what you are looking for in a savings account.";					  
errorMessageArray['aeroplanMiles'] = "Please indicate if you are looking for a way to earn Aeroplan Miles.";
		  		  		
	  
function moveNextPage()
{
  var currentStep=parent.frames['formFrame'].document.forms[0].stepNum.value;
  
  if(currentStep==1)
  {		   
     if(validatePurposeForm())
	 {
	   parent.frames['submitFrame'].document.forms[0].requestPopulatePageNumber.value=0;		
	   
	   var clientAccountUS = frames['submitFrame'].document.forms[0].purposeLookForUSD.value;
	   var clientAccountSavings = frames['submitFrame'].document.forms[0].purposeLookForSavings.value
	   var clientAccountDay = frames['submitFrame'].document.forms[0].purposeLookForDaytoDay.value
	   
	   var clientStudent = frames['submitFrame'].document.forms[0].purposeApplyStudent.value;
	   var clientAge = frames['submitFrame'].document.forms[0].purposeApply.value;
	
	   if ( clientAccountSavings == true && clientAge != "18younger"){
	   		// 1 for show section. default is hidden
	   		parent.frames['submitFrame'].document.forms[0].savingsOptionsDiv.value=1;
			
			if (clientAccountDay == true){
				parent.frames['submitFrame'].document.forms[0].aeroplanMilesDiv.value=1;  
			}
			
	   		if(clientAccountDay == true && clientAge == "19to59" && clientStudent != true){
				parent.frames['submitFrame'].document.forms[0].monthlyTransactionDiv.value=1;	
			}
			else {
				parent.frames['submitFrame'].document.forms[0].monthlyTransactionDiv.value=0;
			}
						
	   		parent.frames['formFrame'].document.location="account-options.html";					 
	   }	  
	   else if(clientAge == "18younger" || clientAge == "60above" || clientStudent == true)
	   {
	     parent.frames['formFrame'].document.location="account-results.html";	
		 	 
	   }
	   else if (clientAge == "19to59")
	   {
			if (clientAccountDay == true) {
				parent.frames['submitFrame'].document.forms[0].aeroplanMilesDiv.value=1;
				parent.frames['submitFrame'].document.forms[0].savingsOptionsDiv.value=0;
				parent.frames['submitFrame'].document.forms[0].monthlyTransactionDiv.value=1;
				parent.frames['formFrame'].document.location="account-options.html";	
			} else {
			     parent.frames['formFrame'].document.location="account-results.html";	
			}
	 	  }
		}
  	}
 	else if(currentStep==2)
	{
	     if(validateOptionForm())
		 {
			parent.frames['submitFrame'].document.forms[0].requestPopulatePageNumber.value=0;	
			parent.frames['formFrame'].document.location="account-results.html";
		 }
	 }
}						
						 		  		
function startOver()
{
  parent.frames['submitFrame'].document.forms[0].requestPopulatePageNumber.value=0;
  parent.location.href="account-start.html";
}		
		
function populatePageRequest(pageNumber)
{
	  frames['submitFrame'].document.forms[0].requestPopulatePageNumber.value=pageNumber;
		 
	  switch (pageNumber)
	  {		
		case 1:
		{
			parent.frames['submitFrame'].document.forms[0].aeroplanMilesDiv.value=0;
		    parent.frames['submitFrame'].document.forms[0].savingsOptionsDiv.value=0;
			parent.frames['submitFrame'].document.forms[0].monthlyTransactionDiv.value=0;
		 	frames['formFrame'].location.href="account-purpose.html";
		  	break;
		}
		case 2:
		{
		  	frames['formFrame'].location.href="account-options.html";		  
		  	break;
		}				 
	 }	
}				

function backing(thisStep)
{

  var clientAccountUS = frames['submitFrame'].document.forms[0].purposeLookForUSD.value;
  var clientAccountSavings = frames['submitFrame'].document.forms[0].purposeLookForSavings.value
  var clientAccountDay = frames['submitFrame'].document.forms[0].purposeLookForDaytoDay.value
  
  if (frames['submitFrame'].document.forms[0].purposeApplyStudent.value == true) {
  	var clientStudent = frames['submitFrame'].document.forms[0].purposeApplyStudent.value;

  } else {
  	var clientAge = frames['submitFrame'].document.forms[0].purposeApply.value;

  }
  
  var savingsOptionsDiv = frames['submitFrame'].document.forms[0].savingsOptionsDiv.value;
  var monthlyTransactionDiv = frames['submitFrame'].document.forms[0].monthlyTransactionDiv.value;
  
  var thisStep = parseInt(thisStep);
  
  if(thisStep == 2)
  {
    populatePageRequest(1);
  }
  else if(thisStep == 3)
  {
    if(savingsOptionsDiv == true || monthlyTransactionDiv == true)
	{
	  populatePageRequest(2);
	}
	else {
	   populatePageRequest(1);
	}
  } 
}
