
// -------------------------------------------------------------------
// MBi WebDB 2.1 (c) 1999-2001 MB-Interactive Online & Multimedia GmbH
// -------------------------------------------------------------------

function getRefVals(aNames, aVals)
{
	for(var i = 0; i < aNames.length; i++)
	{
		var oCheck = document.all[aNames[i]];
		aVals[i] = oCheck.checked;
	}
}

function setRefVals(aNames, aVals)
{
	for(var i = 0; i < aNames.length; i++)
	{
		var oCheck = document.all[aNames[i]];
		oCheck.checked = aVals[i];
	}
	NotifyChange();
}

function showCalendar(theTarget, thePage) {
    var sRtn;
    sRtn = showModalDialog(thePage,"","center=yes;dialogWidth=158px;dialogHeight=208px;status:no;help:no;scroll:no");
    if (sRtn!="") {
    	theValue = theTarget.value;
		i = theValue.indexOf(" ");
		if (i != -1) {
    		theTarget.value = sRtn + theValue.substr(i);
		}
		else {
    		theTarget.value = sRtn;
		}
		NotifyChange();
    }
}

function setStatus(aStatus)
{
	window.status = aStatus;
	return (true);
}

function logon(){
	if (WebSign)
	{
		return WebSign_Logon();
	}
	return true;
}

function logoff(){
	if (WebSign)
	{
		return WebSign_Logoff();
	}
	return true;
}

function prepare(document){
	if (WebSign)
	{
		return WebSign_Prepare(document);
	}
	return true;
}

function validUser(){
	if (WebSign)
	{
		return WebSign_ValidUser();
	}
	return true;	
}

function Action(theAction, theParam) 
{
    if (theAction)
   	{
        document.dbForm.dbAction.value = theAction;
        if (theParam)
        {
            document.dbForm.dbParam.value = theParam;
        }
		switch (theAction) 
		{
		   case 1: // Logon
				if (ValidateForm(document.dbForm))
					document.dbForm.submit();
				break;
		   case 2: // Logoff
				if ((ValidateForm(document.dbForm))&&(logoff()))
					document.dbForm.submit();
				break;
		   case 22: // OK
				if ((ValidateForm(document.dbForm))&&(prepare(document)))
					document.dbForm.submit();
				break;
		   case 30: // WebSign Logon
				if (logon())
					document.dbForm.submit();
				break;
		   case 17:		// Delete
				if ((confirm(ResString('js_confirmDelete')))&&(validUser()))
					document.dbForm.submit();
				break;
		   case 18:		// Delete permanent
				if ((confirm(ResString('js_confirmDeletePermanent')))&&(validUser()))
					document.dbForm.submit();
				break;
		   case 19:		// Undelete
				if ((confirm(ResString('js_confirmUndelete')))&&(validUser()))
					document.dbForm.submit();
				break;
		   case 27:
		   		showHelpWindow();
		   		break;
		   default:
				if ((DoConfirm('js_confirmCancel'))&&(validUser()))
					document.dbForm.submit();
				break;
		}
    }
}

setStatus(window.defaultStatus);