var $annualRates =  '#onlineAnnual,' +
					'#onlineAnnualPrevious,' +
					'#easyAnnual,' +
					'#easyAnnualPrevious,' +
					'#noticeAnnual,' +
					'#noticeAnnualPrevious,' +
					'#taxfreeAnnual,' +
					'#taxfreeAnnualPrevious,' +
					'#childrensAnnual,' +
					'#childrensAnnualPrevious';
					
var $monthlyRates = '#onlineMonth,' +
					'#onlineMonthPrevious,' +
					'#easyMonth,' +
					'#easyMonthPrevious,' +
					'#noticeMonth,' +
					'#noticeMonthPrevious,' +
					'#taxfreeMonth,' +
					'#taxfreeMonthPrevious,' +
					'#childrensMonth,' +
					'#childrensMonthPrevious';					
					
var accountViews =  '#view1,' + 
					'#view2,' + 
					'#view3,' + 
					'#view4,' + 
					'#view5';
					
var accountViewsPrevious =  '#view1Previous,' +
							'#view2Previous,' + 
							'#view3Previous,' + 
							'#view4Previous,' + 
							'#view5Previous';		
							
var getcurrentPreviousDropdownValue = '#currentPreviousSelector';
var getcurrentPreviousDropdownValueSelected = '#currentPreviousSelector :selected';
var getAccountTypesDropdownValue = '#accountTypeSelector';					
var getAccountTypesDropdownValueSelected = '#accountTypeSelector :selected';
var getRatesDropdownValue = '#annualMonthlyRatesSelector';
var getRatesDropdownValueSelected = '#annualMonthlyRatesSelector :selected';			
var accountClosed = 'interest_rates_closed.html';


$(document).ready(function () {	
							
	$('#currentPreviousList')[0].reset();
	$('#accountTypesList')[0].reset();
	$('#annualMonthlyRatesList')[0].reset();
	
	
	// current / previous rates show / hide
	$('#currentRatesView').show();
	$('#previousRatesView').hide();
	
							
	// page load show / hide						
	$($annualRates).show();
	$($monthlyRates).hide();
							
							
	//find all form with class jqtransform and apply the plugin						
	$("form.jqtransform").jqTransform();	
	
	
});

$(function(){			
	
	$('#currentPreviousList ul li a').click(function(){	
		
		if (($(getcurrentPreviousDropdownValue).val() == "current") && ($(getAccountTypesDropdownValueSelected).val() != "viewAll")) {	
			$(accountViews).hide();	
			$(accountViewsPrevious).hide();	
			$('#previousRatesView').hide();
			$('#currentRatesView').show();			
			$("#" + $(getAccountTypesDropdownValueSelected).val()).show();
		}	
		
		else if (($(getcurrentPreviousDropdownValue).val() == "previous") && ($(getAccountTypesDropdownValueSelected).val() != "viewAll")) {
			$(accountViews).hide();	
			$(accountViewsPrevious).hide();	
			$('#currentRatesView').hide();	
			$('#previousRatesView').show();
			$("#" + $(getAccountTypesDropdownValueSelected).val() + "Previous").show();	
		}		
		
		else if (($(getcurrentPreviousDropdownValue).val() == "current") && ($(getAccountTypesDropdownValueSelected).val() == "viewAll")) {
			$(accountViewsPrevious).hide();
			$(accountViews).show();
			$('#previousRatesView').hide();
			$('#currentRatesView').show();
		}	
		
		else if (($(getcurrentPreviousDropdownValue).val() == "previous") && ($(getAccountTypesDropdownValueSelected).val() == "viewAll")) {	
			$(accountViews).hide();
			$(accountViewsPrevious).show();
			$('#currentRatesView').hide();
			$('#previousRatesView').show();	
		}
		
		else if ($(getcurrentPreviousDropdownValue).val() == "closed") {			
			document.location = accountClosed;
		}
		
		ie6Fix();
		
	}); 
	
		   
	$('#accountTypesList ul li a').click(function(){												  
		
		if (($(getcurrentPreviousDropdownValueSelected).val() == "current") && ($(getAccountTypesDropdownValue).val() != "viewAll")) {
			$(accountViews).hide();	
			$(accountViewsPrevious).hide();	
			$("#" + $(getAccountTypesDropdownValue).val()).show();
		}
		
		else if (($(getcurrentPreviousDropdownValueSelected).val() == "previous") && ($(getAccountTypesDropdownValue).val() != "viewAll")) {
			$(accountViews).hide();	
			$(accountViewsPrevious).hide();	
			$("#" + $(getAccountTypesDropdownValue).val() + "Previous").show();
		}
		
		else if (($(getcurrentPreviousDropdownValueSelected).val() == "current") && ($(getAccountTypesDropdownValue).val() == "viewAll")) {
			$(accountViews).show();
			$(accountViewsPrevious).hide();		
		}
		
		else if (($(getcurrentPreviousDropdownValueSelected).val() == "previous") && ($(getAccountTypesDropdownValue).val() == "viewAll")) {
			$(accountViews).hide();
			$(accountViewsPrevious).show();
		}
		
		ie6Fix();
		
	});
	
	
	$('#annualMonthlyRatesList ul li a').click(function(){
														
		if($(getRatesDropdownValue).val() == "monthly") {
			$($annualRates).hide();	
			$($monthlyRates).show();	
			
			// IE6 FIX
			$($monthlyRates).css('visibility','visible');
		}
		else {
			$($monthlyRates).hide();	
			$($annualRates).show();	
			
			// IE6 FIX
			$($annualRates).css('visibility','visible');
		}	
		
	});
	
	
	function ie6Fix() {
		
		// IE6 FIX
		if ($(getRatesDropdownValueSelected).val() == "annual") {
			$($monthlyRates).css('visibility','hidden');
			$($annualRates).css('visibility','visible');
		}
		else if ($(getRatesDropdownValueSelected).val() == "monthly") {
			$($annualRates).css('visibility','hidden');
			$($monthlyRates).css('visibility','visible');
		}	
		
	}
	
	
});

