$(function () {

    var debug = false;
    var img_path = "images/template/"; // Set image path
    var img = "hed-past-dishes.gif"; // If you want a single image to display for all directories, set it here, e.g., "1.jpg"
    
    var protocol = jQuery.url.attr("protocol");
    var host = jQuery.url.attr("host");
    var path = jQuery.url.attr("path");
    if( path.indexOf("blog") != -1 && path.indexOf("page") != -1 )
    {
        // We know the URL is something like ".../blog/page/...", so add the image and bold the menu item...
        
        path = trim(path, "/");
        var dirs = path.split("/");
        var length = dirs.length;
        var num = dirs[length-1];
        var img = ( img ) ? img : num + '.jpg';
        var html = '<img class="generated" src="' + protocol + '://' + host + '/' + img_path + img + '" />';
        if( debug ) { alert(html); }

        // Attach the image HTML right inside the #rightcol div...
        $('#rightcol').prepend(html);
                
        // Bold "Past Dishes" menu item...
        $('ul li a').each( function() {
            if( $(this).attr('href') == '/_blog/Larchmont_Dish' )
            {
                $(this).parent().addClass('selected');
            }
        });
    }

});

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}