$(document).ready(function() {
	
	// Used to transition thumbnails to center image (on click) on gallery pages
	$('.gallery-thumbnail img').click(function(){				
		var src = $(this).attr('src');
		var $gallery = $('.gallery-center');
		
		$gallery.fadeOut(400, function() {
			$gallery.attr('src', src);
			$gallery.fadeIn(400);
		});
			
		return false;				
	});
	
	// Floorplans	
	$('.floorplan-links').click(function(e){				
		var href = $(this).attr('href');
		
		$('.floorplan-links').removeClass('current');
		$(this).addClass('current');
		
		$('#interior-rendering').attr({ 'href': floorplanObj[href]['rendering'] });
		$('#enlarge-pdf').attr({ 'href': floorplanObj[href]['pdf'] });		
		$('#floorplan-image img').fadeOut(400, function() {
			$(this).attr({ 'src': floorplanObj[href]['floorplan'] }).fadeIn(400);
		});	

		e.preventDefault();
	});	
	$('.floorplan-links').hover(function(e){
		var href = $(this).attr('href');	
		$('#floorplate-image img').attr({ 'src': floorplanObj[href]['floorplate'] });	
	});
	
	$('#interior-rendering').click(function(e){
		var renderingImage = $(this).attr('href');
		$('.unit-section').fadeOut(500);
		$('#secondary').fadeOut(500, function() {
			$('#floorplan-rendering-image').fadeIn(500);
			$('#floorplan-rendering').attr({ 'src' : renderingImage });
		});
			
		e.preventDefault();
	});
	
	$('#floorplan-rendering-image a').click(function(e) {
		$('#floorplan-rendering-image').fadeOut(500, function() {
			$('#secondary').fadeIn(500);
			$('.unit-section').fadeIn(500);

		});
		
		e.preventDefault();
	});
	
	//Concert page
	$('.concert .gallery-icon').click(function(e) {
		var thumbLink = $(this).children().attr('src');
		var thumbTitle = $(this).attr('title');		
		$('#concert-center img').attr({ 'src': thumbLink });
		$('#building-title').text(thumbTitle);
		$('#concert-center').fadeIn(500);
		
		e.preventDefault();		
	});
	$('.concert #close').click(function(e) {
		$('#concert-center').fadeOut(500);
		e.preventDefault();		
	});
	
	
	// Used on renderings page to scroll thumbnails up and down
	$('#renderings-scroll').serialScroll({
		items:'li',
		prev:'#prev-button',
		next:'#next-button',
		axis:'xy'
	});
});
