﻿function initMaxMinCourseInfo()
{
    // insert the button collapse/expand button in the header
    $(".my-choices-header").each( function()
    {
        $(this).children("h4").after("<span class=\"arrow down slide-effect \"></span>");
    });
    
    
    // add the click event to the button
    $(".slide-effect").click( function( e )
    {        
        e.preventDefault();     
        
		var parent = $( this ).parent(); // my-choices-header
			
		var parentSibling = $( parent ).next();	// course-information
		
		$( parentSibling ).slideToggle( "slow", ToggleSetup( this ) );

    } );
    
    // auto-hide the necessary pods
	$(".course-information").each( function()
	{
	    if( $( this ).hasClass( "slide-in" ) ) 
	    {
	        $( this ).hide();
	        
	        var header = $( this ).prev();
	    
	        var arrowButton = $( header ).find( ".arrow" );
	        
	        $( arrowButton ).addClass( "down" );
            $( arrowButton ).removeClass( "up" );
	    }	    	        	    	  
		
	} ); 
    
    
    // helper for maximise and minimise
	function ToggleSetup( arrowButton )
	{					
		if ( $( arrowButton ).hasClass( "up" ) )
		{
			// swap css class
			$( arrowButton ).addClass( "down" );
			$( arrowButton ).removeClass( "up" );
			
			//alert("up!");															
		}
		else
		{
			// swap css class
			$( arrowButton ).addClass( "up" );
			$( arrowButton ).removeClass( "down" );			
			
			//alert("down!");									
		}															
	}
    
}