/* 
 * Underscript v.1.0
 * http://www.vaviloff.ru
 *
 * Copyright (c) 2010 Vlad Vaviloff
 *
 * Находит в указаном диапазоне изображения и оборачивает их в a.illustr
 * с описанием в span, которое берется из alt или title изображения
 *
 * $("#text img").undescript();
 *
 * Пример CSS:
 * -------------------------------
    a.illustr  {
        display:block;
        height:auto;
        margin:0 15px 10px 0;
        position:relative;
    }
    a.illustr span {
        background-color:#000000;
        bottom:2px;
        color:#E0E0E0;
        font-size:11px;
        left:0;
        opacity:0.7;
        padding:5px;
        position:absolute;
    }
 * -------------------------------
 */
(function($){
    $.fn.underscript = function(){
        imgs = this
        imgs.each(function(){
            img = this;

            if (img.title || img.alt) {
                text = img.title ? img.title : img.alt;
                float_dir = $(img).css('float') ? $(img).css('float') : 'left';
                $(img).css({'float': 'none', 'margin': 0, 'border': 0})
                    .wrap('<a href="#" class="illustr float'+float_dir+'"></a>')
                    .after('<span>'+text+'</span>')
                    .parent().css('cursor', 'default').click(function(){ return false});

            }
        })
    };

})(jQuery);




