/* ======================================================================================
 * Filename: theme/javascript/functions.js
 * Author: Webmistress, info@webmistress.com.au, www.webmistress.com.au
 * Copyright: Webmistress
 * Date: 1 July 2011
 * Description: JavaScript functions for the food2u website.
 *
 * This file may not be used for any purpose other than for the food2u website 
 * and may not be copied or modified without written permission from the author.
 * ======================================================================================
 */

$(document).ready(function()
{	
	$("#nav li").hover(
		function () { $(this).addClass("hover"); },
		function() { $(this).removeClass("hover"); }
	);
	
	$("a[rel='external']").attr("target","_blank");
	
	$(".expandable h3").each(
		function( intIndex )
		{
			var closeLink = $("<p><a href=\"#\" class=\"close\">Close</a></p>");
			var expandDiv = $("<div class=\"expand\"></div>");
			$(this).nextUntil('h3').detach().appendTo(expandDiv);
			expandDiv.append(closeLink);
			$(this).after(expandDiv);
			$(expandDiv).hide();
			$(closeLink).click(function () 
			{
				$(this).closest("div.expand").slideUp();
				return false;
			});
		}
	);
	
	$(".expandable h3").click(function () 
	{
		if ($(this).next("div.expand").eq(0).is(":hidden")) 
		{
			$(this).next("div.expand").eq(0).slideDown();
			return false;
		} 
		else 
		{
			$(this).next("div.expand").eq(0).slideUp();
			return false;
		}
	});
	
	$("#jumptoform").css("display","block");
	
	$("#jumptoform select").change(function() 
	{
		$('#jumptoform').submit();
	});
	
	$("#jumptoform").submit(function() 
	{
		var theValue = $("#jumpto").val();
		if(theValue != '') 
			window.location = theValue;
		return false;
	});
	
});

$(window).resize(function()
{
	if(typeof initialise_gmap==='function')
		initialise_gmap();
});

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


