/*
* Логинов Андрей Вячеславович
* "SaT" (Site a template) version 0.1
* 19 апреля 2011 г.
* 4. bgSize - css3 свойство background-size
*/




(function($){
    $.fn.bgsize = function(opts4) {
        var element = this;
        var options4 = {
            imgsrc: './img/bgsize.png',
            hoversrc: false,
            imgborder: './img/border.gif'
        };
        options4 = $.extend(options4,opts4);
        var imgwidth = $(element).outerWidth(),
        img = $("<img class='imghov' src='" + options4.imgsrc + "' alt='' style='width: "+imgwidth+"px; height: 40px; position: absolute; text-align: left; top: 1px; left: auto; z-index: 150' />");
        if(!options4.hoversrc) {
            $(element).mouseover(function(){
                if($('img.imghov',this).length == 0){
                    img.prependTo($(this));
                    imgwidth = ($(this).outerWidth() - 3);
                    img.css({
                        'width': imgwidth, 
                        'margin-left': '2px'
                    });
                    $(this).css('background-color','#31932D');
                }
            });
            $(element).mouseleave(function(){
                $(this).css('background','url('+options4.imgborder+') no-repeat 0 1px');
                $('img.imghov',this).remove();
            });
        } else {
            if($('img.imghov',element).length == 0){
                img.prependTo($(element));
                imgwidth = ($(element).outerWidth() - 3);
                img.css({
                    'width': imgwidth, 
                    'margin-left': '2px'
                });
                $(element).css('background-color','#31932D');
            }
        }
    }
})(jQuery);
