jQuery(document).ready(function() {

	jQuery( function($) {

	/* hover popups													  */
	/*
	 * dynamically set caption-pop-caption to bottom: -(height)
	 * @link: http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/
	*/

		var _bnr_opacty_start		= 0 ;
		var _bnr_opacty_end			= 0.3;

		//$('.caption-pop').each( function () {
		$('.bnr-img-caption').each( function () {
			var _el_caption = $('.caption', this);

			var _height_capt = $('.caption', this).height();
			//var _height_head = $('.head', this).height();
			var _height_head = $('.head', this).outerHeight( true);
			var _height_text = $('.text', this).height();

			//var _height_init = '-' + (   _height_capt - _height_head - 16) + 'px';
			var _height_init = '-' + (   _height_capt - _height_head ) + 'px';

			if ( $(this).hasClass( 'bnr-img-caption-bottomtop')) {
				_el_caption.css( 'bottom', _height_init);
				$(this).hover( function( ) {
					$('.caption', this).stop().animate({ bottom: '0px'}, {queue: false, duration: 200});
					$('.overlay', this).stop().animate({ opacity: _bnr_opacty_start}, {queue: false, duration: 200});
				}, function() {
					$('.caption', this).stop().animate({ bottom: _height_init},{ queue:false, duration: 200});
					$('.overlay', this).stop().animate({ opacity: _bnr_opacty_end}, {queue: false, duration: 200});
				});
			} else if ( $(this).hasClass( 'bnr-img-caption-topbottom') && 1 == 2) {
				_el_caption.css( { 'bottom': 'auto', 'top': _height_init});
				$(this).hover( function( ) {
					$('.caption', this).stop().animate({ top: '0px'}, {queue: false, duration: 200});
					$('.overlay', this).stop().animate({ opacity: _bnr_opacty_start}, {queue: false, duration: 200});
				}, function() {
					$('.caption', this).stop().animate({ top: _height_init},{ queue:false, duration: 200});
					$('.overlay', this).stop().animate({ opacity: _bnr_opacty_end}, {queue: false, duration: 200});
				});
			}
		})


		/* suckerfish menu											*/
		$('ul#menu-menu_main').superfish({
			delay: 400,			// the delay before sub closes
			speed: 'fast',	// speed of the fade-in
			dropShadows: true
		});

		/* coda 																*/
		$('#masthead-images-coda').codaSlider({
			autoSlide: true,
			autoSlideInterval: 5000,
			autoSlideStopWhenClicked: true,
			dynamicTabsPosition: 'top', // bottom is default
			firstPanelToLoad: 1,
			dynamicArrows: true
		});


		/* fancybox 														*/
		
		$('#article-content a.link-dest-image').fancybox({
			/* 'padding'         : 0, */ // hide white border
			'padding'         : 0,
			'titlePosition'   : 'over',
			//'title'						: $(this).next().attr('title'),
			'titleFromAlt'		: true,
			'titleFormat'     : function(title, currentArray, currentIndex, currentOpts) {
		  	return '<span id="fancybox-title-over">' + title + ' <span style="display:block;clear:both;float:left;width:100%;height:20px;text-align:right"><em>Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</em></span><span style="display:block;clear:both"></span></span>'
		  }
		});

	})
})

