	<!--
	
		// these are the ids given to div tags containing <select>s
		// we may want to display:none them or otherwise based on the div's ids
		var divs = ['savingsage','savingscurrency','savingsbalance','chequingage','chequingvolume','chequingbalance','chequingtype','final'];		
	
		// enable jQuery
		$(document).ready(function() {
								   
			// transaction type popup goes here
			$("a[@name='transactionTypeHelp']").cluetip({splitTitle: '|'});
		
			// connect StartOver() function to link named "start over"
			$("a[@name='startover']").click ( function(){ StartOver(); } );
			$("#accounttypenext").click ( function(){ AccountTypeSelected(); } );
			$("#savingsagenext").click ( function(){ SavingsAgeSelected(); } );
			$("#savingscurrencynext").click ( function(){ SavingsCurrencySelected(); } );
			$("#savingsbalancenext").click ( function(){ SavingsBalanceSelected(); } );
			$("#chequingagenext").click ( function(){ ChequingAgeSelected(); } );
			$("#chequingvolumenext").click ( function(){ ChequingVolumeSelected(); } );
			$("#chequingbalancenext").click ( function(){ ChequingBalanceSelected(); } );
			$("#chequingtypenext").click ( function(){ ChequingTypeSelected(); } );
		});
		
		
		
		/*
		=========================================================================
			Function:		StartOver
			Purpose:		Hide all divs other than 'type of account'
		=========================================================================
		*/
		function StartOver()
		{
			for (var i=0; i < divs.length; i++) 
			{
				var idTag = "#" + divs[i];
				ShowHideDiv (idTag, "hide");
			}
			return true;
		}
		
		
		
		/*
		=========================================================================
			Function:		HideDivs
			Purpose:		Hides all div tags depending on what's asked
			In:				character
			Notes:			If parameter = "s", hides all SAVINGS div tags
							If parameter = "c", hides all CHEQUING div tags
							If parameter = "f", hides submit button
		=========================================================================
		*/
		function HideDivs (startsWith)
		{
			for (var i=0; i < divs.length; i++) 
			{
				if (divs[i].substring(0,1) == startsWith)
				{
					// create the ID tag
					// apply the class 'quiet' if it does not already have that 
					// class assigned, thereby hiding those div tags
					var idTag = "#" + divs[i];
					ShowHideDiv (idTag, "hide");
				}
			}
			return true;
		}
		
		
		
		/*
		=========================================================================
			Function:		ShowHideDiv
			Purpose:		Shows or hides a given div tag based on its id
			In:				tag of the id, string "show" or "hide"
		=========================================================================
		*/
		function ShowHideDiv (idTag, showHide)
		{
			if (showHide == "show")
			{
				if ($(idTag).hasClass("quiet") ) $(idTag).removeClass("quiet");
			}
			else
			{
				if (! $(idTag).hasClass("quiet") ) $(idTag).addClass("quiet");
			}
		}
		
		
		
		
		/*
		=========================================================================
			Function:		various functions
			Purpose:		Displays appropriate divs upon selection
		=========================================================================
		*/
		function AccountTypeSelected()
		{
			// make sure only display age question is displayed
			StartOver();
			
			// depending on the selection (0-chequing, 1-savings, -1-none)
			// display more divs
			if ($("select[@name='accounttype']").val() == 0)
			{
				ShowHideDiv ("#chequingage", "show");
			}
			else if ($("select[@name='accounttype']").val() == 1)
			{
				ShowHideDiv ("#savingsage", "show");
			}
			else
			{
				alert ("Please select an account type");
			}
			return true;
		}
		
		// 0: 17yrs or less, 1: 18 or above
		function SavingsAgeSelected()
		{	
			// hide the next fields
			ShowHideDiv ("#savingscurrency", "hide");
			ShowHideDiv ("#savingsbalance", "hide");
			ShowHideDiv ("#final", "hide");
			
			// if age is 17 and under (ie. value=0), display the table
			// otherwise display the next option
			if ($("select[@name='savingsage']").val() == 0)
				DisplayTable (youthsavings);
			else
			{
				// display currency option
				ShowHideDiv ("#savingscurrency", "show");
			}
			return true;
		}
		
		// 0: Canadian Dollars, 1: USD
		function SavingsCurrencySelected()
		{
			// hide the next fields
			ShowHideDiv ("#savingsbalance", "hide");
			ShowHideDiv ("#final", "hide");
		
			// if US Dollars (ie. value=1), show ussavings table
			if ($("select[@name='savingscurrency']").val() == 1)
				DisplayTable (ussavings);
			else
			{
				// display balance option
				ShowHideDiv ("#savingsbalance", "show");
			}
		}
		
		// 0: <5000, 1>5000
		function SavingsBalanceSelected()
		{
			// if 5000 and less (ie. value=0), show ussavings table
			if ($("select[@name='savingsbalance']").val() == 1)
				DisplayTable (premiumsavings);
			else
				DisplayTable (dailysavings);
			return true;
		}		
		
		
		// 0: 12 or under, 1: 13-17, 2: 18-25, 3: 26-59, 4: 60 or above
		function ChequingAgeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingvolume", "hide");
			ShowHideDiv ("#chequingbalance", "hide");
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingage']").val() == 0)
				DisplayTable (none);
			else if ($("select[@name='chequingage']").val() == 1)
				DisplayTable (youthchequing);
			else if ($("select[@name='chequingage']").val() == 2)
				DisplayTable (nextsteps);
			else if ($("select[@name='chequingage']").val() == 3)			
			{
				// display currency option
				ShowHideDiv ("#chequingvolume", "show");
			}
			else
				DisplayTable (advantage);
				
			return true;
		}

		// 0: up to 11, 1: 12-15, 2: 16-32, 3: 33 or more
		function ChequingVolumeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingbalance", "hide");
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#final", "hide");			
			
			if ($("select[@name='chequingvolume']").val() == 0)
				ShowHideDiv ("#chequingbalance", "show");
			else if ($("select[@name='chequingvolume']").val() == 1)
				ShowHideDiv ("#chequingbalance", "show");
			else if ($("select[@name='chequingvolume']").val() == 2)
				DisplayTable (basic_2);
			else
			{
				// display currency option
				ShowHideDiv ("#chequingtype", "show");
			}
				
			return true;
		}
		
		// 0: $1000 or more, 1: less than $1000 - balance
		// 0: up to 11, 1: 12-15 - volume
		function ChequingBalanceSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#final", "hide");
			
			// here goes 1000 or more [ELSE: less than 1000]
			if ($("select[@name='chequingbalance']").val() == 0)
			{				
				
				if ($("select[@name='chequingvolume']").val() == 0)
					DisplayTable (personal1_0);				// $1000 or more AND up to 11
				else
					DisplayTable (personal1_1);		// $1000 or more AND 12-15
			}
			else			
			{				
				if ($("select[@name='chequingvolume']").val() == 0)
					DisplayTable (pca);		// less than $1000 AND up to 11
				else
					DisplayTable (basic);			// less than $1000 AND 12-15
			}
				
			return true;
		}
		
		// 0: full serve, 1: self serve
		function ChequingTypeSelected()
		{
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingtype']").val() == 0)
				DisplayTable (value);
			else if ($("select[@name='chequingtype']").val() == 1)
				DisplayTable (eserve);
				
			return true;
		}
		
		
		/*
		=========================================================================
			Function:		DisplayResults
			Purpose:		Performs data display; heart of the application
		=========================================================================
		*/
		function DisplayResults()
		{
			alert ("Displaying results");			
			AccountTypeSelected();
							
			// always return false!
			return false;
		}		
		
		
		function DisplayTable (tableName)
		{			
			$("#final").html (tableName);
			$("a[@name='registerHelp']").cluetip({splitTitle: '|'});
			ShowHideDiv ("#final", "show");			
		}
		
		
		
		
		
		
	//-->
