ldm_reinitialize_scroller = function() {
	$('#backScrollPane').jScrollPane({showArrows:true, scrollbarWidth: 9, animateTo:true, animateInterval:50, animateStep:5});
}


// initialise plugins
		jQuery(function(){
			jQuery('ul.sf-menu').superfish();
			
			$('#bigimg').animate({ top:'0px'}, 1000, 'linear', function(){
				$('#topimg').animate({ left:'0px'}, 500, 'linear', function(){
					$('#botimg').animate({ left:'0px'}, 500, 'linear', function(){});				
				});				
			});
			
			$("#searchbox").focus(function() {
             	if ( $(this).val() == "SITE SEARCH")
                	$(this).val('');
            	}).blur(function() {
             		if ( $(this).val() == "")
                		$(this).val('SITE SEARCH');
            	});
         	 
            // add Hover to Go Button for search area
			jQuery('#searchlink').hover(
                function() {
			         jQuery(this).attr('src', 'images/go_over.jpg');
			    },
			    function() {
			         jQuery(this).attr('src', 'images/go.jpg');
			    }
	        ); // jQuery('#searchlink').hover(
	        
			// this initialises the scrollpane on the page.
			$('#backScrollPane').jScrollPane({showArrows:true, scrollbarWidth: 9, animateTo:true, animateInterval:50, animateStep:5});
	        	
            // initialize lightbox swf
            jQuery('#lbswfs a').fancybox({
              'overlayShow':true,
              'overlayOpacity':0.85,
              'frameWidth': 725,
              'frameHeight': 525
            });
			
			// initialize lightbox for photogalleries
			jQuery('#photogallery_container .photogallery a').fancybox();
			
			
			jQuery.each(
				jQuery('#videogallery_container .video_container a'),
				function (i, obj) {
					jQuery(obj).fancybox({'hideOnContentClick':false}); // initialize lightbox
					video_url = jQuery(obj).find('param[name="movie"]').val();
					if (video_url == null) {
						// browser uses embed tag instead of object tag (i.e. IE)
						video_url = jQuery(obj).find('embed').attr('src')
					}
					video_name = /^http:\/\/www.youtube.com\/v\/(.*?)&.*$/.exec(video_url);					
                    // if determining video name fails, degrade gracefully SRF 20090831
					if (video_name !== null) {
    					video_image_url = "http://i3.ytimg.com/vi/" + video_name[1] + "/default.jpg";
	   				    jQuery(obj).find('img').attr('src', video_image_url);
					} 
				}
			);
			
			// create separate version for printing
				// clone backScrollPane 
					// change id to 'forprint' (it will be hidden until printing)
					// set css top to zero (proper setting for printing display)
					// append to #main_text div .bod
				jQuery('#main_text .bod').append(jQuery('#backScrollPane').clone().attr('id', 'forprint').css('top','0'));
				

			// move video divs out of #videogallery_container for smooth transistions
			jQuery.each(
				jQuery('.video'),
				function(i, obj) {
					jQuery('#hidden_video_container').append (obj);
				} // function(i, obj)
			);			
			//jQuery('#forprint').append('.video');

			/* BEGIN Controls for Media Gallery */
			
/*			jQuery('#videogallery_trigger').toggle(
				function(e) {
					e.preventDefault();
					jQuery('#videogallery_container').slideDown('normal',ldm_reinitialize_scroller);
					// reinit scroller
					$('#backScrollPane').jScrollPane({showArrows:true, scrollbarWidth: 9, animateTo:true, animateInterval:50, animateStep:5}); 					
				},
				function(e) {
					e.preventDefault();
					// ie6 slide up looks glitchy
					if(jQuery.browser.msie && jQuery.browser.version.substr(0,2)=="6.") {
						jQuery('#videogallery_container').hide(); // ie6 use a straight hide						
						ldm_reinitialize_scroller();
					} else {
						jQuery('#videogallery_container').slideUp('normal',ldm_reinitialize_scroller); // all other browsers
					}
					// reinit scroller
					$('#backScrollPane').jScrollPane({showArrows:true, scrollbarWidth: 9, animateTo:true, animateInterval:50, animateStep:5}); 
				}				
			); // jQuery('#videogallery_trigger')*/
			
			
			
			jQuery('#photogallery_trigger').click(
				function(e) {
					e.preventDefault();
					jQuery('#medianav a').removeClass('selected');
					jQuery(this).addClass('selected').blur();
					if (jQuery.browser.msie && jQuery.browser.version.substr(0, 2) == "6.") {
						jQuery('#videogallery_container').hide(); // ie6 use a straight hide						
					}
					jQuery('#videogallery_container')
					.slideUp('normal', 
						function(){
							jQuery('#podcast_container')
							.slideUp('normal',
								function() {
									jQuery('#photogallery_container').slideDown();																		
								}								
							);
						}
					);
				}
			); // jQuery('#photogallery_trigger').click(			

			jQuery('#videogallery_trigger').click(
				function(e) {
					e.preventDefault();
					jQuery('#medianav a').removeClass('selected');
					jQuery(this).addClass('selected').blur();

					jQuery('#photogallery_container')
					.slideUp('normal', 
						function(){
							jQuery('#podcast_container')
							.slideUp('normal',
								function() {
									jQuery('#videogallery_container').slideDown();																		
								}								
							);
						}
					);
				}
			); // jQuery('#videogallery_trigger').click(

			jQuery('#podcastgallery_trigger').click(
				function(e) {
					e.preventDefault();
					jQuery('#medianav a').removeClass('selected');
					jQuery(this).addClass('selected').blur();

					jQuery('#photogallery_container')
					.slideUp('normal', 
						function(){
							if (jQuery.browser.msie && jQuery.browser.version.substr(0, 2) == "6.") {
								jQuery('#videogallery_container').hide(); // ie6 use a straight hide						
							}
							jQuery('#videogallery_container')
							.slideUp('normal',
								function() {
									jQuery('#podcast_container').slideDown();																		
								}								
							);
						}
					);
				}
			); // jQuery('#podcastgallery_trigger').click(


			/* END Controls for Media Gallery */		
		}); // jQuery(function()
		
		window.onload = function() {
		  $('#backScrollPane').jScrollPane({showArrows:true, scrollbarWidth: 9, animateTo:true, animateInterval:50, animateStep:5});
		}