// JavaScript Document
function RTrim( stringa ) {
	while ( stringa.charAt ( (stringa.length -1) ) == " " ) {
	stringa = stringa.substring ( 0,stringa.length-1 );
	}
	return stringa;
}

function LTrim ( stringa ) {
	while ( stringa.charAt(0) == " " ) {
		stringa = stringa.replace ( stringa.charAt(0),"" );
	}
	return stringa;
}

function Trim( stringa ) {
	stringa = LTrim ( stringa );
	return RTrim ( stringa );
}

function SommaA (idcampo,idcampo2,quantita) {
	var valore =  parseInt(prendiElementoDaId(idcampo2).value) + parseInt(quantita);;
	prendiElementoDaId(idcampo2).value = parseInt(valore); 
	prendiElementoDaId(idcampo).innerHTML = prendiElementoDaId(idcampo2).value;
}
function SommaB (idcampo,quantita) {
	prendiElementoDaId(idcampo).value = parseFloat(prendiElementoDaId(idcampo).value) + quantita;
}

 /*
 function Somma (idcampo,quantita) {
	prendiElementoDaId(idcampo).value = parseFloat(prendiElementoDaId(idcampo).value) + quantita;
}
*/
function countItems(myString,myChar)
{
	var itemCount=myString.split(myChar).length;
	return itemCount-1;
}

function cambiaStato(id) {
	if ( document.getElementById(id) ) {
		if ( document.getElementById(id).style.display == 'none' ) {
			document.getElementById(id).style.display = 'block';
		} else {
			document.getElementById(id).style.display = 'none';
		}
	}
}

function caricaContenutoDiv (da,a) {
	if ( document.getElementById ( da ) && document.getElementById ( a ) ) {
		if ( document.getElementById ( da ).innerHTML != "" )
			document.getElementById(a).innerHTML=document.getElementById(da).innerHTML;
	}
}

function mostraNews ( idNews ) {
	var numero = document.getElementById ( "newsNumero"+idNews ).value;
	document.getElementById ( "newsMostra" ).innerHTML = document.getElementById ( "newsText"+numero ).innerHTML;
//	document.getElementById ( "newsAttuale" ).value = idNews;
}


