// JavaScript Document

var FirstColumn;
var SecondColumn;
var ThirdColumn;
var allFirstColumn;
var allSecondColumn;
var allThirdColumn;

$(function() {

    allSecondColumn = $('#All_Programs ul.programs_column.middle').html();
      allFirstColumn = $('#All_Programs ul.programs_column.first').html();
       allThirdColumn   = $('#All_Programs ul.programs_column.last').html();

	$('#All_Programs a#allmasters').click(function(){	   
		$('#All_Programs ul.programs_column.first').html(allFirstColumn);
		$('.degree-program').hide();
		$('.masters').show();
		$(this).blur();		
		
	    $(".highlight").removeClass("highlight");
		});	 

	
	 $('#All_Programs a#allbachelors').click(function() {        
		$('#All_Programs ul.programs_column.first').html(allFirstColumn);
		$('.degree-program').hide();
		$('.bachelor').show();
		$(this).blur();        
	    $(".highlight").removeClass("highlight");
		});		
	
		
	 $('#All_Programs a#allassociates').click(function() {

		$('#All_Programs ul.programs_column.first').html(allThirdColumn);
		$('.degree-program').hide();
		$('#All_Programs  ul.programs_column.first .associate').show();
		
		$(this).blur();	
		
        $(".highlight").removeClass("highlight");
        
		});		
	
    
     $('#All_Programs a#allcertificates').click(function() {
     
		$('#All_Programs ul.programs_column.first').html(allThirdColumn);
		$('.degree-program').hide();
		$('#All_Programs  ul.programs_column.first .certificate').show();		
		$(this).blur();
		$(".highlight").removeClass("highlight");      

		});
		
	 $('#All_Programs a#alllawdegree').click(function() {
     
		$('#All_Programs ul.programs_column.first').html(allThirdColumn);
		$('.degree-program').hide();
		$('#All_Programs ul.programs_column.first .lawdegree').show();		
		$(this).blur();	
		$(".highlight").removeClass("highlight");	
		});


		
	 $('#All_Programs a#allmasters').mouseover(function(){ tdMouseOver(this); });
    
    $('#All_Programs a#allmasters').mouseout(function() { tdMouseout(this); });
  
    $('#All_Programs a#allbachelors').mouseover(function(){ tdMouseOver(this); });
    
    $('#All_Programs a#allbachelors').mouseout(function(){ tdMouseout(this); });

   $('#All_Programs a#allassociates').mouseover(function(){ tdMouseOver(this); });
    
    $('#All_Programs a#allassociates').mouseout(function(){ tdMouseout(this); });
    
    $('#All_Programs a#allcertificates').mouseover(function(){ tdMouseOver(this); });
    
     $('#All_Programs a#allcertificates').mouseout(function(){ tdMouseout(this); });
     $('#All_Programs a#alllawdegree').mouseout(function(){	
        tdMouseout(this); 
    });
    $('#All_Programs a#alllawdegree').mouseover(function(){	
        tdMouseOver(this); 
    });
$(function() {
	$('ul#kuhs_programs_nav li').each(function(){
		
		var numClasses = $('#kuhs_programs .' + $(this).attr('id') + ' .program_class').length;
		var reduction = numClasses * 24;
		var newHeight = 419 - reduction;
		var currentId = $(this).attr('id');
		$('#kuhs_programs .' + currentId).accordion( { header: '.program_class' } );
		$('#kuhs_programs .' + currentId).find('.class').css('height', newHeight + 'px'); // set the height available for the class description div
		
		// tabs
		$(this).click(function(){
			var id = $('kuhs_programs_nav a.active').attr('id');
			$('#kuhs_programs_nav li a').removeClass('active');
			$(this).find('a').addClass('active');
			$('#kuhs_programs div.active').removeClass('active');
			$('#kuhs_programs .' + currentId).addClass('active');
			$('#kuhs_programs .' + currentId).find('.class:first').addClass('active');
			$(this).blur();
		});
		
		// accordion panes acitve class
		$('#kuhs_programs .' + currentId + ' .program_class').each(function(){
			$(this).attr('accordionId', currentId);
			$(this).click( function(){
				var $elems = $('#kuhs_programs .' + $(this).attr('accordionId') + ' .program_class');
				var len = $elems.length;
				for(i=0; i < len; i++)
				{
					var id = $($elems[i]).attr("id");
					id = '.' + id;
					var divElem = $($elems[i]).parent().find(id);
					$(divElem).css("display","none");
				}
				$('#kuhs_programs .' + $(this).attr('accordionId') + ' .program_class').removeClass('active');
				$(this).addClass('active');
				var div = '.' + $(this).attr('id');
				$(div).css('display','block');
			});
		});
	});
});
	
});