$(document).ready(function(){
    switch ($("#add-item input[name=honor_or_memory]:radio:checked").val()){
        case "honor":
            $("#honor-set").show();
            break;
        case "memory":
            $("#memory-set").show();
            break;
    }

    $("#add-item input[name=honor_or_memory]:radio").click(function(){

        switch (this.value){
            case "none":
                $("#memory-set").hide();
                $("#honor-set").hide();
                break;
            case "honor":
                $("#memory-set").hide();
                $("#honor-set").show();
                break;
            case "memory":
                $("#honor-set").hide();
                $("#memory-set").show();
                break;
        }
    });

    $(".submit").click(function(){
        var content = ""

        switch ($("#add-item input[name=honor_or_memory]:radio:checked").val()){  
            case "honor":
                content = "In Honor of \n"
                $("#honor-set :input").each(function(i){
                    content += this.name + ": " + this.value + "\n";     
                });
                $("#memory_of").val(content);
                break;
            case "memory":
                content = "In Memory of \n"
                $("#memory-set :input").each(function(i){
                    content += this.name + ": " + this.value + "\n";
                });
                $("#memory_of").val(content);
                break;
        }
    });
});