function print_email_ns(auth,em)
{
        em = em.substring(3,em.length-3);
        auth = auth.substring(4,auth.length-4);
        document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
}

function check_submit(form)
{
        if(document.all||document.getElementById)
        {
                for (i=0;i<form.length;i++)
                {
                        var tempobj=form.elements[i]
                        if(tempobj.type.toLowerCase()=="submit")
                        {
                                tempobj.disabled=true
                        }
                }
        }
}

function pr(text){
        document.postform.text.focus();
        document.postform.text.value += text;
}

function ins_quote(nick)
{
        var maxlen = 80;

        if (document.getSelection)
                text = document.getSelection().toString();
        else
                text = document.selection.createRange().text;

        pr("[b]"+nick+"[/b]\n", 1);

        if(!text.length)
                return;

        var s = text.split('\n');
        var len = s.length;
        var i, j, begstr, str, cmts, si;

        if ((s[len-1]).indexOf("Последняя правка") == 0)
                len --;

        text = "";

        for (i=0; i<len; i++)
        {
                ti=(s[i].indexOf(" >")==0 ? 1 : 0);
                tend=s[i].length-1;
                while (s[i].charAt(tend)==' ') tend--;
                if (ti || tend<s[i].length-1) s[i]=s[i].substring(ti,tend+1);
                cmts = "";
                if (((si = s[i].indexOf(' ')) == -1) || (s[i] == ""))
                {
                        text += ("> " + s[i] + "\n");
                        continue;
                }
                for (j=0; j<s[i].length; j++)
                {
                        if (s[i].charAt(j) == '>')
                                cmts += "> ";
                        else
                                break;
                }
                str = cmts;
                s[i] = s[i].slice(cmts.length);
                s[i] += " ";
                while ((si = s[i].indexOf(' ')) != -1)
                {
                        begstr = s[i].slice(0, si);
                        s[i] = s[i].slice(si+1);
                        if (begstr.length + str.length >= maxlen)
                        {
                                if (str.slice(cmts.length) != '')
                                {
                                        str = str.slice(0, str.length-1);
                                        text += ("> " + str + "\n");
                                }
                                str = cmts + begstr + " ";
                                continue;
                        }
                        if (begstr.length < maxlen)
                                str += (begstr + " ");
                        else
                                str = cmts + begstr + " ";
                        if (str.length >= maxlen)
                        {
                                str = str.slice(0, str.length-1);
                                text += ("> " + str + "\n");
                                str = cmts;
                        }
                        if (s[i].length == 0)
                                break;
                }
                str = str.slice(0, str.length-1);
                if (str.slice(cmts.length) != '')
                {
                        text += ("> " + str + "\n");
                }
        }
        pr(text);
}

function p_nick(text){
        pr("[b]"+text+"[/b]\n", 1);
}



function out_counter_gd()
{
        d=document;
        var a=';r='+escape(d.referrer)
        s=screen;
        a+=';s='+s.width+'*'+s.height;
        a+=';d='+(s.colorDepth?s.colorDepth:s.pixelDepth);

        d.write('<a href="http://top.mail.ru/jump?from=261892"><img src="http://top.list.ru/counter?id=261892;t=56;'+a+';rand='+Math.random()+
                '" alt="Рейтинг@Mail.ru"'+' border="0" height="31" width="88" /><\/a>');
}


function out_search_gd()
{
    document.write('<div style="float: right;"><form method="get" action="http://www.google.com/search"><input type="hidden" name="ie" value="windows-1251" /><input type="hidden" name="oe" value="windows-1251" /><input type="hidden" name="domains" value="www.gamedev.ru" /><input type="hidden" name="sitesearch" value="www.gamedev.ru" />Поиск: <input class="thinbut" type="text" name="q" size="10" maxlength="255" value="" /> <input class="thinbut" type="submit" name="btnG" value="Найти!" /></form></div>');
}


function out_login(url)
{
    document.write('<div style="float: right;"><form method="post" action="'+url+'?login"><input type="hidden" name="action" value="autopost" /><a href="'+url+'?login">Логин</a>:<input class="thinbut" name="nick" value="" size="10" /> Пароль:<input class="thinbut" name="pass" type="password" value="" size="10" /> <input class="thinbut" id="_gdr_post" name="_gdr_post" type="submit" value="Войти" /></form></div>');
}


function out_advblock_gd()
{
    yandex_partner_id = 45409;
    yandex_site_bg_color = 'FFFFFF';
    yandex_site_charset = 'windows-1251';
    yandex_ad_format = 'direct';
    yandex_font_size = 1;
    yandex_direct_type = 'horizontal';
    yandex_direct_border_type = 'ad';
    yandex_direct_limit = 3;
    yandex_direct_header_bg_color = '6699CC';
    yandex_direct_bg_color = 'CCEEFF';
    yandex_direct_border_color = '6699CC';
    yandex_direct_title_color = '006699';
    yandex_direct_url_color = '006699';
    yandex_direct_all_color = '000000';
    yandex_direct_text_color = '000000';
    yandex_direct_hover_color = '6699CC';
    document.write('<sc'+'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc'+'ript>');
}


function out_advblock_gd_bad()
{
        yandex_partner_id = 55589;
        yandex_site_bg_color = 'FFFFFF';
        yandex_site_charset = 'windows-1251';
        yandex_ad_format = 'direct';
        yandex_font_size = 1;
        yandex_direct_type = 'horizontal';
        yandex_direct_border_type = 'ad';
        yandex_direct_limit = 3;
        yandex_direct_header_bg_color = '666666';
        yandex_direct_bg_color = 'CCCCCC';
        yandex_direct_border_color = '666666';
        yandex_direct_title_color = '000000';
        yandex_direct_url_color = '000000';
        yandex_direct_all_color = '000000';
        yandex_direct_text_color = '000000';
        yandex_direct_hover_color = '666666';
        document.write('<sc'+'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc'+'ript>');
}
