var news = {
    del: function(newsId, img)
    {
        if (confirm('Продолжить?')) {
            var ajax = new leto.ajax('/ajaxadmin/delete/');
            ajax.onSuccess = function()
            {
                $(img).parent().parent().remove();
            }
            ajax.query({ id: newsId });
        }

        return false;
    }
}

$(document).ready(function(){
    $('div.news-item img').css('cursor', 'pointer').click(function(){

        if ('a' == $(this).parent().attr('tagName').toLowerCase() || $(this).hasClass('nobig')) {
            return true;
        }


        //var width = this.width;
        //alert([width, $(this).width()]);

        //var img = $(this).clone();
        //img.removeAttr('width').removeAttr('height').css({ width: "", height: "" });
        //var w = img.width();
        //var h = img.height();

        var w = $(this).width();// * 2;
        var h = $(this).height();// * 2;
        var left = ($(window).width() - w) / 2 + $(window).scrollLeft();
        var top = ($(window).height() - h) / 2+ $(window).scrollTop();
        if (top < 0) top = 0;
        if (left < 0) left = 0;

        var docH = $(window).height();

        $.blockUI({
            css: {
                top:  top  + 'px',
                left: left + 'px',
                border: 0,
                position: 'absolute',
                background: 'transparent',
                width: w + 'px',
                height: h + 'px'
            },
            overlayCSS: {
                opacity: .23
            },
            message: '<div id="block" style="background: none;" onclick="$.unblockUI(); $(this).remove();" style="cursor: pointer;" title="Нажмите, чтобы закрыть"></div>'
        });
        //$.blockUI({ , css: { top: m + 'px', backgroundColor: 'transparent', border: 0 } });
        $(this).clone()//.width(w).height(h)
        .appendTo('#block');
    });
});
