﻿/*
*
* This page keeps a list of common functions for forms.
*
* File : form_functions.asp
* 
* Creation:
*		djc 10/03/2002
*
* Modification
*     iii mm/dd/rrrr
*			[description of changes]
*
*
* Dependencies
*   form_functions.js
*/
var bPageModified = false;

/*
* This function will toggle a hidden field based on the value of a checkbox. 
*
*	params
*		prCheckbox - the checkbox that was checked
*		prHiddenField - the hidden field holding the checkbox value
*		psCheckedValue - the value if checked
*		psUncheckedValue - the value if unchecked
*/
function setHiddenCheckboxValue(prCheckbox, prHiddenField, psCheckedValue, psUncheckedValue) {
    if (prCheckbox.checked) {
        prHiddenField.value = psCheckedValue;
    } else {
        prHiddenField.value = psUncheckedValue;
    }
}

/*
* This function will mark a page as modified.
*
*	params
*		prHiddenField - the hidden field holding the modified flag.
*/
function markAsModified(prHiddenField) {
    if (!bPageModified) {
        prHiddenField.value = 1;
        bPageModified = true;
    }
}

/*
* This function will modify the sort order.
*
*	params
*		psSortValue - the new sort order value.
*		prHiddenSortOrderField - the hidden field holding the sort order.
*		prHiddenSortDirField - the hidden field holding the sort direction.
*/
function setSortOrder(psSortValue, prHiddenSortOrderField, prHiddenSortDirField) {
    if (prHiddenSortOrderField.value == psSortValue) {
        //
        // Sorting by the same field. Just switch the direction.
        //
        if (prHiddenSortDirField.value == "ASC") {
            prHiddenSortDirField.value = "DESC";
        } else {
            prHiddenSortDirField.value = "ASC";
        }
    } else {
        //
        // Sorting by a new field. Just mark the direction as ascending.
        //
        prHiddenSortOrderField.value = psSortValue;
        prHiddenSortDirField.value = "ASC";
    }
} 

