/* ===========================================================================
 * SCHEDULE THE BEHAVIOURS
 * =========================================================================== 
 */

/* 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();
});

$(document).ready(function()
{
	//geo();
});



$(document).ready(function()
{	
	/*
	$("#navigation li ul").hide(); 
	*/
	$("#nav li").hover(
		function () 
		{
			$(this).addClass("hover");
		},
		function()
		{
			$(this).removeClass("hover");
		}
	);//hover
	
});


/* Set links */
$(document).ready(function()
{	
	$("a.tool-print").click(
		function () 
		{
			if (window.print)
				window.print();
			else
				alert("Sorry, your browser doesn't support the print feature. Use the File menu on your browser to select Print.");
			return false;	
		}
	);
	
	$("a[rel='external']").attr("target","_blank");
});

/* Set the tooltips */
$(document).ready(function()
{	
	/* http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ */
	/*
	$('#tools a').tooltip(
	{
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		opacity: 1.0,
		fade: 100
	});
	*/
});

/* Set text resizing */
$(document).ready(function()
{	
	textresize();
});


/* Do some page tidying */
$(document).ready(function()
{
	$("#header").append("<div id=\"strip\"></div>");
	$("#nav li.current + li a").css("background-image","none");
	$("#nav li.last.current").css("background-image","none");
	$("#main h2:first").addClass("first");
	
	// Add inner class to header for image mask
	$("h3").wrapInner("<span></span>");
	
	if(typeof fixMenuForIE==='function')
		fixMenuForIE();
		
		
	$("li > a.pdf").parent().parent().addClass("nobullet");
	$("li > a.doc").parent().parent().addClass("nobullet");
	
});


/* http://www.shopdev.co.uk/blog/text-resizing-with-jquery/ */
function textresize()
{
	// show text resizing links
	$(".FontSize").show();
	var $cookie_name = "sitename-FontSize";
	var originalFontSize = $("html").css("font-size");
	
	// if exists load saved value, otherwise store it
	if($.cookie($cookie_name)) 
	{
		var $getSize = $.cookie($cookie_name);
		$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
	} 
	else 
	{
		$.cookie($cookie_name, originalFontSize);
	}
	
	// reset link
	$(".tool-textreset").bind("click", function() 
	{
		$("html").css("font-size", originalFontSize);
		$.cookie($cookie_name, originalFontSize);
	});
	
	// text "+" link
	$(".tool-textup").bind("click", function() 
	{
		var currentFontSize = $("html").css("font-size");
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum+1;
		if (newFontSize,  11) 
		{
			$("html").css("font-size", newFontSize);
			$.cookie($cookie_name, newFontSize);
		}
		return false;	
	});
	
	$(".tool-textdown").bind("click", function() 
	{
		var currentFontSize = $("html").css("font-size");
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum-1;
		if (newFontSize, 11) 
		{
			$("html").css("font-size", newFontSize);
			$.cookie($cookie_name, newFontSize);
		}
		return false;
	});
}


