// Show / Hide Course descriptions

/*
Name: Steven Price
Description: 

(1) Show / hide course descriptions for qual pages
(2) Show / hide course fees for course pages

*/

$(document).ready(function() {
 
  
// (1) Show / hide course descriptions for qual pages


// Show contracted arrow icon
$('table.show-hide dl').addClass('contracted');	

// hide all course descriptions. If user has no JS these will be shown
$('table.show-hide dl dd').hide();
				
			
		// Add Show all / Hide all links. If user has no JS these will NOT be shown
		$('div#courses h2:first-child').after('<ul class="toggle-all"><li><a href="#course-list" id="show-all">Show all descriptions</a></li><li class="contracted"><a href="#course-list" id="hide-all">Hide all descriptions</a></li></ul>'			   
		);	
				
		// When course link is clicked
		$('table.show-hide dt a').click(function(){	
			
			// Toggle between contracted / down arrow icon
			$(this).parent().parent().toggleClass("contracted");	
			
			// Toggle between highlight on tr
			$(this).parent().parent().parent().parent().toggleClass("highlight");
			
			// Toggle individual course descriptions 
			$(this).parent().siblings().slideToggle('fast');
			
			// add contextual info to see full description
			var description = $(this).text();
				
		    $(this).parent().siblings().find('a').attr({ 
                   title: description                
            });
			
			
			// Cancel link 
			return false;		
		});			
		
		
		// Show all course descriptions 
		$('ul.toggle-all li a#show-all').click(function(){	
			
			// Show contracted arrow icon
			$("table.show-hide dl").removeClass("contracted");	
			
			$("table.show-hide tr").addClass("highlight");
			
			$('table.show-hide dl dd').slideDown('fast');
			
			// Cancel link 
			return false;		
		});	
		
		// Hide all course descriptions 		
		$('ul.toggle-all li a#hide-all').click(function(){	
			
			// Show down arrow icon
			$("table.show-hide dl").addClass("contracted");
			
			$("table.show-hide tr").removeClass("highlight");
			
			$('table.show-hide dl dd').slideUp('fast');
			
			// Cancel link 
			return false;		
		});
		

// (3) Show / hide course contextual help

// hide all contextual help. If user has no JS these will be shown
$('form#financial p.help-text').hide();


// Add help. If user has no JS these will NOT be shown
$('form#financial legend.help').append('<a href="#" class="help-link"><img src="gui/help.gif" alt="help" class="help-img" /></a>');	


// When help icon is clicked
		$('form#financial a.help-link').click(function(){	
			
			// Toggle between contracted / down arrow icon
			//$(this).parent().parent().toggleClass("contracted");	
			
			// Toggle between highlight on tr
			//$(this).parent().parent().parent().parent().toggleClass("highlight");
			
			// Toggle individual course descriptions 
			$(this).parent().siblings('p.help-text').slideToggle('fast');
			
			// add contextual info to see full description
			//var description = $(this).text();
				
		    //$(this).parent().siblings().find('a').attr({ 
                  // title: description                
            //});
			
			
			// Cancel link 
			return false;		
		});



// (3) Show / hide bookmarklet

// hide all bookmarklets. If user has no JS these will be shown
$('div.bookmarkers').hide();

$('p.bookmarklet').click(function(){			
			$('div.bookmarkers').toggle();
			return false;		
});


// Added by rho24 28/07/09 - gives print functionality to print this page link.
$('#print-page').click(function() {
    window.print();
    return false;
    });
    
$('.no-js-hide').removeClass('no-js-hide');

});



