﻿(function($) {
    $(function() {
        //what happens when you select a timezone from the list?
        $("select[name='time']").change(function() {
            $(this).parents('form').submit();
        });

        //delete links
        $("a.delete-link").click(function(e) {
            //stop the normal action
            e.preventDefault();

            if (!confirm("Are you sure you want to delete this item?"))
                return;

            //find the reference id (href="#referenceId")
            var id = $(this).attr('href').substring($(this).attr('href').indexOf('#') + 1);

            //find the related field (rel="#field_id")
            var field = $(this).attr('rel');

            //set value and submit
            $(field).val(id);
            $(field).parents('form').submit();
        });
    });

})(jQuery);