	
	$(document).ready(function(){
		
		//Tech Downloads
		$('#tech-downloads-links').hide();
		$('a#tech-downloads-agree').click(function () { 
			$('#tech-downloads-links').show();
			return false;
	    });
		
		$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
		
		//Occupiers
		$('div#occupiers-indicator').hide();
		$('div.occupiers-no-script').addClass('occupiers').removeClass('occupiers-no-script');
		$('ul#occupiers-list a').hover(
			function () {
				if($(this).attr('rel') !== undefined){
				var occupier = $(this).attr("rel");
				$('div#occupiers-indicator').addClass(occupier).show();
				}
			}, 
			function () {
				var occupier = $(this).attr("rel");
				$('div#occupiers-indicator').hide().removeClass(occupier);
			}
		);
		
		//Crossrail at Paddington
		$('div.cp-map ul li p').hide();
		$('div.cp-map ul li a').hover(
			function () {
				$(this).next('p').show();
			}, 
			function () {
				$(this).next('p').hide();
			}
		);
		
		//Schedule
		$('table.schedule-table div').addClass('schedule-floor').hide();
		$("table.schedule-table td a.selected").next('div').show();
		$('div#podium-details').hide();
		$('div#podiumBreakDown a').toggle(
			function () {
				$('div#podium-details').show();
			},
			function () {
				$('div#podium-details').hide();
			}
	    );

		
		$("table.schedule-table td").children("a").click(function () { 
			$("table.schedule-table td a").removeClass('selected');
			$(this).addClass('selected');
			$('table.schedule-table div').hide();
			$(this).next('div').fadeIn();
			return false;
	    });
		
		//Amenities 
		$('div.am-details').hide();
		$("a.selected").next('div.am-details').show();
		
		$("#am-list li").children("a").click(function () { 
			$("#am-list li a").removeClass('selected');
			$(this).addClass('selected');
			$('div.am-details').hide();
			$(this).next('div.am-details').fadeIn();
			return false;
	    });

		$('ul.gallery_demo').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				image.css('display','none').fadeIn(1000);
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
	});
	
