// JavaScript Document

$(document).ready(function(){
    
     // Hide text on page load (shows if JS is disabled)
	 $("#showhide").hide();	  
	 
	 
	 // Create link with JS (won't show if JS is disabled)
	 $('<a href="#" class="toggle">Show websites</a>').appendTo("p.external-sites")
							 
	 // Attach event handler 
	 $('a.toggle').click(function() {		
		
		// Change text depending on whether show or hide 
		var text = $("#showhide:visible").size() > 0 ? 'Show websites' : 'Hide websites';	
		
		// show/hide text
		$("#showhide").toggle();
	    
		// write show/hide link to page
		$(this).html(text);	 
		
		// Don't activate link
		return false;
	 });
	 
	 

});


// Toggle function

// Andy Langton's show/hide/mini-accordion - updated 23/11/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='More...';
var hideText='Close';

// initialise the visibility check
var is_visible = false;

// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().after('<p class="trigger"><a href="#" class="toggleLink">'+showText+'</a></p>');

// hide all of the elements with a class of 'toggle'
$('.toggle').hide();

// capture clicks on the toggle links
$('a.toggleLink').click(function() {

// switch visibility
is_visible = !is_visible;

// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
// $('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').toggle();

// return false so any link destination is not followed
return false;

});
});


// Toggle function for STYLE GUIDE

// Andy Langton's show/hide/mini-accordion - updated 23/11/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='Show markup';
var hideText='Hide markup';

// initialise the visibility check
var is_visible = false;

// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.styleguide-toggle').prev().after('<p class="trigger"><a href="#" class="styleguide-toggleLink">'+showText+'</a></p>');

// hide all of the elements with a class of 'toggle'
$('.styleguide-toggle').hide();

// capture clicks on the toggle links
$('a.styleguide-toggleLink').click(function() {

// switch visibility
is_visible = !is_visible;

// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
// $('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.styleguide-toggle').toggle();

// return false so any link destination is not followed
return false;

});
});



/* 
Steven Price
May 2010


*/

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {	
	
    // wrap link around header content
	$('.sitemap-toggle').prev().wrapInner('<a title="toggle" href="#" class="sitemap-toggleLink" />');	
    
    // hide all of the elements with a class of '.sitemap-toggle'
    $('.sitemap-toggle').hide();
    
    // capture clicks on the toggle links
    $('a.sitemap-toggleLink').click(function() {
		
		// toggle hide icon
        $(this).toggleClass('hideIcon');		
        
        // toogle hidden content
		$(this).parent().next('.sitemap-toggle').toggle();
        
        // return false so any link destination is not followed
        return false;	
    
    });
});


// Show hide video transcripts

$(document).ready(function() {	
	
    // wrap link around header content
	//$('.vid-transcript').prev().wrapInner('<a title="toggle" href="#" class="vid-transcript-link" />');	
    
    // hide all of the elements with a class of '.sitemap-toggle'
    $('.vid-transcript').hide();    
	
	$('div.videoWrapper').after('<a title="toggle" href="#" class="vid-transcript-link">Show transcript</a>');
	
    // capture clicks on the toggle links
    $('a.vid-transcript-link').click(function() {	
		
		
		
		// toggle hide icon
        $(this).toggleClass('hideIcon');		
        
        // toogle hidden content
		$(this).next('.vid-transcript').slideToggle();
        
        // return false so any link destination is not followed
        return false;	
    
    });
});

 




// Show / Hide Home Feature


$(document).ready(function() {


// Show contracted arrow icon
$('div.home-feature dl').addClass('contracted');	

// hide all. If user has no JS these will be shown
$('div.home-feature dl dd').hide();
				
				
		// When link is clicked
		$('div.home-feature dt a').click(function(){	
			
			// Toggle between contracted / down arrow icon
			$(this).parent().parent().toggleClass("contracted");	
			
						
			// Toggle individual
			$(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;		
		});					
		

});
