/*
$HeadURL: svn+secure://svn.comminternet.com/main/websites/dennisoysters.com/trunk/web/common/framework/javascript/DatabaseForm.js $
$LastChangedRevision: 6658 $
$LastChangedDate: 2009-07-23 10:42:15 -0400 (Thu, 23 Jul 2009) $
*/

function __CX_DatabaseForm_SetPageAction(pForm, pPageAction, pFieldIndex, pArgument)
{
    if (typeof(pArgument) != "undefined")
	pForm.__CX_Form_argument.value = pArgument;

    __CX_Form_SetPageAction(pForm, pPageAction, pFieldIndex);
}

/*
function __CX_DatabaseForm_CheckAll(pCheckboxes, pCheckState)
{
    var loopCondition;

    if (typeof(pCheckboxes) == "undefined")
	loopCondition = 0;
    else if (typeof(pCheckboxes.length) == "undefined") {
	// If there is only one checkbox, checkboxes will contain a single
	// checkbox object rather than a collection of checkboxes, and thus
	// there will be no length property.
	pCheckboxes.checked = pCheckState;
	return;
    } else
	loopCondition = pCheckboxes.length;

    for (var i = 0; i < loopCondition; ++i)
	pCheckboxes[i].checked = pCheckState;
}

function __CX_DatabaseForm_OnSubmit(pForm, pCheckboxName)
{
    var fPerformSubmit = true;

    switch(pForm.__CX_Form_pageAction.value)
    {
	case "FormSubtableDelete":

	    var fRowsSelected = false;

	    if (pForm.__CX_Form_argument.value)
		fRowsSelected = true;
	    else {
		var checkboxes = pForm.elements["__CX_SubtableForm_" + pForm.__CX_Form_fieldIndex.value + "_rows[]"];
		var loopCondition;

		if (typeof(checkboxes) == "undefined")
		    loopCondition = 0;
		else if (typeof(checkboxes.length) == "undefined") {
		    loopCondition = 0;
		    fRowsSelected = checkboxes.checked;
		} else
		    loopCondition = checkboxes.length;

		for (var i = 0; i < loopCondition; ++i)
		{
		    if (checkboxes[i].checked == true)
		    {
			fRowsSelected = true;
			break;
		    }
		}
	    }

	    if (!fRowsSelected)
	    {
		alert("In order to delete a record, you must first check it in the list. Please select a record to delete and then click the Delete button.");
		return false;
	    }

	    fPerformSubmit = confirm("Are you sure that you want to delete the selected records? You will not be able to undo this operation.");

	    break;

	default:

	    fPerformSubmit = __CX_Form_OnSubmit(pForm);
	    break;
    }

    return fPerformSubmit;
}
*/
