// Navigation toolbar client-side scripting

function navGetParam(uidTable, sParam)
{
	// return navigation form object for table
	var sElementName = 'TBFX_' + uidTable + '_' + sParam;
	
	return document.getElementById(sElementName);
}

function navGotoPageAccel(uidTable)
{
	if (event.keyCode == 13) 
	{
		event.returnValue = false;
		navPageMoveTo(uidTable);
	}
}

function navPageMoveTo(uidTable)
{
	
	var oPageIndex = navGetParam(uidTable, 'PAGEINDEX');
	var oPageGoto = navGetParam(uidTable, 'GOTOPAGE');
	var oForm = oPageIndex.form;

	// set it
	oPageIndex.value = oPageGoto.value;
	oForm.submit();
}

function navPageMoveToIndex(uidTable, nIndex)
{
	var oPageIndex = navGetParam(uidTable, 'PAGEINDEX');
	var oForm = oPageIndex.form;

	// set it
	oPageIndex.value = nIndex;
	oForm.submit();		
}
/*
GABRIELE TORTORA
Controllo che il valore inserito si un numero
e che sia maggiore uguale di numMin e minore uguale numMax

Questa funzione è utile per le date quando si verificano in campi
distini il gg, mm e aaaa
*/
function controlloData(numMin, numMax, campo)
{
	try
	{
		if (campo.value == "")
			return;

		//Verifico che si un numero
		if (isNaN(campo.value))
		{
			alert("Il valore inserito non è un numero"); 
			campo.value = "";
			//campo.focus();
			return;
		}
		//Controllo che sia nell'intervallo corretto
		if ((campo.value > numMax) || (campo.value < numMin))
		{
			alert("Il valore inserito non è valido"); 
			campo.value = "";
			//campo.focus( );
			return;
		}

		//Il mese e il giorno devo sempre essere di due cifre..
		//L'anno non passa mai da qui in quanto è di 4 e controllo intervallo
		if (campo.value.length == 1)
				campo.value = "0" + campo.value

	}
	catch(er)	
	{
		campo.value = "";
		return;
	}
}
