/* ===========================================================================
 * Filename: theme/javascript/functions.js
 * Author: Rebecca Skeers, rebecca@webmistress.com.au, www.webmistress.com.au
 * Copyright: Rebecca Skeers
 * Date: 26 Nov 2010
 * Description: Contains JavaScript behaviour for the Flinders Lane Apartments website.
 *
 * This file may not be used for any purpose other than for the Flinders Lane Apartments
 * website and may not be modified without written permission from the author.
 * =========================================================================== 
 */

$(document).ready(function()
{	
	$("a[rel='external']").attr("target","_blank");
	
	$(".thumbnails a").click(
		function () 
		{
			var imagepath = $(this).attr("href");
			var caption = $(this).attr("title");
			$("#galleryimage").attr({ src: imagepath, alt: caption });
			return false;
		}
	);
	
	$(".thumbnails a").each(
		function( intIndex )
		{
			var imagepath = $(this).attr("href");
			preLoadImage(imagepath);
		}
	);
});


/* Google map functions */
$(window).resize(function()
{
	if(typeof loadMap==='function')
		loadMap();
});

$(window).unload(function()
{
	if(typeof GUnload==='function')
		GUnload();
});

$(document).ready(function()
{
	if(typeof loadMap==='function')
		loadMap();
});


var cache = [];
preLoadImage = function() 
{
	var args_len = arguments.length;
	for (var i = args_len; i--;) 
	{
		var cacheImage = document.createElement('img');
		cacheImage.src = arguments[i];
		cache.push(cacheImage);
	}
}

