var theForm;
var suppressAutoSave = false;
var formDirty = false;
var confirmAutoSaveMessage = 'You have made changes to the information on this page which have not been saved.\nWould you like to save them now?';
var confirmAutoSaveRegisterMessage = 'Are you sure you want to navigate away from this page?';

addLoadEvent( SetForm );


function SetForm()
{
	theForm = GetPageElement('ServerForm')
}


function PromptAutoSave()
{
	if (theForm!=null && !suppressAutoSave && formDirty)
	{
		if ( confirm(confirmAutoSaveMessage) )
			AutoSave();
	}
}


/*
function PromptAutoSaveRegister()
{
	if (theForm!=null)
	{
		AutoSave();
		if ( !confirm(confirmAutoSaveRegisterMessage) )
			return false;
	}
}
*/


function AutoSave()
{
	if (theForm!=null && !suppressAutoSave && formDirty)
	{
		oldTarget = theForm.target;

		theForm.target = "AutoSaveIFrame";
		theForm.__EVENTTARGET.value = "AutoSave";
		theForm.submit();

		theForm.target = oldTarget;
		theForm.__EVENTTARGET.value = "";
	}
}
