/*
	============================================================================
	Library Name:		members-update.js

	Synopsis:			Supply scripts for the HTML page generated by
						members-update.aspx

	Author:				David A. Gray
						Simple Soft Services, Inc., d/b/a WizardWrx
						on behalf of The Edit House, Inc., d/b/a The Learning
						Agency, and Emergency Medical Certification, Inc. d/b/a
						Emcert.com

	Copyright:			(c) 2007-2011, Emergency Medical Certification, Inc.
						d/b/a Emcert.com

	----------------------------------------------------------------------------
	Revision History
	----------------------------------------------------------------------------

	Date	   Version Who What was done.
	---------- ------- --- -----------------------------------------------------
	2007/04/03 1.0.0.0 DAG Initial version.
	2007/06/22 1.0.1.0 DAG Correct deficiencies in the internal documentation.
	============================================================================
*/

function TestFieldGroups ( pActionCode )
{
    /*
	----------------------------------------------------------------------------

	Function Name:		TestFieldGroups

	Synopsis:			Control the Enabled and Disbled states of the form
						controls involved in gathering information about the
						subscriber's ENT certification.

	Arguments:			pActionCode     = Numeric action code, to determine the
										  action to perform.

	Author:				David A. Gray, of Simple Soft Services, Inc., d/b/a
						WizardWrx, on behalf of The Edit House, Inc., d/b/a The
						Learning Agency, and Emergency Medical Certification,
						Inc. d/b/a Emcert.com

	Created:			Wednesday, 25 April 2007 to Friday, 27 April 2007.

	----------------------------------------------------------------------------
	Revision History
	----------------------------------------------------------------------------

	Date	   Author Synopsis
	---------- --- -------------------------------------------------------------
	2007/04/27 DAG/WW Created and tested original feature set.
	2007/06/22 DAG/WW Correct deficiencies in the internal documentation.
	----------------------------------------------------------------------------
	*/

    // Declare variables.

    var BlurryObjectValue ;

    // The Big Switch drives everything.

    //alert ( 'pActionCode = ' + pActionCode ) ;
    switch ( parseInt ( pActionCode ) ) {
        case 1 :
            // If CertificationState is National Registry, disable the state license fields.
            BlurryObjectValue = switchDom ( this , 'CertificationState' ).value ;
            //alert ( 'BlurryObjectValue = ' + BlurryObjectValue ) ;

            if ( BlurryObjectValue == 'NR' )
            {
                EnableControls('NationalRegistryID;NRReRegDate','text');
                switchDom (this,'NatRegChoice').checked = true;
                switchDom (this,'NatRegChoice').disabled = true;

                if ( !DisableControls ( 'LicenseRenewalDate;StateLicenseID' ) )
                {
                    alert ( 'Processing error 001 in JavaScript function TestFieldGroups - please contact EmCert, Inc.' ) ;
                }
            }
            else
            {
                switchDom (this,'NatRegChoice').disabled = false;

                if ( !EnableControls ( 'LicenseRenewalDate;StateLicenseID','text' ) )
                {
                    alert ( 'Processing error 002 in JavaScript function TestFieldGroups - please contact EmCert, Inc.' ) ;
                }
            }

            break ;

        case 2 :
            // If NationalRegistryID is blank, disable the corresponding renewal date field.
            BlurryObjectValue = switchDom ( this , 'NationalRegistryID' ).value ;

            if ( BlurryObjectValue == '' )
            {
                if ( !DisableControls ( 'NRReRegDate' ) ) {
                    alert ( 'Processing error 003 in JavaScript function TestFieldGroups - please contact EmCert, Inc.' ) ;
                }
            }
            else
            {
                if ( !EnableControls ( 'NRReRegDate' ) )
                {
                    alert ( 'Processing error 004 in JavaScript function TestFieldGroups - please contact EmCert, Inc.' ) ;
                }
            }

            break ;

        case 3 :
            if (switchDom (this,'NatRegChoice').checked)
            {
                EnableControls('NationalRegistryID;NRReRegDate','text');
            }
            else
            {
                DisableControls('NationalRegistryID;NRReRegDate');
            }

            break ;

        default :
            // EEK!
            alert ( 'Processing error 005 in JavaScript function TestFieldGroups - please contact EmCert, Inc.' ) ;
            return false ;
    }
    return true ;
}   // End of function TestFieldGroups ( pActionCode )
