$.fn.findPos = function()
{
    obj = jQuery(this).get(0);
    var curleft = obj.offsetLeft || 0;
    var curtop = obj.offsetTop || 0;
    while (obj = obj.offsetParent)
    {
        curleft += obj.offsetLeft
        curtop += obj.offsetTop
    }
    return { x: curleft, y: curtop };
};

$.fn.loadingOverlay = function()
{
    pos = $(this).findPos();

    $(this).append('<div class="loading" style="height:'
        + $(this).innerHeight()
        + 'px;width:' + ($(this).innerWidth() - 25) + 'px;'
        + 'top:'
        + pos.y
        + 'px;left:'
        + pos.x
        + ';"><img src="Content/Images/Icons/loading.gif" /></div>');

    $(this).find('.loading').css({ opacity: '0.6' });

};
