	$(function(){
		$('#menu a').hover(function() {
			if($(this).parent().parent().attr('id') == '') return false;
			
			if ($(this).parent().children('div').length > 0) {
				$(this).parent().children('div').slideDown();
			} else {
				$('#menu div').hide();
			}
		});

		$('body').click(function(){$('#menu div').hide();});

		$('#carousel1').bxCarousel({
			display_num: 5,
			move: 1,
			prev_image: '/public/img/filmleft.png',
			next_image: '/public/img/filmright.png',
			margin: 5
		});

		// We only want these styles applied when javascript is enabled
		$('div.content').css('display', 'block');

		// Initially set opacity on thumbs and add
		// additional styling for hover effect on thumbs
		var onMouseOutOpacity = 1;
		$('#thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		
		// Initialize Advanced Galleriffic Gallery
		if ($('#thumbs').length) {
			var gallery = $('#thumbs').galleriffic({
				delay:                     5000,
				numThumbs:                 8,
				preloadAhead:              10,
				enableTopPager:            false,
				enableBottomPager:         true,
				maxPagesToShow:            10,
				imageContainerSel:         '#slideshow',
				controlsContainerSel:      '#controls',
				captionContainerSel:       '#caption',
				loadingContainerSel:       '#loading',
				renderSSControls:          false,
				renderNavControls:         false,
				nextPageLinkText:          '<img src=\'/public/img/slideright.png\' class=\'nextPage\' />',
				prevPageLinkText:          '<img src=\'/public/img/slideleft.png\' class=\'prevPage\' />',
				enableHistory:             false,
				autoStart:                 true,
				syncTransitions:           true,
				defaultTransitionDuration: 1000,
				onSlideChange:             function(prevIndex, nextIndex) {
				// 'this' refers to the gallery, which is an extension of $('#thumbs')
				this.find('ul.thumbs').children()
					.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
					.eq(nextIndex).fadeTo('fast', 1);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn:        function() {
					this.fadeTo('fast', 1.0);
				}
			});
		}

	});
