$(document).ready(function() {

	var planImage = $('#planImage');

	$('#extraButtons a').click(function(){
		var newImg = $(this).attr('href');
		planImage.attr('src',newImg);
		return false;
	});

	$('#buttons a').click(function(){
		var me = $(this);
		var meChild = $(this).children();

		var imagePath = 'images/plan_' + me.attr('id')
		var pdflink = 'pdfs/plan_' + me.attr('id') + '.pdf';

		// change the HREF for all the buttons inside the extraButtons div
		$('#extraButtons a').each( function(){
			$(this).attr('href',imagePath + '_' + $(this).attr('id') + '.gif');
		});

		// update the pdf download link
		$('#planImageLink').attr('href',pdflink);

		// reset the background of all buttons
		$('#buttons a span').not("#" + me.attr('id')).animate({left: 0}, "slow"); 

		// fix the background color of the current floor plan
		meChild.animate({left: 25}, "fast");

		// change the primary image
		planImage.attr('src',imagePath  + '_elevation.gif');

		return false;
	});

});