function _abririmagem(ficheiro, width, height) {
	newwindow = window.open(ficheiro, "miniatura", 'width='+ width +', height='+ height +', resizable=yes, scrollbars=no');
	newwindow.focus();
}

function _calculartotal(numprodutos) {
  var soma = 0; var quant = 0;
  var texto = "";
  for (var a = 1; a <= numprodutos; ++a) {
    texto = document.getElementById("preco_" + a);
    if (texto != null) {
      quant = parseInt(document.forms["formencomenda"].elements["quant_" + a].value);
      //alert("Label B at " + a + ": " + quant);
      if (isNaN(quant)) {
        quant = 0;
      }
      soma += parseFloat(texto.innerHTML.replace(",", ".")) * Math.round(quant);
      //alert("Produto " + a + " : " + texto + " | " + quant + " | " + soma);
    }
  }
  //alert("Label A: " + numprodutos);
  //alert("Label 0: " + soma);
  soma = soma.toFixed(2);
  //alert("Label 0 - 1: " + soma);
  somatexto = soma.toString();
  //alert("Label 1: " + somatexto);
  somatexto = somatexto.replace(".", ",");
  //alert("Label 2: " + somatexto);
  document.getElementById("preco_total").innerHTML = somatexto + " &euro;";
  document.forms["formencomenda"].precototal.value = somatexto + " Eur";
  document.getElementById("phpprecototal").value = somatexto + " Eur";
}

