jQuery.preloadImages = function() {
	if (arguments) {
		for(var i = 0; i<arguments.length; i++)
		{
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
}

function initialize(pagename) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		map.setUIToDefault();
	}
}

/*---- Simple Slideshow ----*/
function slideSwitch() {
	var $active = $('#slideshow IMG.active');

	if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
	// use this to pull the images in the order they appear in the markup
	var $next =  $active.next().length ? $active.next()
	: $('#slideshow IMG:first');

	// uncomment the 3 lines below to pull the images in random order
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
	});
}

$(function() {
	setInterval( "slideSwitch()", 4000 );
});

//toggle #you-could-save with scollTo effect
jQuery(function($) {

	//toggle #you-could-save with scollTo effect
	$('.form').click( function() {
		$('#contact').fadeIn('slow');
		$.scrollTo( '#contact', 800);
		return false;
	});

	$('#hdr-contact').click( function() {
		$('#contact').fadeOut('fast');
		return false;
	});

	//clear input fields onfocus
	$('input[type="text"]').focus( function() {
		if (this.defaultValue ==  this.value) { this.value = ''}
	}).blur( function() {
		if (this.value ==  '') { this.value = this.defaultValue }
	});

});
var qsON = false;
function qs() {
	var qsw = document.getElementById("quickSearchWrap");
	if(!qsON) {
		qsw.style.display="block";
		qsON = true;
	}
	else {
		qsw.style.display="none";
		qsON = false;
	}
}

// slide nav 
$(document).ready(function() {
	$('.faq').find('.faq').hide().end().find('dt').click(function() {
		$(this).next().slideToggle();
	});
	// 

	//
	$("a").hover(function(){
		$(this).parents("p").addClass("highlight");
	},function(){
		$(this).parents("p").removeClass("highlight");
	});
});

function getGroupItems(opts) {
	jQuery.each(imageList, function(i, val) {
		opts.itemArray.push(val);
	});
};

/*
if (! isIE6) {
	$(function(){
		$.Lightbox.construct({
			show_linkback:	false,
			show_info: true,
			show_helper_text: true,
			ie6: isIE6,
			ie6_support: false,
			ie6_upgrade: false, // sad -- the domain it links to is dead
			download_link: false
		});
	});

	$(document).ready(function(){
		$('.thumb-container-gallery a').lightbox();
		$('.floorplan-map a').lightbox();
	});

};
*/

// color box
$(document).ready(function() {
	$('a[rel="gallery"], a[rel="floorplans_image"], a[rel="sitemap"], .floorplan-map a').colorbox({transition:"elastic"});
	$('#target_blank').attr('target', '_blank');
  $('#target_blanks').attr('target', '_blank');

});
