function controllo_campo_numerico(campo){
var a=parseInt(campo.value,10)+"";
	if (a!=campo.value) {
		if (('0'+a)!=campo.value) campo.value=campo.value.substr(0,campo.value.length-1);
	}
}
function controllo_campo_decimale(campo){

var a=parseFloat(campo.value,10)+"";
	if (a!=campo.value) {
		if (('0'+a)!=campo.value && (a+'.')!=campo.value) campo.value=campo.value.substr(0,campo.value.length-1);
	}
	
}
function fine_inserimento(campo1,max,campo2){
	if (campo1.value.length==max) campo2.focus();
}
function calcola(potenza,attenuazione,oggetto){
	p=parseFloat(potenza);
	a=parseFloat(attenuazione);
	
	if (p>0 && a>=0){
		pout=Math.round(p/Math.pow(10,(a/10))*1000)/1000
		perdita=Math.round((potenza-pout)*1000)/1000;
		
		stringa="Power out "+pout+" Watt &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Power loss "+perdita+" Watt";
	} else 		stringa="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"

	if (navigator.appName.indexOf("Microsoft")!=-1)
			oggetto.innerHTML=stringa;
}
function calcolaat(potenza,oggetto){
	p=parseFloat(potenza);
	if (p>0){
		pout=(0.1e-6/p)
		pout=Math.abs(Math.round(10*(Math.log(pout)/Math.log(10))*1000)/1000);
		stringa="Attenuation "+pout+" db &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp";
	} else 		stringa="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"

	if (navigator.appName.indexOf("Microsoft")!=-1)
			oggetto.innerHTML=stringa;
}
/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 * @param   object   the background color
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // end of the 'setPointer()' function

