$(function() {
//if closeaftersave defined - close form
if ($('#closeaftersave').val() == 'true') self.close();
    
//validate form first time to initialize validator
$('.validate').validate({ ignore: '.ignore' });
$('.validate input').keydown(function(e) { if (e.keyCode == 13) { formchanged = true; return false; } });
    
       
    $('#fieldtypeid').change(function() {
        if (this.value == 5) {
            $('#cvfield').show();
            $('#cvfield textarea').addClass('required');
        }
        else {
            $('#cvfield').hide();
            $('#cvfield textarea').removeClass('required');
        }
    });

    $('form').validate();
});


function afterSave() {    
    opener.loadFields(true);
}