var count_lines = 0;
$(function() {
    $('#activ_add').live("click",function() {
        var root = homeurl;
        $("#addbox").html('<center><img src="'+root+'images/ajax-loader.gif" border="0" alt="Se incarca..." align="center"/></center>');
        $.ajax({
            type: "POST",
            url: root+'includes/ajax/select_produs.php',
            data: '',
            cache: false,
            success: function(html){
                $("#addbox").html(html);
                $("#addbox").css('padding', '10px');
            }
        });
        return false;
    });
    $('.del').live("click", function() {
        var linedel = $(this).attr('id');
        var line_id = linedel.replace('del', '');
        $("#line"+line_id).remove();
    });
    $('#sendbtn').live("click", function() {
        var nume = $('#nume').val();
        var prenume = $('#prenume').val();
        var firma = $('#firma').val();
        var cod_fiscal = $('#cod_fiscal').val();
        var telefon = $('#telefon').val();
        var email = $('#email').val();
        var localitate = $('#localitate').val();
        var errors = '';
        if (nume.length < 3) errors += 'Introduceti numele\n';
        if (prenume.length < 3) errors += 'Introduceti prenumele\n';
        if (firma.length < 3) errors += 'Introduceti numele societatii\n';
        if (cod_fiscal.length < 3) errors += 'Introduceti codul fiscal\n';
        if (telefon.length < 3) errors += 'Introduceti numarul de telefon\n';
        filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (!filter.test(email)) errors += 'Introduceti o adresa valida de email\n';
        if (localitate.length < 3) errors += 'Introduceti localitatea\n';
        if (errors.length > 0) {
            errors = 'Asigurati-va ca ati completat toate campurile obligatorii:\n\n' + errors;
            alert(errors);
        }
        else {
            $('#myfrm').submit();
        }
    });
});
// end function
