/*DONOTDEFER*/

var mainForm_onSubmitEvents = new Array();

/*------------------------------------------------------------------------------
 * mainForm_onSubmit
 *
 * Use this method when submitting the main form.  The submit handlers are 
 * designed to give you a chance to prepare the data (like update RTE's and
 * perform validation before the form is submitted).  If the event (use the
 * routine addSubmitEvent( STRING ) to add one) returns a false value, the
 * submit is canceled.
 *----------------------------------------------------------------------------*/

function mainForm_doSubmit() {

    var stopsubmit = false;

    for( i in mainForm_onSubmitEvents ) {

        var eventstat = eval( mainForm_onSubmitEvents[i] );

        if( typeof(eventstat) != 'undefined' ) {

            if( !eventstat ) stopsubmit = true;

        }

    }//for

    if( !stopsubmit ) document.mainForm.submit();

}//mainForm_onSubmit

/*------------------------------------------------------------------------------
 * addSubmitEvent
 *
 * Add a submit event for the mainForm.  An event is just a javascript method
 * (or code), as it is 'performed' by eval().
 *----------------------------------------------------------------------------*/

function addSubmitEvent( event ) {

    try {

        push( mainForm_onSubmitEvents, event );

    } catch( err ) {

        // Quiet

    }

}//addSubmitEvent

/**
 * submitWithValidation
 *
 * If the caller is created a function 'validateForm', make sure it returns
 * true before submitting the form.
 *
 */

function submitWithValidation() {

    if( defined( "validateForm" ) )
    {
        if( validateForm() )
        {
            mainForm_doSubmit();
        }
    }
    else
    {
        mainForm_doSubmit();
    }

}//submitWithValidation

/**
 * relay
 *
 * Keep the changes they made (but do not commit them) and display another page.
 *
 */

function relay( page, params ) {

    document.mainForm._action.value = "KeepData";
    document.mainForm._req_pageid.value = page;

    if( document.mainForm._req_params.value ) {
        document.mainForm._req_params.value += "&" + params;
    } else {
        document.mainForm._req_params.value = params;
    }

    mainForm_doSubmit();

}//relay

/**
 * action
 *
 * Keep the changes they made (but do not commit them), perform an action,
 * then redisplay this page.
 *
 */

function action( action, params ) {

    document.mainForm._action.value = "KeepData," + action;
    document.mainForm._req_pageid.value = document.mainForm._src_pageid.value;

    if( document.mainForm._req_params.value && params ) {

        document.mainForm._req_params.value += "&";

    }//if

    if( params ) {

        document.mainForm._req_params.value += params;

    }//if

    mainForm_doSubmit();

}//action

/**
 * view
 *
 * Carry out the form's action, then continue to the specified page.
 *
 */

function view( params ) {

    if( document.mainForm._req_params.value ) {
        document.mainForm._req_params.value += "&" + params;
    } else {
        document.mainForm._req_params.value = params;
    }

    mainForm_doSubmit();

}//view

/**
 * areyousure
 *
 * Go somewhere if they say yes
 */

function areyousure( message, url ) {
    
    if( confirm( message ) ) {

        document.location = url;

    }//if

}//areyousure
