//----------------------------------------------------------------------------
// Page Scope Level: denotes which type of button was clicked.  Buttons/ImageButtons [of submit type] if wanting
// to subscribe to the navigate function, need to have a click event [OnClick] set "buttonType" to appropriate 
// switch [case] member.
//----------------------------------------------------------------------------
var buttonType = "";
//----------------------------------------------------------------------------
//MsHack: In Javascript we copied down WebUIValidation.js and included in
//Page_ClientValidate two methods [Global_OnBeforeValidate & Global_OnAfterValidate]
//Along with a (in Banner for now) a registration of a custom validator that is
//affiliated with no specific client side or server side control or method.  The
//reason for this was to force the inclusion of the WebUIValidation.js on every 
//page. For Netscape... we include a WebUIValidationNS.js version of this script.
//
//Global_OnSubmit is called globally on all navigation.  HttpHeader include
//registers (overrides) the builtin Form_OnSubmit and returns prior to calling like
// [onsubmit="return Global_OnSubmit(); ValidatorOnSubmit();"] e.g. the ValidatorOnSubmit()
//is never called.
//
//Global_OnBeforeValidate is called if exists prior to validators running. Asp.Net
//Validators then run. Then if successful asp.net validators,  Global_OnAfterValidate
//is called.  These in turn look for page specific page validators to exist
//[Page_OnBeforeValidate && Page_OnAfterValidate].  Any Page level items are ran
//prior to global items running.  Returning True continues processing, False stops.
//----------------------------------------------------------------------------
function Global_OnSubmit()
{
	var result = true;
    result = Page_IsValid;
	return result;
}
//----------------------------------------------------------------------------
function Global_OnBeforeValidate()
{
	// called prior to page level validators
	var result = true;
	
	// page level 
	if (typeof(Page_OnBeforeValidate) != "undefined")
		result = Page_OnBeforeValidate();

	// FSC OnBeforeValidate() call this when in buffered FSC mode
	if (typeof(Global_OnBeforeValidateFSC) != "undefined")
	{
		if (result)
		{
			result = Global_OnBeforeValidateFSC(buttonType);
		}
	}
	else
	{
		// global level
		if (result)
		{
			switch(buttonType)
			{
				case "exitHome":
					result = confirm("Are you sure you would like to exit to main menu?");
					break;
				case "exitLogOut":
					result = confirm("Are you sure you would like to log out of this session?");
					break;
				case "exitGeneral":
					result = confirm("Are you sure you would like leave this section of the application?");
					break;
				case "exitCancel":
					result = confirm("Are you sure you would like to cancel this Family Status Change?");
					break;
			}
		}
	}
		
	// reset buttonType value
	buttonType = "";

	return result;
}

//----------------------------------------------------------------------------
function Global_OnAfterValidate(IsValid)
{
	// called after page level validators
	var result = true;

	if (typeof(Page_OnAfterValidate) != "undefined")
		result = Page_OnAfterValidate(IsValid);
	
	return result;
}
//----------------------------------------------------------------------------

