function finalizarCompra(form){
    if(form.peso_total.value < 30){
        form.finalizar.disabled = true;
        form.atualizar.disabled = true;
        document.getElementById("carrinho-dados").style.display = 'block';
    } else {
        alert("O peso máximo para envio é de 30kg, retire alguns itens de seu carrinho.");
    }
}

function getContinuarComprando(){
    document.getElementById("finalizar").disabled = false;
    document.getElementById("atualizar").disabled = false;
    document.getElementById("carrinho-dados").style.display = 'none';
}

function removerProdutoCarrinho(form, id){
    if(confirm('Deseja remover este item do seu carrinho ?')){
        form.remover_item.value = id;
        form.target = '_self'
        form.action = '/validar/remover_carrinho.php';
        form.submit();
    }
    return false;
}

function getCampos(form){
    var campo = "nome="+form.cliente_nome.value+"&cep="+form.cliente_cep.value+"&end="+form.cliente_end.value+
                "&num="+form.cliente_num.value+"&bairro="+form.cliente_bairro.value+"&cidade="+form.cliente_cidade.value+
                "&uf="+form.cliente_uf.value+"&ddd="+form.cliente_ddd.value+"&tel="+form.cliente_tel.value+
                "&email="+form.cliente_email.value;
                
    return campo;
} 

function calcularFrete(form) {
    if(form.cliente_cep.value.length > 0){
        form.target = '_self'
        form.action = '/validar/calcular_frete.php';
        form.submit();
    } else {
        alert("Complete o CEP antes de fazer o cálculo");
    }
}

function setAtualizaCarrinho(form) {
    form.target = '_self'
    form.action = '/validar/atualizar_carrinho.php';
    form.submit();
}

function verificaAdicionarCarrinho(form){
    if(form.id.value == '1251'){
        return true;
    }
    
    var radio_choice = false;
    for (counter = 0; counter < form.tamanho.length; counter++) {
        if (form.tamanho[counter].checked){
            radio_choice = true; 
        }
    }

    if (!radio_choice) {
        alert("Você não escolheu o tamanho do produto.");
        return false;
    }
    return true;
}

function mostraDiv(div){
    document.getElementById("carrinho-dados").style.display = 'none';
    document.getElementById("banco-dados").style.display = 'none';
    document.getElementById("sitepoker-dados").style.display = 'none';
    document.getElementById(div).style.display = 'block';
}

function trocaValor(item){
    if(item.value == 1){
        document.getElementById('item_valor_1').value = '212.80';
        document.getElementById('item_descr_1').value = '2ª Estapa Ribeirão Poker Tour - Main Event (R$212,80) - 07 de Maio de 2011';
    } else if(item.value == 2){
        document.getElementById('item_valor_1').value = '510.72';
        document.getElementById('item_descr_1').value = '2ª Estapa Ribeirão Poker Tour - High Roller (R$510,72) - 06 de Maio de 2011';
    } 
}

