﻿var tracking;
var facebook;

// Register any other necessary scripts here.
// Make sure to chain the callback methods in the correct order, and that Setup() is last.
$(document).ready(function ()
{
	$.ajaxSetup({ async: false });
	// Include the debugging script
	$.getScript("/js/debug.js");
	$.ajaxSetup({ async: true });

	// Register common page startup functions.
	// Always configure GA first.  Tracking clicks should be registered by calling methods on this object.
	$.getScript("/js/tracking.js", PageInitialisation);
});

function PageInitialisation()
{
	tracking = new Tracking();

	// Async load the facebook api, if wanted.
	if (typeof (FacebookApiLoaded) == 'function') $.getScript("/js/facebook.js", function () { facebook = new Facebook(); SetAppId(); FacebookApiLoaded(); });
	if (typeof (TwitterApiLoaded) == 'function') $.getScript("http://platform.twitter.com/widgets.js", function () { TwitterApiLoaded(); });

	// Call any page-specific initialisation scripts (registered on the relevant specific page).
	if (typeof (Initialise) == 'function') Initialise();

	// Setup print buttons everywhere?
	attachPrint();
}

function attachPrint()
{
	jQuery("a.btn-print").each(function (i)
	{
		jQuery(this).click(function ()
		{
			window.print();
			return false;
		});
	});
}
