


$(document).ready(function(){
	
	// fix "external" links to open in new window									 
	$('a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	}).attr('title', 'Opens in New Window or Tab');


	// home slideshow
	
	// load slide from # (hash)
	var hashSlide = parseInt(window.location.hash.slice(1, window.location.hash.length) );
	if ( hashSlide > 0 ) {
		hashSlide--;
	} else {
		hashSlide = 0;
	}
	
	$("#home-slideshow").cycle({
		pause:1,
		speed:500,
		timeout:5000,
		after:onAfterHome,
		startingSlide:hashSlide
	});
	
	$(".top-row a").click(function(){
	});
	$(".top-row-home a").click(function(){
		var newSlide = parseInt( $(this).attr("rel") );
		$("#home-slideshow").cycle( newSlide-1 );
		return false;
	});

	// floorplan image control
	$('#floorplan-names').tabs({ 
		fxFade: true, 
		fxSpeed: 'fast', 
		fxAutoHeight: true 
	});
	
	
	// gallery slideshow
	$("#gallery-items").cycle({
		pause:1,
		speed:500,
		timeout:5000,
		pager:"#gallery-pager",
		prev:"#gallery-prev",
		next:"#gallery-next",
		after:onAfterGallery
	});
	$(".gallery-thumb a").click(function(){
		var newSlide = parseInt( $(this).attr("rel") );
		$("#gallery-items").cycle( newSlide-1 );
		return false;
	});
	
	// nav lavalamp effect
	
    $("#footer-nav-list").lavaLamp({
        fx: "backout",
		speed: 700
    });

	$("#inquire-form").validate();
	
});

function onAfterHome(curr,next,opts) {
	var curSlide = opts.currSlide + 1;
	$(".top-row").removeClass("active");
	$("#top-row-"+curSlide).addClass("active");
}

function onAfterGallery(curr,next,opts) {
	var curSlide = opts.currSlide + 1;
	$(".gallery-thumb").removeClass("active");
	$(".gallery-thumb-"+curSlide).addClass("active");
}

