	<!--
	
		// 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 = ['savingscurrency','savingsbalance','chequingpurpose','chequingnonprofitvolume','chequingprofitvolume','chequingtype','chequingfullservevolume','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(); } );
			$("#savingscurrencynext").click ( function(){ SavingsCurrencySelected(); } );
			$("#savingsbalancenext").click ( function(){ SavingsBalanceSelected(); } );
			$("#chequingpurposenext").click ( function(){ ChequingPurposeSelected(); } );
			$("#chequingnonprofitvolumenext").click ( function(){ ChequingNonProfitVolumeSelected(); } );
			$("#chequingprofitvolumenext").click ( function(){ ChequingProfitVolumeSelected(); } );
			$("#chequingtypenext").click ( function(){ ChequingTypeSelected(); } );
			$("#chequingfullservevolumenext").click ( function(){ ChequingFullServeVolumeSelected(); } );
		});
		
		
		
		/*
		=========================================================================
			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 ("#chequingpurpose", "show");
			}
			else if ($("select[@name='accounttype']").val() == 1)
			{
				ShowHideDiv ("#savingscurrency", "show");
			}
			else
			{
				alert ("Please select an account type");
			}
			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 (bussavings);
			else
			{
				// display balance option
				ShowHideDiv ("#savingsbalance", "show");
			}
		}
		
		// 0: >5000, 1: <5000
		function SavingsBalanceSelected()
		{
			// if 5000 and less (ie. value=0), show businessavings table
			if ($("select[@name='savingsbalance']").val() == 1)
				DisplayTable (businesssavings);
			else
				DisplayTable (premiumsavings);
			return true;
		}		
		
		// 0: For profit, 1: Non profit
		function ChequingPurposeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingnonprofitvolume", "hide");
			ShowHideDiv ("#chequingprofitvolume", "hide");
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#chequingfullservevolume", "hide");
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingpurpose']").val() == 0)
				ShowHideDiv ("#chequingprofitvolume", "show");
			else
				ShowHideDiv ("#chequingnonprofitvolume", "show");
				
			return true;
		}

		// 0: 0-26, 1: 27-33,  2: 34-55, 3: 56-100, 4: Extensive (100+)
		function ChequingNonProfitVolumeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingprofitvolume", "hide");
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#chequingfullservevolume", "hide");
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingnonprofitvolume']").val() == 0)
				DisplayTable (communityorganizations);
			else if ($("select[@name='chequingnonprofitvolume']").val() == 1)
				DisplayTable (bronze);
			else if ($("select[@name='chequingnonprofitvolume']").val() == 2)
				DisplayTable (silver);
			else if ($("select[@name='chequingnonprofitvolume']").val() == 3)
				DisplayTable (gold);
			else
				DisplayTable (custom);
				
			return true;
		}
		
		// 0: 0-17, 1: 18-33, 2: 34-55, 3: 56-100, 4: Extensive (100+)
		function ChequingProfitVolumeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingnonprofitvolume", "hide");
			ShowHideDiv ("#chequingtype", "hide");
			ShowHideDiv ("#chequingfullservevolume", "hide");
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingprofitvolume']").val() == 0)
				ShowHideDiv ("#chequingtype", "show");
			else if ($("select[@name='chequingprofitvolume']").val() == 1)
				DisplayTable (bronze);
			else if ($("select[@name='chequingprofitvolume']").val() == 2)
				DisplayTable (silver);
			else if ($("select[@name='chequingprofitvolume']").val() == 3)
				DisplayTable (gold);
			else
				DisplayTable (custom);
				
			return true;
		}

		// 0: self serve, 1: full serve
		function ChequingTypeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#chequingfullservevolume", "hide");
			ShowHideDiv ("#final", "hide");			
			
			if ($("select[@name='chequingtype']").val() == 0)
				DisplayTable (businesschequing);				
			else
				ShowHideDiv ("#chequingfullservevolume", "show");
				
			return true;
		}
		
		// 0: 0-7, 1: 8-17
		function ChequingFullServeVolumeSelected()
		{
			// hide the next fields
			ShowHideDiv ("#final", "hide");
			
			if ($("select[@name='chequingfullservevolume']").val() == 0)
				DisplayTable (businesschequing);
			else
				DisplayTable (bronze);
				
			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");			
		}
		
		
		
		
		
		
	//-->
