// text replacement
Cufon.replace('#slideshowText', {
	fontStyle: 'italic',
	fontWeight: '900',
	fontStretch: 'expanded',
	fontSize: '20px',
	textShadow: '#000 1px 1px'
});

Cufon.replace('#milestone strong', {
	fontStyle: 'italic',
	fontWeight: '900',
	fontStretch: 'expanded',
	fontSize: '20px'
});

Cufon.replace('.shadow', {
	fontStyle: 'italic',
	fontWeight: '900',
	fontStretch: 'expanded',
	fontSize: '18px',
	textShadow: '#444 2px 2px'
});

	Cufon.replace('.cufon', {fontFamily: 'Helvetica Neue LT Std', hover: true});
	Cufon.replace('#topNav li a', { hover: true, fontFamily: 'Helvetica Neue LT Std' });
	Cufon.replace('#subBanner', {fontFamily: 'Helvetica Neue LT Std', textShadow: '#000 1px 1px'});


$(function() {
		   
// randomise left hand nuggets
	$('ul#nuggets').shuffle();


// adds classes to external links
		$('a[href^="http://"]')
		  .attr("title", "Link opens in a new window")
		  .attr("target", "_blank")
		  .addClass('externalLink');
		  
		  
		  	// Add pdf icons to pdf links
	$("a[href$='.pdf']")
	.addClass("pdf")
	.attr("title", "Adobe Acrobat document");
 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
 
	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
 
	// Add email icons to email links
	$("a[href^='mailto:']")
	.addClass("email")
	.attr("title", "Send an email to this address");
 
 	$("#center img").removeAttr("border");

// Milestones slideshow 

$('#milestone').cycle({ 
    fx:         'fade', 
    timeout:     8000, 
    pager:      '#milestonenav', 
	activePagerClass: 'activeSlide',
	pagerAnchorBuilder: function(idx, slide) {
		var year = $(slide).find("strong").html();
        return '<li id="milestone'+year+'"><a href="#">'+year+'</a></li>'; 
    }	
});




// homepage sliders

// the large image
	$('#slideshow').before('<div id="slideshowNavContainer"><ul id="slideshowNav">').cycle({
		speed:  1000,
		timeout: 6000,
		pager:  '#slideshowNav',
		pagerClick: function(idx, slide) {
			$('#slideshowText').cycle(idx);
			return false;
		},
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"><img src="' + slide.src + '" width="48"  /></a></li>';
		}
	});

// the text for the large image
	$('#slideshowText').cycle({
		fx:     'blindY',
		speed:  1000,
		timeout: 6000,
		cleartype: !$.support.opacity, 
		cleartypeNoBg: true
	});

// the small slider on the right of the large image
	$('#slider').cycle({
		fx:     'scrollHorz',
    	prev:   '#prev',
		next:   '#next',
		speed: 	 400,
		timeout: 0,
		cleartype: !$.support.opacity, 
		cleartypeNoBg: true
	});

// sub pages

// the large image at the top
	$('#subImage img:first').fadeIn(1000, function() {
        $('#subImage').cycle({
			speed:  'fast',
			speed:  1000,
			timeout: 6000
		});
    });

});

