﻿_PFX = 'ctl00_C_';

/*
Anthem_PostCallBack =
	function()
	{
		if (DG_PostCallback != null) DG_PostCallback();
		if (typeof(SetupTooltips) == 'function') SetupTooltips();
	}
*/

CancelButton_OnClick =
	function(e)
	{
		if (!(top.detailIsDirty) || confirm('Are you sure you wish to cancel your changes?'))
			document.location.reload();
	}
	
DeleteButton_OnClick  =
	function(e)
	{
		var el = YAHOO.util.Dom.get('ctl00_DeleteButton');
		var entity = DDI.Web.GetAttribute('string', el, 'entity', 'information');
		if (confirm('Are you sure you want to delete this ' + entity + '?'))
			return true;
		return false;
	}
	
PublishPageButton_OnClick  =
	function(e)
	{
		Toggle_ErrorSummary('error');
		if (confirm('Are you sure you want to publish this page?'))
			return true;
		return false;
	}

PublishSectionButton_OnClick  =
	function(e)
	{
		Toggle_ErrorSummary('error');
		if (confirm('Are you sure you want to publish this page and all child pages?'))
			return true;
		return false;
	}
		
SaveButton_OnClick =
	function()
	{
		Toggle_ErrorSummary('error');
		if (typeof(SaveButton_Local_OnClick) == 'function') SaveButton_Local_OnClick;
	}
	
SetDirtyFlag =
	function(e)
	{
		top.detailIsDirty = true;
	}
	
Toggle_ErrorSummary =
	function(mode)
	{
		var summary = YAHOO.util.Dom.get('ctl00_ErrorSummary');

		if (mode == 'info')
		{
			YAHOO.util.Dom.replaceClass(summary, 'ErrorSummary', 'InfoSummary');
			YAHOO.util.Dom.setStyle(summary, 'color', '#00529b');
		}
		if (mode == 'error')
		{
			YAHOO.util.Dom.replaceClass(summary, 'InfoSummary', 'ErrorSummary');
			YAHOO.util.Dom.setStyle(summary, 'color', '#d63301');
		}
	}
	
Window_OnLoad = 
	function() 
	{
		DDI.ControlList();
		
		if (YAHOO.util.Dom.inDocument('ctl00_ButtonBar'))
		{
			YAHOO.util.Event.addListener('ctl00_SaveButton', 'click', SaveButton_OnClick);
			YAHOO.util.Event.addListener('ctl00_CancelButton', 'click', CancelButton_OnClick);
		}
		
		if (typeof(Local_Window_OnLoad) == 'function') Local_Window_OnLoad();
	}

YAHOO.util.Event.addListener(window, 'load', Window_OnLoad);
