$(document).ready(function() {
    $("form[enter=0]").bind("keypress", function(e) {
         if (e.keyCode == 13) {
             return false;
         }
    }); 
});


function inputs_check(form) {
    var submit_ok = true;
    
    $("input, textarea", form).each(function() {
        $(this).trigger('inputs_reset');
        check = $(this).attr('check');
       
        if (typeof check !== 'undefined' && check != '') {
            try {
                if (!eval(check)) {
                    $(this).addClass('error');
                    $(this).trigger('inputs_error');
                    submit_ok = false;
                }
            } catch (e) {
            }
        }
    }); 
    
    return submit_ok;
}

function inputs_checklist(chk, name, sep) {
    input = $("[name=" + name + "]");
    if (input.val() != "")
        vals = input.val().split(sep); else
        vals = [];
        
    val = chk.val();

    if (chk.is(":checked")) 
        vals.push(val); else
        vals.splice(indexOf(val), 1);

    vals.sort();
    input.val(vals.join(sep));
}

function inputs_post(form) {
    var post = {};
    $("input, textarea", form).each(function() {
        if ($(this).attr('type') == 'checkbox') 
            post[$(this).attr('name')] = $(this).is(":checked"); else
            post[$(this).attr('name')] = $(this).val();       
    });
    
    return post;
}
