//here you place the ids of every element you want.
var ids=new Array('divPJ', 'divPF', 'hidePJ', 'hidePF');

function switchid(id){
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}
}

function hideallidsfor(arrID){
	//loop through the array and hide each element by id
	for (var i=0;i<arrID.length;i++){
		hidediv(arrID[i]);
	}
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.SPD_TCLIENTESFRM.NQTLICENCAS.value;
  two = document.SPD_TCLIENTESFRM.NVALORPROD.value;
  document.SPD_TCLIENTESFRM.NVALORPRODJS.value = CurrencyFormatted((one * 1) * (two * 1));
  document.SPD_TCLIENTESFRM.NVALORPARCELAJS.value = CurrencyFormatted((document.SPD_TCLIENTESFRM.NVALORPRODJS.value * 1) / (3));
}
function stopCalc(){
  clearInterval(interval);
}
function showParcela(){
  showdiv('divParcela');
  document.SPD_TCLIENTESFRM.NVALORPARCELAJS.value = CurrencyFormatted((document.SPD_TCLIENTESFRM.NVALORPRODJS.value * 1) / (3));
}
function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}