//////////////////////////////////////////////////
function getCurrency(getCurrencyNum,getCurrencyDec,getCurrencySmig,getCurrencySdec)
//////////////////////////////////////////////////
// Variabili:	getCurrencyNum=Valore
//				getCurrencyDec=Numero decimali
//				getCurrencySmig=Separatore migliaia
//				getCurrencySDec=Separatore decimali
		{
		if(isNaN(getCurrencyNum)) getCurrencyNum = "0";
		var sign = (getCurrencyNum == (getCurrencyNum = Math.abs(getCurrencyNum)));
		var i=0
		if (getCurrencyDec==0)
			{
			cents=''
			}
		else
			{
			var espo = 10
			for (i = 1; i < getCurrencyDec; i++)
				{
				espo=espo*10
				}
			cents = Math.round((getCurrencyNum%1)*espo);
		while (cents>=espo)
			{
			cents=Math.floor(cents-espo)
			getCurrencyNum=getCurrencyNum+1
			}
		while (String(cents).length < getCurrencyDec) cents='0'+cents
			}
		getCurrencyNum = Math.floor(getCurrencyNum).toString();
		for (i = 0; i < Math.floor((getCurrencyNum.length-(1+i))/3); i++)
			{
			getCurrencyNum = getCurrencyNum.substring(0,getCurrencyNum.length-(4*i+3))+getCurrencySmig+ getCurrencyNum.substring(getCurrencyNum.length-(4*i+3));
			}
		return (((sign)?' ':'-') + getCurrencyNum + getCurrencySdec + cents);
		}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
return sString;
}


function isNumber(field)
{
  var perm = /[\9\16\17\18\35\36\37\38\39\40]/;
//	if (perm.test(event.keyCode))
//	{
//		if (field.value.indexOf('.')!=-1)
//		{
//			field.value = getReplace(field.value,'.',',');
//		}
		var re = /^[0-9-'.'-',']*$/;
		if (!re.test(field.value))
		{
			alert('Il valore di questo campo deve essere numerico!');
			field.value = field.value.replace(/[^0-9-',']/g,'');
  	}
//	}
}

function disableForm(frm) 
{
	var limit = document.forms[frm].elements.length;
	for (i=0;i<limit;i++) 
	{
	  document.forms[frm].elements[i].disabled = true;
	}
}

function Mid(str, start, len)
{
    if (start < 0 || len < 0) return '';
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}
