// $Id: init.js,v 1.5 2009/10/28 20:10:24 rchen Exp $
$(document).ready(function(){
	$("#hideCtrl").click(function(){
		$("#sumControllerShow,#sumControllerHide" ).toggle();
		$("#monthlyFeeDetails").toggle();
		$("#equitFeeDetails").toggle();
		
	});
	$("#showCtrl").click(function(){
		$("#sumControllerShow,#sumControllerHide" ).toggle();
		$("#monthlyFeeDetails").toggle();
		$("#equitFeeDetails").toggle();
	});
	
	$("a.boxHeadBgCollapse,a.boxHeadBgExpanded").click(function()
	{
		 
		 if ($(this).parent().is('#itemboxPlan'))
			$(this).next('h3').removeClass('planName');
				
		if ( $(this).is('.boxHeadBgCollapse'))
		{
			
			if( $(this).parent().is(".collapse"+".mcItemBox") )
			{
				$(this).parent().removeClass('collapse mcItemBox');
				$(this).parent().addClass('expanded mcItemBox');
			}
			$(this).parent().find('.PL10').slideDown("slow", function(){
				
				$(this).parent().children('a').addClass('boxHeadBgExpanded');
				$(this).parent().children('a').removeClass('boxHeadBgCollapse');
				
				
			});
			
		}
		else
		{
			 
			$(this).parent().find('.PL10').slideUp("slow", function(){
			  
				if( $(this).parent().is(".expanded"+".mcItemBox") )
				{
					$(this).parent().removeClass('expanded mcItemBox');
					$(this).parent().addClass('collapse mcItemBox');
				}
			 
			 	$(this).parent().children('a').removeClass('boxHeadBgExpanded');
				$(this).parent().children('a').addClass('boxHeadBgCollapse');  
				 
				if ($(this).parent().is('#itemboxPlan'))
					$(this).parent().children('h3').addClass('planName');
				});
			
		}
		 
		return false;
	
	}
	);
	
	$("a.tabCtrl").click(function()
	{
		if ( $(this).parent().parent().parent().is(".ctrlXpand"))
		{
			$(this).parent().parent().parent().removeClass('ctrlXpand');
			$(this).parent().parent().parent().addClass('ctrlCollapse');
		
			$(this).parent().parent().parent().next('tbody').toggle();
			$(this).parent().parent().parent().next('tbody').removeClass('visibilityYes');
			$(this).parent().parent().parent().next('tbody').addClass('visibilityNo');
		}
		else
		{
			$(this).parent().parent().parent().removeClass('ctrlCollapse');
			$(this).parent().parent().parent().addClass('ctrlXpand');
		
			$(this).parent().parent().parent().next('tbody').toggle();
			$(this).parent().parent().parent().next('tbody').removeClass('visibilityNo');
			$(this).parent().parent().parent().next('tbody').addClass('visibilityYes');
		}
		return false;
	}); 
	
	$(".clpsXpdCtrler"+".hideAll").click(function(){
		$(this).toggle();
		$(".clpsXpdCtrler"+".showAll").show();
		
		$('table.accResults tbody:odd').hide();
		$('table.accResults tbody:even').removeClass('ctrlXpand');
		$('table.accResults tbody:even').addClass('ctrlCollapse');
                 
	});
	
	$(".clpsXpdCtrler"+".showAll").click(function(){
		$(this).toggle();
		$(".clpsXpdCtrler"+".hideAll").show();
		
		 
		$('table.accResults tbody:odd').show();

		$('table.accResults tbody:even').removeClass('ctrlCollapse');
		$('table.accResults tbody:even').addClass('ctrlXpand');
		
	});
	
});
  