function atualizaTotal() {			
	var valores = document.getElementsByTagName("input");
	var subtotal = 0;
	var valorTotal = 0;
	
	for (i = 0; i < valores.length; i++) {
		input = valores[i];
		subtotal = 0;
		
		if (input.name.indexOf("valor") >= 0) {
			var id = input.name.replace("valor", "");
			if (input.value.length > 0) {
				var q = document.getElementById('quantidade'+id).value;
				if (q.length > 0) {
					subtotal = parseFloat(input.value * q);
					valorTotal += subtotal;					
					nfSub = new NumberFormat(subtotal);
					nfSub.setSeparators(true, ".", ",");
					subtotalFormatado = nfSub.toFormatted();
					document.getElementById('subtotal'+id).innerHTML = subtotalFormatado;
				} else {
					document.getElementById('subtotal'+id).innerHTML = " - ";
				}
			}			
		} 
	}
	nfTotal = new NumberFormat(valorTotal);
    nfTotal.setSeparators(true, ".", ",");
    totalFormatado = nfTotal.toFormatted();
	document.getElementById("celulaSubTotal").innerHTML = totalFormatado;
	
	valorTotal += parseFloat(document.getElementById('frete').value);
	nfTotal = new NumberFormat(valorTotal);
	nfTotal.setSeparators(true, ".", ",");
	totalFormatado = nfTotal.toFormatted();
		
	document.getElementById("celulaTotal").innerHTML = "<strong>"+totalFormatado+"</strong>";	
	document.getElementById("totalCompra").value = valorTotal;	
}

function fecharCompra() {
	document.formCarrinho1.acao.value = "fecharCompra";
	document.formCarrinho1.submit();
}

function continuarComprando() {
	document.formCarrinho1.acao.value = "continuarComprando";
	document.formCarrinho1.submit();
}

function excluirProduto(idProduto) {
	document.formCarrinho1.acao.value = "excluirProduto";
	document.getElementById("idProduto").value = idProduto;
	document.formCarrinho1.submit();
}

function limparCarrinho() {
    document.formCarrinho1.acao.value = "limparCarrinho";    
    document.formCarrinho1.submit();
}

function mudaClasse(idInput) {
	var quantidades = document.getElementsByTagName("input");	
	
	for (i = 0; i < quantidades.length; i++) {
		input = quantidades[i];
		
		if (input.name.indexOf("quantidade") >= 0) {
			if (input.value.length > 0) {
				input.className = "input_prod";
			}			
		} 
	}
	document.getElementById(idInput).className = "input_prod_hover";
}

function verificaLogin() {
    login = document.getElementById("login");
    senha = document.getElementById("senha");
    
    if (!isEmail(login.value)) {
        alert("Informe um login válido!");
        login.focus();
        return false;
    }
    
    if (senha.value == "") {
        alert("Preencha o campo senha!");
        senha.focus();
        return false;
    }
    
    return true;
}

