$(document).ready(function(){
    $('a[rel="delete"]').click(function(){
        if (confirm("Are you sure you want to do this? Any associated information will be lost.")) {
            return true;
        }
        return false;
    });
    
    $('a[rel="external"]').click(function(){
        window.open(this.href);
        return false;
    });
    
    $('a[rel="submission"]').click(function(){
        if (confirm("Are you sure you want to do this? Any submissions will be considered final and locked from user modification.")) {
            return true;
        }
        return false;
    });
    
    $('a[rel="confirm"]').click(function(){
        if (confirm("Are you sure you want to do this?")) {
            return true;
        }
        return false;
    });
    
    $('a[rel="none"]').click(function(){
        return false;
    });
    
    $('a.button').tooltip({ 
        bodyHandler: function() { 
            if ($(this).children("img:first").attr("alt")) {
                return $(this).children("img:first").attr("alt");
            } else {
                return $(this).text();
            }
        }, 
        showURL: false
    });
    
    $('.submitOnChange').change(function() { 
        $(this).parent().get(0).submit();
    });
});