(function($){
    $.fn.ConfirmWizard = function(trail_id, trail_name)
    {
        var wizard = new wizardMaker(this);

        wizard.setData('other_confirm', {'trail_name' : trail_name});

        wizard.addSlide('other_confirm');
        wizard.setInitialSlide('other_confirm');
        wizard.setSlideOptions('other_confirm', {
            'action' : 'slides/other_confirm',
            'width' : 300,
            'height' : 200,
            'onLoad' : otherConfirmLoad,
            'dataNeeded' : 'other_confirm'
        });

/*********************************LOADS*******************************************************/

       function otherConfirmLoad()
       {
            $('#wizard_confirm .no').click(function(){
				$('#fancy_close').click();
            });

            $('#wizard_confirm .yes').click(function(){

                var selected = [];
                var deselected = [trail_id];

                $.post(absoluteFilepath('actions/addSurveyTrails'),
                {'selected_trails' : $.toJSON(selected),
                 'deselected_trails' : $.toJSON(deselected)
                });


                $('#user_trails .trail[trail_id="' + trail_id + '"]').parent().remove();

                if( !$('#user_trails .trail').get(0) )
                {
                    $.post(absoluteFilepath('user_trails/trails_subview'),
                       {},
                       function(results){
                           $('#user_trails .trail_list').html(results);
                           add_trail_listeners();
                       });
                }

                $('#fancy_close').click();
            });
       }

/*********************************FUNCTIONS*******************************************************/

    }
})(jQuery);



