function DefaultButton_Init()
{
	if ( !DefaultButton_BrowserCapable() )
		return false;
	
	for( var i=0; i<DefaultButtons.length; i++ ) 
	{
		var defaultButtonSetting = DefaultButtons[i].split(";");
		if ( defaultButtonSetting.length != 3 )
		{ 
			return; 
		}
		var inputControl = document.getElementById( defaultButtonSetting[0] );
		var buttonControlName = defaultButtonSetting[1];
		var causesValidation = ( defaultButtonSetting[2] == 'True' );
		if ( inputControl != null ) 
		{
			if ( i==0 ) 
			{
				var theForm = inputControl.form;
				theForm.EnsureDefault = false;
				theForm.defaultButtonName = "";
			}
			inputControl.defaultButtonName = buttonControlName;
			inputControl.causesValidation = causesValidation;
			inputControl.RegisterDefault = DefaultButton_RegisterDefault;
			inputControl.UnRegisterDefault = DefaultButton_UnRegisterDefault;
			inputControl.onfocus = inputControl.RegisterDefault;
			inputControl.onblur = inputControl.UnRegisterDefault;
		}
	}
}
function DefaultButton_BrowserCapable() 
{
	if ( typeof( __doPostBack ) == "undefined" ) 
		return false;
	if ( typeof( document.getElementById ) == "undefined" ) 
	{
		if( typeof( document.all ) != "undefined" ) 
		{
			document.getElementById = function( elementId ) { return document.all[elementId]; };
		} 
		else 
		{
			return false;
		}
	}
	return true;
}
function DefaultButton_RegisterDefault() 
{
	this.form.EnsureDefault = true;
	this.form.defaultButtonName = this.defaultButtonName;
	this.form.causesValidation = this.causesValidation;
}
function DefaultButton_UnRegisterDefault() 
{
	this.form.EnsureDefault = false;
	this.form.defaultButtonName = "";
	this.form.causesValidation = false;
}
function DefaultButton_RequireOwnPostback(form)
{
	if ( form.EnsureDefault && form.defaultButtonName != "" ) 
	{
		form.EnsureDefault = false;
		window.setTimeout( "DefaultButton_Postback( '" + form.defaultButtonName + "', " + form.causesValidation + ");", 10 );
		return true;
	} 
	else
	{
		return false;
	}
}
function DefaultButton_Postback( buttonName, causesValidation )
{
	if (typeof(Page_ClientValidate) == 'function' && causesValidation)
	{
		if (  Page_ClientValidate() )
		{
			__doPostBack( buttonName, '' );
		}
	}
	else
	{
		__doPostBack( buttonName, '' );
	}
}

