jQuery(function ($) 
{
    //RATE IT START
    rate_it = function (rate_form_id) 
    {
        if ($('#rt' + rate_form_id + ' option:selected').val() != 0 && confirm($('#rt' + rate_form_id + ' option:selected').text() + '?')) 
        {
            this.disabled = true;
            _uPostForm('', 
            {
                complete : function () 
                {
                    $.get(self.location.pathname, function (new_rate_data) 
                    {
                        new_rate_data = '' + $('p.alert', new_rate_data).html();
                        $('p.alert').html(new_rate_data);
                    }) 
                },
                url : '/load/0-1-' + $('#rt' + rate_form_id + ' option:selected').val() + '-' + rate_form_id + '-3' 
            });
        }
    }
    //RATE IT STOP
    //Get News START
    getNews = function (id, url) 
    {
        if (!document.getElementById('new' + id)) 
        {
            $('#t' + id).append('<div id="new' + id + '" class="thDescr"><div class="nload"><\/div><\/div>');
            $.get(url, {}, function (xml) 
            {
                data = $('td.posttdMessage:eq(0)', xml).html();
                $('#new' + id).html(data);
            });
        }
        else {
            $('#new' + id).slideToggle('slow');
        }
    }
    //Get News END
    popup = function () 
    {
        //AJAX Pop-Up START
        $('a[href*=/index/8]').each(function () 
        {
            $(this).click(function () 
            {
                new _uWnd('popup', 'Страница пользователя: ' + $(this).text(), 640, 480, {
                    autoresize : 1,
                    oncontent : function () 
                    {
                        popup();
                    }
                },
                {
                    url : $(this).attr('href'), xml : false 
                });
                return false;
            });
            //$(this).attr('href', 'javascript://');
            $(this).removeAttr('target');
        });
        $('div.myWinCont a[href*=/index/11]').each(function () 
        {
            $(this).click(function () 
            {
                new _uWnd('popup', 'Мои данные', 640, 480, {
                    autoresize : 1,
                    oncontent : function () 
                    {
                        popup();
                    }
                },
                {
                    url : $(this).attr('href'), xml : false 
                });
                return false;
            });
            //$(this).attr('href', 'javascript://');
            $(this).removeAttr('target');
        });
        $('div.myWinCont a[href*=/index/14]').each(function () 
        {
            $(this).click(function () 
            {
                new _uWnd('popup', 'Личные сообщения', 640, 480, {
                    autoresize : 1,
                    oncontent : function () 
                    {
                        popup();
                    }
                },
                {
                    url : $(this).attr('href'), xml : false 
                });
                return false;
            });
            //$(this).attr('href', 'javascript://');
            $(this).removeAttr('target');
        });
        //AJAX Pop-Up STOP
    };
    $(document).ready(function () 
    {
        //Links fix Start
        $('a[href^=/wiki/]').each(function () 
        {
            $(this).attr('href', function () 
            {
                return 'http://ru.wikipedia.org/wiki/' + $(this).attr('title');
            });
            $(this).attr('target', '_blank');
        });
        //Links fix End
/*
        //Внешние ссылки start
        $('a[href^=http:]').each(function () 
        {
            if (this.host != 'sp-fans.net.ru' && this.host != 'www.sp-fans.net.ru' && this.host != 'sp-fans.net.ru:80' && this.host != 'www.sp-fans.net.ru:80' && this.host != 'download.sp-fans.net.ru' && this.host != 'www.download.sp-fans.net.ru' && this.host != 'download.sp-fans.net.ru:80' && this.host != 'www.download.sp-fans.net.ru:80') 
            {
                $(this).attr('target', '_blank').attr('href', function () 
                {
                    return '/away.htm?' + this.href;
                });
            }
        });
        //Внешниие ссылки END
*/
        //popup();
    });
});
