
RBjs_Template = function( owner )
{
    this.owner = owner;
    var me = this;
    
    this.vals = {};
    
    // собственно темплейты
    this.tpls = {};

    //RB
    this.tpls['for_bloggers_rb_ru'] = '[font=arial][url={url}][size=3][b]{title}[/b][/size][/url]\
\n\n\
[img]{img}[/img]\
\n\n\
[color=#717275]{anons}[/color] // [url={url}]читать статью полностью[/url][/font]';
    this.tpls['for_bloggers_rb_ru_preview'] = '<span style="font-family: arial;"><a target="_blank" href="{url}"><span style="font-size: 12pt; line-height: 100%;"><b>{title}</b></span></a><br><br><img border="0" src="{img}"><br><br><span style="color: rgb(113, 114, 117);">{anons}</span> // <a target="_blank" href="{url}">читать статью полностью</a></span>';

    //BB space
    this.tpls['bb_code'] = '[img]http://www.rb.ru/_img/logo.gif[/img]\
\n\n\
[font=arial][url={url}][size=3][b]{title}[/b][/size][/url]\
\n\n\
[img]{img}[/img]\
\n\n\
[color=#717275]{anons}[/color] // [url={url}]читать статью полностью[/url][/font]';
    this.tpls['bb_code_preview'] = '<img src="http://www.rb.ru/_img/logo.gif"><br><br><span style="font-family: arial;"><a target="_blank" href="{url}"><span style="font-size: 12pt; line-height: 100%;"><b>{title}</b></span></a><br><br><img border="0" src="{img}"><br><br><span style="color: rgb(113, 114, 117);">{anons}</span> // <a target="_blank" href="{url}">читать статью полностью</a></span>';        

    this.tpls['html_code'] = '<!-- RB.RU code START --><img src="http://www.rb.ru/_img/logo.gif"><br><br><span style="font-family: arial;"><a target="_blank" href="{url}"><span style="font-size: 12pt; line-height: 100%;"><b>{title}</b></span></a><br><br><img border="0" src="{img}"><br><br><span style="color: rgb(113, 114, 117);">{anons}</span> // <a target="_blank" href="{url}">читать статью полностью</a></span><!-- RB.RU code END -->';
    this.tpls['html_code_preview'] = this.tpls['html_code'];

    this.tpls['jj_code'] = '<!-- RB.RU code START --><table width="420" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><a href="http://www.rb.ru/" target="_blank"><img src="http://www.rb.ru/_img/blog_rb_logo_a.gif" alt="RB.Ru / Деловая Сеть" title="RB.Ru / Деловая Сеть" width="420" height="62" border="0"></a></td></tr><tr><td valign="top" style="border:1px solid #C4C5CA; border-top: 0px; padding:10px; padding-top:0px; background: url(http://www.rb.ru/_img/blog_grad.gif); background-repeat:repeat-x; background-position:bottom;"><div style="padding: 5px 8px;"><font size="4" face="Arial, Helvetica, sans-serif"><a target="_blank" href="{url}" style="color:#5571A4; text-decoration:none;">{title}</a></font></div><img src="{img}" alt="" width="117" style="margin:0 5px 5px 0;border:1px solid #8D8F97;" align="left"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #717275;">{anons}</span><p align="right"><a style="color:#4E78C4; font-family: Arial, Helvetica, sans-serif; font-size: 11px;" href="{url}" target="_blank">читать статью полностью</a></p></td></tr><tr><td height="23" bgcolor="#868890" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="{url}" target="_blank" style="color:white; text-decoration:none;">{url}</a></font></td></tr></table><!-- RB.RU code END -->';
    this.tpls['jj_code_preview'] = this.tpls['jj_code'];

    this.tpls['li_code'] = '<img src="http://www.rb.ru/_img/logo.gif"><br><br><span style="font-family: arial;"><a target="_blank" href="{url}"><span style="font-size: 12pt; line-height: 100%;"><b>{title}</b></span></a><br><br><img border="0" src="{img}"><br><br><span style="color: rgb(113, 114, 117);">{anons}</span> // <a target="_blank" href="{url}">читать статью полностью</a></span>';
    this.tpls['li_code_preview'] = this.tpls['li_code'];    

                                    
    this.assign = function( name, value )
    {
        this.vals[ name]  = value;
    }
    
    this.render = function( tpl )
    {
        if( !this.tpls[tpl] ) return '';
        
        var text = this.tpls[tpl];
        
        if( !me.owner.empty( me.vals ) ) {
            for( key in me.vals ) {
                regexp = new RegExp('\{' + key + '\}', 'g')
                text = text.replace( regexp, me.vals[key] );
            }
        }
        
        return text;
    }
    
    this.clear = function()
    {
        this.vals = {};    
    }

}



RBjs.Template = new RBjs_Template( RBjs );