// CMC Certificate for anon user. The placeholder value will be removed when a user focuses on the input box,
// the second part will take the users input and add it the document so it formats nicely
// for printing and the last allows the user to edit their name in case they mistyped it
$(function(){
    
    $('#certificate_name_field').show();
    $('#certificate_name_field_clear').hide();
    $('#edit_name_link').hide();
    
    $('#certificate_name_field').focus(function() {
        $(this).hide();
        $('#certificate_name_field_clear').show();
        $('#certificate_name_field_clear').focus();
    });

    $('#certificate_name_field_clear').blur(function() {
        if($(this).val() == '') {
            $('#certificate_name_field').show();
            $(this).hide();
        }
        else {
            certName = $(this).val(); 
            $(this).hide();
            $('#name_for_print').text(certName).show();
            $('#edit_name_link').show();
        }
    });

    $('#show_name_field').click(function() {
        $('#name_for_print').hide();
        $('#certificate_name_field_clear').val(certName).show();    
    });
});

