$(function(){
	$('#floorplan a').bind('click', function(){
		window.open($(this).attr('href'),'dialog','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=815,height=750,screenX=100,screenY=100,top=100,left=100');
		return false;
	});
	// The amount of time to display each slide in millaseconds
	var slideDuration = 3000;
	// The fade transistion speed of the slides in millaseconds
	var fadeSpeed = 1000;
	// Get slideshow containers
	var slideshows = $('div.tour .thumbs .photo');
	// Attach slideshow functionality to each slideshow
	slideshows.each(function(index){
		var i = 0;
		var n = $(this).find('div div').length;
		// Fade in first photo
		slideshows.eq(index).find('div div').eq(i).fadeIn(fadeSpeed);
		// Only play slideshow if there is more than one photo
		if (n > 1) {
			setTimeout(function(){
				setInterval(function() {
					nextIndex = i + 1;
					if (i == (n - 1)) nextIndex = 0;
					// Fade out previous logo
					slideshows.eq(index).find('div div').eq(i).fadeOut(fadeSpeed);
					// Fade in next logo
					slideshows.eq(index).find('div div').eq(nextIndex).fadeIn(fadeSpeed);
					i++;
					if (i == n) i = 0;
				}, slideDuration);
			}, (index * 500));
		}						
	});
	$('div.tour .nav a').each(function(index){
		$(this).bind('click', function(){
			$('div.tour .slides .slide > div').fadeOut().eq(index).fadeIn();
			return false;
		});
	});				
});