$(document).ready(function() {
    $(this).run();
});

jQuery.fn.run = function() {

    var context = this;
    
    $.ifixpng('/v2/img/blank.gif');
    $('*', this).ifixpng();
    
    $('.focus-blur', context).each(function() {
        $(this).attr('default', $(this).val());
        $(this).bind('focus',function() {
            if ($(this).val() == $(this).attr('default')) {
                $(this).val('');
            }
        });
        $(this).bind('blur',function() {
            if ($(this).val() == '') {
                $(this).val($(this).attr('default'));
            }
        });
    });
    
    $('.form-submit', context).click(function() {
        $(this).parents('form').submit();
        return false;
    });
    
    $('#right-doc .ajax a', context).click(function() {
        $('#right-doc').load($(this).attr('href') + ' #right-doc', function() {
            $(this).run();
        });
        return false;
    });
    
    $('#right-law .ajax a', context).click(function() {
        $('#right-law').load($(this).attr('href') + ' #right-law', function() {
            $(this).run();
        });
        return false;
    });
    
    $('#favourite').click(function(e) {
        title = $(document).attr('title');
        url = $(window).attr('location');
        if (window.sidebar && window.sidebar.addPanel) {
            window.sidebar.addPanel(title, url, "");
        }
        else if (window.external && window.external.AddFavorite) {
            window.external.AddFavorite(url, title);
        }
        else if (window.opera && window.print) {
            return false;
        }
        return false;
    });
    
    $('#home').click(function(e) {
        if ($.browser.msie) {
            try {
                this.style.behavior = "url(#default#homepage)";
                this.setHomePage(this.href);
            }
            catch (c) {
                ;
            }
        }
        else {
            alert('Чтобы сделать эту страницу стартовой, просто перетащите этот значок на значок "дома" рядом с адресной строкой');
        }
        return false;
    });
    
    return this;

};

