function criaCampo(frm){
    var cont = frm.contCampo.value;
    var tbody = document.createElement("TBODY");
        tbody.setAttribute("id","Campo"+cont);
    var linha = document.createElement("tr");      
    var col1 = document.createElement("td");
        col1.setAttribute("id","col1_"+cont);
    var col2 = document.createElement("td");
        col2.setAttribute("id","col2_"+cont);
        col2.setAttribute("style","text-align:center");
    var col3 = document.createElement("td");
        col3.setAttribute("id","col3_"+cont);
        col3.setAttribute("style","text-align:center");
    var col4 = document.createElement("td");
        col4.setAttribute("id","col4_"+cont);
        col4.setAttribute("style","text-align:center");
    var col5 = document.createElement("td");
        col5.setAttribute("id","col5_"+cont);
        col5.setAttribute("style","text-align:center");
    var alvo = document.getElementById("CalculoQtdeSal");
    
    var eBody = document.getElementsByTagName("body");
    
    //CRIA O CAMPO Alimento
    var alimento = document.createElement("input");
        alimento.setAttribute("type", "text"); 
        alimento.setAttribute("name", "Alimento[]");
        alimento.setAttribute("id", "Alimento");
        alimento.setAttribute("value", "");
        if(navigator.userAgent.indexOf('MSIE') <= -1){
            alimento.setAttribute("class", "input_normal"); 
            alimento.setAttribute("maxlength", "100");
            alimento.setAttribute("size", "30");
        }
    col1.appendChild(alimento);
    
    //CRIA O CAMPO Porcao
    var porcao = document.createElement("input");
        porcao.setAttribute("type", "text"); 
        porcao.setAttribute("name", "Porcao[]");
        porcao.setAttribute("id", "Porcao");
        porcao.setAttribute("value", "");
        if(navigator.userAgent.indexOf('MSIE') > -1){
            porcao.attachEvent("onkeypress", function(){ return keyRestrict(event,'1234567890'); });
        }
        else{
            porcao.setAttribute("class", "input_normal"); 
            porcao.setAttribute("maxlength", "3");
            porcao.setAttribute("size", "3");
            porcao.setAttribute("style", "text-align:center;");
            porcao.setAttribute("onkeypress", "return keyRestrict(event,'1234567890')");
        }
    col2.appendChild(porcao);
    
    //CRIA O CAMPO QtdeSodio
    var qtdeSodio = document.createElement("input");
        qtdeSodio.setAttribute("type", "text"); 
        qtdeSodio.setAttribute("name", "QtdeSodio[]");
        qtdeSodio.setAttribute("id", "QtdeSodio");
        qtdeSodio.setAttribute("value", "");
        if(navigator.userAgent.indexOf('MSIE') > -1){
            qtdeSodio.attachEvent("onkeypress", function(){ return keyRestrict(event,'1234567890'); });
        }
        else{
            qtdeSodio.setAttribute("class", "input_normal"); 
            qtdeSodio.setAttribute("maxlength", "4");
            qtdeSodio.setAttribute("size", "4");
            qtdeSodio.setAttribute("style", "text-align:center;");
            qtdeSodio.setAttribute("onkeypress", "return keyRestrict(event,'1234567890')");
        }
    col3.appendChild(qtdeSodio);
    
    //CRIA O CAMPO QtdeEmbalagem
    var qtdeEmbalagem = document.createElement("input");
        qtdeEmbalagem.setAttribute("type", "text"); 
        qtdeEmbalagem.setAttribute("name", "QtdeEmbalagem[]");
        qtdeEmbalagem.setAttribute("id", "QtdeEmbalagem");
        qtdeEmbalagem.setAttribute("value", "");
        if(navigator.userAgent.indexOf('MSIE') > -1){
            qtdeEmbalagem.attachEvent("onkeypress", function(){ return keyRestrict(event,'1234567890'); });
        }
        else{
            qtdeEmbalagem.setAttribute("class", "input_normal"); 
            qtdeEmbalagem.setAttribute("maxlength", "4");
            qtdeEmbalagem.setAttribute("size", "4");
            qtdeEmbalagem.setAttribute("style", "text-align:center;");
            qtdeEmbalagem.setAttribute("onkeypress", "return keyRestrict(event,'1234567890')");
        } 
    col4.appendChild(qtdeEmbalagem);
    
    //CRIA O CAMPO Remover
    var remover = document.createElement("input");
        remover.setAttribute("type", "button");
        remover.setAttribute("name", "REMOVER[]");
        remover.setAttribute("id", "REMOVER");
        remover.setAttribute("value", "Remover");
        if(navigator.userAgent.indexOf('MSIE') > -1){
            var campoRemove = cont;
            remover.attachEvent("onclick", function(){ removeCampo( campoRemove ); });
        }
        else{
            remover.setAttribute("class", "Campos input_normal"); 
            remover.setAttribute("onclick", "javascript:removeCampo("+cont+");");
        }   
    col5.appendChild(remover);
       
    linha.appendChild(col1);
    linha.appendChild(col2);    
    linha.appendChild(col3);    
    linha.appendChild(col4);    
    linha.appendChild(col5);
    tbody.appendChild(linha);
    alvo.appendChild(tbody);
        
    for(i = 0; i <= cont; i++){
        if(document.getElementById('col1_'+i) != null){
            document.getElementById('col1_'+i).className = 'tb';   
            document.getElementById('col2_'+i).className = 'tb';   
            document.getElementById('col2_'+i).align = 'center';  
            document.getElementById('col3_'+i).className = 'tb';  
            document.getElementById('col3_'+i).align = 'center';    
            document.getElementById('col4_'+i).className = 'tb';  
            document.getElementById('col4_'+i).align = 'center';
            document.getElementById('col5_'+i).className = 'tb';  
            document.getElementById('col5_'+i).align = 'center';
        }
    }
    
    if(navigator.userAgent.indexOf('MSIE') > -1){   
        
        for(i = 1; i < frm.Alimento.length; i++){
            frm.Alimento[i].className           = 'input_normal';
            frm.Alimento[i].maxLength           = 100;
            frm.Alimento[i].size                = 30;
            
            frm.Porcao[i].className             = 'input_normal';
            frm.Porcao[i].style.cssText         = 'text-align:center';
            frm.Porcao[i].maxLength             = 3;
            frm.Porcao[i].size                  = 3;
            
            frm.QtdeSodio[i].className          = 'input_normal';
            frm.QtdeSodio[i].style.cssText      = 'text-align:center';
            frm.QtdeSodio[i].maxLength          = 4;
            frm.QtdeSodio[i].size               = 4;
            
            frm.QtdeEmbalagem[i].className      = 'input_normal';
            frm.QtdeEmbalagem[i].style.cssText  = 'text-align:center';
            frm.QtdeEmbalagem[i].maxLength      = 4;
            frm.QtdeEmbalagem[i].size           = 4;
        }
        
        if(frm.REMOVER.length > 0){
            
            for(i = 1; i < frm.REMOVER.length; i++){
                frm.REMOVER[i].className  = 'Campos input_normal';
            }
        }
        else{
            frm.REMOVER.className  = 'Campos input_normal';
        }
    }

    cont = parseInt(cont);
    cont = cont+1;
    frm.contCampo.value = cont;
}
function removeCampo(tbody){
    var alvo = document.getElementById('CalculoQtdeSal');
    var oldtbody = document.getElementById('Campo'+tbody);
    alvo.removeChild(oldtbody);
}
