function include(filename)
{
	// Allows us to dynamically include other javascript if necessary
	var head = document.getElementsByTagName('head')[0];
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	head.appendChild(script);
}


$(document).ready(function()
{
	$(function(){$('.lavaLamp').lavaLamp({fx:'backout',speed:700});});
	$('.button').button();
	$('#cancelbutton').button({icons:{primary:'ui-icon-circle-close'}});
	$('#feedbackbutton').button({icons:{primary:'ui-icon-comment'}});
	$('#showtransport').button({icons:{primary:'ui-icon-info'}});
	if(document.cookie.indexOf('loggedIntoSite=yes') > -1)
	{
		// Include the necessary javascript to set up editable fields
		include('javascript/maintenance/setup.js');
	}

	// Have we got a map?
	var map = document.getElementById('map_canvas');
	if(map !== null)
	{
		// We've got a map, so initialise it
		initialise_map();
	}
	var g = 0;
	if(typeof(galleries) != 'undefined')
	{
		g = galleries.length;
	}
	// Check if the edit cookie's set. If it is, we don't want to attach the
	// divbox code
	if(g > 0 && document.cookie.indexOf('loggedIntoSite=yes') == -1)
	{
		// The galleries array contains a list of the divisions containing
		// distinct galleries, so we can initialise separate instances and
		// avoid having them all merge into one within the divbox code
		for(var i=0;i<g;i++)
		{
			$('#'+galleries[i]+' a').divbox();
		}
	}
	// Do we need to include tablesort and tabs code?
		$('.tabs').tabs();
	if(typeof(needTabs) !== 'undefined')
	{
		$('.tabs').tabs();
		if(typeof(emptyTabs) != 'undefined' && document.cookie.indexOf('loggedIntoSite=yes') == -1)
		{
			var e = emptyTabs.length;
			for(i=0;i<e;i++)
			{
				$('#'+emptyTabs[i]).hide();
			}
		}
		$('#hiddentabs').show();
	}
});
function resort(column,table,descending)
{
	$(table).sortTable({
		onCol:column,
		keepRelationships:true,
		sortDesc:descending
	});
}

function show_feedback()
{
	$('#feedbackframe').show();
	$('#feedbackbutton').hide();
}
function close_feedback()
{
	$('#feedbackframe',window.parent.document).hide();
	$('#feedbackbutton',window.parent.document).show();
}

