$(document).ready(function() {
    $("a.icon").livequery(function() {
        var icon;
        var parts = $(this).attr('href').split('/');
        var link = parts.length > 0 ? parts.pop() : undefined;
        
        if($(this).attr('icon'))
            $(this).prepend($("<img />").addClass("icon").attr("src", site.url + "/resources/icons/crystal/" + icon));
    });
    $(".action a, .action span").livequery(function(i, e){
        var icon;
        
        switch(true) {
            case $(this).text() == 'View':
                icon = "crystal/actions/demo.png";
            break;
            
            case $(this).text() == 'Download':
                icon = "crystal/actions/download.png";
            break;
            
            case $(this).text() == 'Edit':
                icon = "crystal/actions/db_update.png";
            break;
            
            case $(this).text() == 'Delete':
                icon = "db_remove.png";
            break;
            
            case $(this).text() == 'Search':
                icon = "perform_saved_search.png";
            break;
            
            case $(this).text() == 'Pay Now':
                icon = "pay_now.png";
            break;
            
            case $(this).text() == 'Notes':
                icon = "apps/knotes.png";
            break;
        }
        
        if(icon)
            $(this).html($("<img />").addClass("icon").attr("src", site.url + "/resources/icons/" + icon));
    });
});
