$(document).ready(function() {
	var page = location.hash;	// get the hash
	if(page != ''){
		$('#property_tabs ' + page).fadeIn(); 
			$('.current').removeClass('current');
			$('#tabs ul li a[href=' + page +']').parent().addClass('current');

	} else {
		$('#property_tabs').children(":first").show();  //show overview tab by default.
	}
	$('#tabs ul li a').click(function(e){
		e.preventDefault();
		$('#property_tabs').children().hide(); //hide any active tabs
			var hashtarget = $(this).attr('href');
			location.hash = hashtarget;
			$(hashtarget).show();
			if(hashtarget == '#map'){ //fix map display bug by refreshing the page
				location.reload();
			}
			$('.current').removeClass('current');
			$(this).parent().addClass('current');
	});
	
	$('#floorplans ul li span.title a').click(function(e){
	     e.preventDefault();
		 
		$('#property_tabs').children().hide(); //hide any active tabs
			var hashtarget = $(this).attr('href');
			location.hash = hashtarget;
			hashtab = hashtarget + '_tab';
			$(hashtarget).show();
			$('.current').removeClass('current');
			$(hashtab).addClass('current');
	});
});
