F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Admin\ManageTemplates.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Admin\ManageTemplates.pm
############################################################################### ###############################################################################
# ManageTemplates.pl                                                          # # ManageTemplates.pm                                                          #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$managetemplatesplver = 'YaBB 2.5.2 $Revision: 1.1 $'; $managetemplatespmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('Templates');  LoadLanguage('Templates'); 
  LoadLanguage('Menu');
  $admin_images = "$yyhtml_root/Templates/Admin/default";
   
sub ModifyTemplate { sub ModifyTemplate {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my ($fulltemplate, $line);     my @tempnames = qw ( Bdaylist BoardIndex Calendar Display Downloads HelpCentre Loginout Memberlist MessageIndex MyCenter MyMessage MyPosts MyProfile Poll Post Other Register Search ); 
   if    ($FORM{'templatefile'}) { $templatefile = $FORM{'templatefile'} }     my ( $fulltemplate, $line ); 
   elsif ($INFO{'templatefile'}) { $templatefile = $INFO{'templatefile'} }    if    ( $FORM{'templatefile'} ) { $templatefile = $FORM{'templatefile'} }
   else { $templatefile = "default/default.html"; }    elsif ( $INFO{'templatefile'} ) { $templatefile = $INFO{'templatefile'} }
   opendir(TMPLDIR, $templatesdir);     else                            { $templatefile = 'default/default.html'; } 
   @temptemplates = readdir(TMPLDIR);     opendir TMPLDIR, $templatesdir; 
   closedir(TMPLDIR);     @temptemplates = readdir TMPLDIR; 
   $templs = "";     closedir TMPLDIR; 
     $templs = q{};
   foreach $file (@temptemplates) {  
       if (-e "$templatesdir/$file/$file.html") {    foreach my $file (@temptemplates) {
           push(@templates, $file);         if ( -e "$templatesdir/$file/$file.html" ) { 
       } else {             push @templates, $file; 
           next;         } 
       }         else { 
   }             next; 
         }
   foreach $name (sort @templates) {     } 
       $selected = "";  
     foreach my $name ( sort @templates ) {
       if (-e "$templatesdir/$name/$name.html") {         $selected = q{}; 
           $cmp_templatefile = "$name/$name.html";         if ( -e "$templatesdir/$name/$name.html" ) { 
           if ($cmp_templatefile eq $templatefile) { $selected = qq~ selected="selected"~; }             $cmp_templatefile = "$name/$name.html"; 
           $templs .= qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~;             if ( $cmp_templatefile eq $templatefile ) { 
           $selected = "";                 $selected = q~ selected="selected"~; 
       } elsif (-e "$templatesdir/$name/$name.htm") {             } 
           $cmp_templatefile = "$name/$name.htm";             $templs .= 
           if ($cmp_templatefile eq $templatefile) { $selected = qq~ selected="selected"~; }  qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~; 
           $templs .= qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~;             $selected = q{}; 
           $selected = "";         } 
       }         elsif ( -e "$templatesdir/$name/$name.htm" ) { 
             $cmp_templatefile = "$name/$name.htm";
       $cmp_boardfile   = "$name/BoardIndex.template";             if ( $cmp_templatefile eq $templatefile ) { 
       $cmp_messagefile = "$name/MessageIndex.template";                 $selected = q~ selected="selected"~; 
       $cmp_displayfile = "$name/Display.template";             } 
       $cmp_helpfile    = "$name/HelpCentre.template";             $templs .= 
       $cmp_mycenterfile = "$name/MyCenter.template";  qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~; 
             $selected = q{};
       if (-e "$templatesdir/$name/BoardIndex.template") {         } 
           $ext = "BoardIndex";  
           if ($cmp_boardfile eq $templatefile) { $selected = qq~ selected="selected"~; }         for my $tmp (@tempnames) { 
           $templs .= qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;             $tmpnm = lc $tmp; 
           $selected = "";             ${ 'cmp_' . $tmpnm } = "$name/$tmp.template"; 
       }             if ( -e "$templatesdir/$name/$tmp.template" ) { 
       if (-e "$templatesdir/$name/MessageIndex.template") {                 $ext = $tmp; 
           $ext = "MessageIndex";                 if ( ${ 'cmp_' . $tmpnm } eq $templatefile ) { 
           if ($cmp_messagefile eq $templatefile) { $selected = qq~ selected="selected"~; }                     $selected = q~ selected="selected"~; 
           $templs .= qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;                 } 
           $selected = "";             $templs .= 
       }  qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~; 
       if (-e "$templatesdir/$name/Display.template") {             $selected = q{}; 
           $ext = "Display";             } 
           if ($cmp_displayfile eq $templatefile) { $selected = qq~ selected="selected"~; }        }
           $templs .= qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;     } 
           $selected = "";  
       }     fopen( TMPL, "$templatesdir/$templatefile" ); 
       if (-e "$templatesdir/$name/HelpCentre.template") {     my $line = join '',<TMPL>; 
           $ext = "HelpCentre";     fclose(TMPL); 
           if ($cmp_helpfile eq $templatefile) { $selected = qq~ selected="selected"~; }     for my $x( 0 .. ( length($line) - 1 ) ){ 
           $templs .= qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;         $fulltemplate .= "&#" . sprintf("%03d",ord((substr($line,$x,1)))) . ";"; 
           $selected = "";     } 
       }  
       if (-e "$templatesdir/$name/MyCenter.template") {     $yymain .= qq~ 
           $ext = "MyCenter";  <div class="bordercolor rightboxdiv"> 
           if ($cmp_mycenterfile eq $templatefile) { $selected = qq~ selected="selected"~; }     <table class="border-space pad-cell"> 
           $templs .= qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;         <tr> 
           $selected = "";             <td class="titlebg"> 
       }                 $admin_img{'xx'} <b> $templ_txt{'52'}</b> - $templatefile 
   }                 <span class="small">(<a href="$adminurl?action=modskin2"><b>$templ_txt{'configure'}</b></a>)</span> 
             </td>
   fopen(TMPL, "$templatesdir/$templatefile");         </tr> 
   while ($line = <TMPL>) {     </table> 
       $line =~ s~[\r\n]~~g;     <table class="border-space pad-cell" style="margin-bottom:.5em"> 
       $line =~ s~&nbsp;~&#38;nbsp;~g;             <td class="windowbg2"> 
       $line =~ s~&amp;~&#38;amp;~g;                 <div style="float: left; width: 40%; padding: 3px;"><label for="templatefile"><b>$templ_txt{'10'}</b>$templ_txt{'10b'}</label></div> 
       &FromHTML($line);                 <div style="float: left; width: 59%;"> 
       $fulltemplate .= qq~$line\n~;                     <form action="$adminurl?action=modtemp" method="post" style="display: inline;" accept-charset="$yymycharset"> 
   }                         <select name="templatefile" id="templatefile" size="1" onchange="submit()"> 
   fclose(TMPL);                     $templs 
                         </select>
   $yymain .= qq~                     </form> 
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">                 </div> 
  <table width="100%" cellspacing="1" cellpadding="4" style="table-layout: fixed;">             </td> 
   <tr valign="middle">         </tr> 
       <td align="left" class="titlebg">     </table> 
       <img src="$imagesdir/xx.gif" alt="" border="0" /><b> $templ_txt{'52'}</b> - $templatefile  </div> 
       </td>  <form action="$adminurl?action=modtemp2" method="post" style="display: inline;" accept-charset="$yymycharset"> 
   </tr>  <div class="bordercolor borderstyle rightboxdiv"> 
   <tr valign="middle">     <table class="border-space pad-cell" style="table-layout: fixed; margin-bottom: .5em;"> 
       <td align="center" class="windowbg2">         <tr> 
       <form action="$adminurl?action=modtemp2" method="post" style="display: inline;">             <td class="windowbg2 center"> 
       <textarea rows="20" cols="95" name="template" style="width:99%; height: 350px;">$fulltemplate</textarea>                 <textarea rows="20" cols="95" name="template" style="width:99%; height: 350px; font-family:Courier">$fulltemplate</textarea> 
       <input type="hidden" name="filename" value="$templatefile" />                <input type="hidden" name="filename" value="$templatefile" />
       </td>            </td>
   </tr>        </tr>
   <tr valign="middle">     </table> 
       <td align="center" class="catbg">  </div> 
       <input type="submit" value="$admin_txt{'10'} $templatefile" class="button" />  <div class="bordercolor rightboxdiv"> 
       </form>  <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
       </td>     <tr> 
   </tr>         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th> 
   <tr valign="middle">     </tr><tr> 
       <td align="left" class="windowbg2">         <td class="catbg center"> 
       <div style="float: left; width: 30%; padding: 3px;"><label for="templatefile"><b>$templ_txt{'10'}</b></label></div>             <input type="submit" value="$admin_txt{'10'} $templatefile" class="button" /> 
       <div style="float: left; width: 69%;">         </td> 
       <form action="$adminurl?action=modtemp" method="post" style="display: inline;">     </tr> 
       <select name="templatefile" id="templatefile" size="1" onchange="submit()">  </table> 
       $templs  </div> 
       </select>  </form> 
       <noscript><input type="submit" value="$admin_txt{'32'}" class="button" /></noscript>  
       </form>  
       </div>  
       </td>  
   </tr>  
  </table>  
</div>  
~; ~;
   $yytitle     = "$admin_txt{'216'}";    $yytitle     = "$admin_txt{'216'}";
   $action_area = "modtemp";     $action_area = 'modtemp'; 
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub ModifyTemplate2 { sub ModifyTemplate2 {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   $FORM{'template'} =~ tr/\r//d;     if   ( $FORM{'filename'} ) { $templatefile = $FORM{'filename'}; } 
   $FORM{'template'} =~ s~\A\n~~;     else                       { $templatefile = 'default.html'; } 
   $FORM{'template'} =~ s~\n\Z~~;     $FORM{'template'} =~ tr/\r//d; 
   if ($FORM{'filename'}) { $templatefile = $FORM{'filename'}; }     $FORM{'template'} =~ s/\A\n//xsm; 
   else { $templatefile = "default.html"; }     $FORM{'template'} =~ s/\n\Z//xsm; 
   fopen(TMPL, ">$templatesdir/$templatefile");     fopen( TMPL, ">$templatesdir/$templatefile" ); 
     print {TMPL} "$FORM{'template'}" or croak "$croak{'print'} TMPL";
   print TMPL "$FORM{'template'}\n";     fclose(TMPL); 
   fclose(TMPL);  
   $yySetLocation = qq~$adminurl?action=modtemp;templatefile=$templatefile~;    $yySetLocation = qq~$adminurl?action=modtemp;templatefile=$templatefile~;
   &redirectexit;     redirectexit(); 
     return;
  }
   
  sub ModifySkin {
     is_admin_or_gmod();
   
     if   ( $INFO{'templateset'} ) { $thistemplate = $INFO{'templateset'}; }
     else                          { $thistemplate = "$template"; }
   
     foreach my $curtemplate (
         sort { $templateset{$a} cmp $templateset{$b} }
         keys %templateset
       )
     {
         $selected = q{};
         if ( $curtemplate eq $thistemplate ) {
             $selected    = q~ selected="selected"~;
             $akttemplate = $curtemplate;
         }
         $templatesel .=
           qq~<option value="$curtemplate"$selected>$curtemplate</option>\n~;
     }
   
     (
         $aktstyle,   $aktimages,  $akthead,     $aktboard,
         $aktmessage, $aktdisplay, $aktmycenter, $aktmenutype, $aktthreadtools, $aktposttools
     ) = split /\|/xsm, $templateset{$akttemplate};
     $thisimagesdir = "$yyhtml_root/Templates/Forum/$aktimages";
   
     $ttoolschecked = q{};
     if ( $INFO{'threadtools'} ne q{} ) {
         if ($INFO{'threadtools'} == 1 ) {
             $ttoolschecked = ' checked="checked"';
         }
     }
     elsif ( $aktthreadtools == 1 ) {
         $ttoolschecked = ' checked="checked"';
     }
     elsif ( $threadtools == 1 ) {
         $ttoolschecked = ' checked="checked"';
     }
   
     if ( $aktposttools == 1 || $INFO{'posttools'} == 1 ) {
         $ptoolschecked = ' checked="checked"';
     }
   
     my ( $fullcss, $line );
     if   ( $INFO{'cssfile'} ) { $cssfile = $INFO{'cssfile'}; }
     else                      { $cssfile = "$aktstyle.css"; }
     if   ( $INFO{'imgfolder'} ) { $imgfolder = $INFO{'imgfolder'}; }
     else                        { $imgfolder = "$aktimages"; }
     if   ( $INFO{'headfile'} ) { $headfile = $INFO{'headfile'}; }
     else                       { $headfile = "$akthead.html"; }
     if ( $INFO{'boardfile'} ) { $boardfile = $INFO{'boardfile'}; }
     else                      { $boardfile = "$aktboard/BoardIndex.template"; }
     if ( $INFO{'messagefile'} ) { $messagefile = $INFO{'messagefile'}; }
     else { $messagefile = "$aktmessage/MessageIndex.template"; }
     if ( $INFO{'displayfile'} ) { $displayfile = $INFO{'displayfile'}; }
     else { $displayfile = "$aktdisplay/Display.template"; }
   
     if ( $INFO{'mycenterfile'} ) { $mycenterfile = $INFO{'mycenterfile'}; }
     else { $mycenterfile = "$aktmycenter/MyCenter.template"; }
   
     if ( $INFO{'menutype'} ne q{} ) { $UseMenuType = $INFO{'menutype'}; }
     else {
         $UseMenuType = $MenuType;
         if ( $aktmenutype ne q{} ) { $UseMenuType = $aktmenutype; }
     }
   
     if ( $INFO{'threadtools'} ne q{} ) { $useThreadtools = $INFO{'threadtools'}; }
     else {
         if ( $thistemplate ne 'Forum default' ) { $useThreadtools = $aktthreadtools; }
         else { $useThreadtools = $threadtools; }
     }
   
     if ( $INFO{'posttools'} ne q{} ) { $usePosttools = $INFO{'posttools'}; }
     else {
         $usePosttools = $posttools;
         if ( $thistemplate ne 'Forum default' ) { $usePosttools = $aktposttools; }
     }
   
     if   ( $INFO{'selsection'} ) { $selectedsection = $INFO{'selsection'}; }
     else                         { $selectedsection = 'vboard'; }
     my ( $boardsel, $messagesel, $displaysel );
     if ( $selectedsection eq 'vboard' ) { $boardsel = q~ checked="checked"~; }
     elsif ( $selectedsection eq 'vmessage' ) {
         $messagesel = q~ checked="checked"~;
     }
     elsif ( $selectedsection eq 'vdisplay' ) {
         $displaysel = q~ checked="checked"~;
     }
     else { $mycentersel = q~ checked="checked"~; }
   
     opendir TMPLDIR, "$htmldir/Templates/Forum";
     @styles = readdir TMPLDIR;
     closedir TMPLDIR;
     $forumcss = q{};
     $imgdirs  = q{};
     foreach my $file ( sort @styles ) {
         if ( $file ne 'calscroller.css' && $file ne 'setup.css' ) {
             ( $name, $ext, $bak ) = split /\./xsm, $file;
             $selected = q{};
             if ( !$bak && $ext eq 'css' ) {
                 if ( $file eq $cssfile ) {
                     $selected = q~ selected="selected"~;
                     $viewcss  = $name;
                 }
                 $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;
             }
         }
         if ( -d "$htmldir/Templates/Forum/$file" 
             && $file =~ m{\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z}xsm )
         {
             if ( $imgfolder eq $file ) {
                 $imgdirs .=
                   qq~<option value="$file" selected="selected">$file</option>~;
                 $viewimg = $file;
             }
             else { $imgdirs .= qq~<option value="$file">$file</option>~; }
         }
     }
   
     fopen( CSS, "$htmldir/Templates/Forum/$cssfile" )
       or fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile" );
     while ( $line = <CSS> ) {
         $line =~ s/[\r\n]//gxsm;
         FromHTML($line);
         $fullcss .= qq~$line\n~;
     }
     fclose(CSS);
   
     opendir TMPLDIR, "$templatesdir";
     @temptemplates = readdir TMPLDIR;
     closedir TMPLDIR;
   
     foreach my $tmpfile (@temptemplates) {
         if ( -d "$templatesdir/$tmpfile" ) {
             push @templates, $tmpfile;
         }
         else {
             next;
         }
     }
   
     if    ( $UseMenuType == 0 ) { $menutype0 = ' selected="selected" '; }
     elsif ( $UseMenuType == 1 ) { $menutype1 = ' selected="selected" '; }
     elsif ( $UseMenuType == 2 ) { $menutype2 = ' selected="selected" '; }
   
     $fullcss =~ s/\s{2,}/ /gsm;
     $boardtemplates   = q{};
     $messagetemplates = q{};
     $displaytemplates = q{};
     $headtemplates    = q{};
   
     foreach my $name ( sort @templates ) {
         opendir TMPLSDIR, "$templatesdir/$name";
         @templatefiles = readdir TMPLSDIR;
         closedir TMPLSDIR;
   
         foreach my $file (@templatefiles) {
             if ( $file eq 'index.html' ) { next; }
             $thefile = qq~$name/$file~;
             ( $section, $ext ) = split /\./xsm, $file;
             $hselected = q{};
             if ( $ext eq 'html' && $section eq $name ) {
                 if ( $file eq $headfile ) {
                     $hselected = q~ selected="selected"~;
                     $viewhead  = $name;
                 }
                 $headtemplates .=
                   qq~<option value="$file"$hselected>$name</option>\n~;
             }
             $bselected  = q{};
             $mselected  = q{};
             $dselected  = q{};
             $myselected = q{};
             if ( $section eq 'BoardIndex' ) {
                 if ( $thefile eq $boardfile ) {
                     $bselected = q~ selected="selected"~;
                     $viewboard = $name;
                 }
                 $boardtemplates .=
                   qq~<option value="$thefile"$bselected>$name</option>\n~;
             }
             elsif ( $section eq 'MessageIndex' ) {
                 if ( $thefile eq $messagefile ) {
                     $mselected   = q~ selected="selected"~;
                     $viewmessage = $name;
                 }
                 $messagetemplates .=
                   qq~<option value="$thefile"$mselected>$name</option>\n~;
             }
             elsif ( $section eq 'Display' ) {
                 if ( $thefile eq $displayfile ) {
                     $dselected   = q~ selected="selected"~;
                     $viewdisplay = $name;
                 }
                 $displaytemplates .=
                   qq~<option value="$thefile"$dselected>$name</option>\n~;
             }
             elsif ( $section eq 'MyCenter' ) {
                 if ( $thefile eq $mycenterfile ) {
                     $myselected   = q~ selected="selected"~;
                     $viewmycenter = $name;
                 }
                 $mycentertemplates .=
                   qq~<option value="$thefile"$myselected>$name</option>\n~;
             }
         }
     }
   
     fopen( TMPL, "$templatesdir/$viewhead/$viewhead.html" );
     while ( $line = <TMPL> ) {
         $line =~ s/^\s+//gsm;
         $line =~ s/\s+$//gsm;
         $line =~ s/[\r\n]//gxsm;
         $fulltemplate .= qq~$line\n~;
     }
     fclose(TMPL);
   
     $tabsep = q{};
     $tabfill = q{};
   
     $tempforumurl  = $mbname;
     $temptitle     = q~Template Config~;
     $tempnewstitle = qq~<b>$templ_txt{'68'}:</b> ~;
     $tempnews      = qq~$templ_txt{'84'}~;
     $tempstyles =
  qq~<link rel="stylesheet" href="$yyhtml_root/Templates/Forum/$viewcss.css" type="text/css" />~;
     $tempimages    = qq~$yyhtml_root/Templates/Forum/$viewimg~;
     $tempimagesdir = qq~$htmldir/Templates/Forum/$viewimg~;
     $tempmenu =
  qq~<ul><li><span class="tabstyle selected" title="$img_txt{'103'}">$tabfill$img_txt{'103'}$tabfill</span></li>~;
     $tempmenu .=
  qq~<li><span class="tabstyle" title="$img_txt{'119'}" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</span></li>~;
     $tempmenu .=
  qq~<li><span class="tabstyle" title="$img_txt{'331'}">$tabfill$img_txt{'331'}$tabfill</span></li>~;
     $tempmenu .=
  qq~<li><span class="tabstyle" title="$img_txt{'mycenter'}">$tabfill$img_txt{'mycenter'}$tabfill</span></li>~;
     $tempmenu .=
  qq~<li><span class="tabstyle" title="$img_txt{'108'}">$tabfill$img_txt{'108'}$tabfill</span>$tabsep</li></ul>~;
     $tempmenu =~
  s/img src\=\"$imagesdir\/(.+?)\"/TmpImgLoc($1, $tempimages, $tempimagesdir)/eisgm;
     $rssbutton = qq~<img src="$imagesdir/rss.png" alt="" />~;
     $tempuname = qq~$templ_txt{'69'} ${$uid.$username}{'realname'}, ~;
     $tempuim   = qq~$templ_txt{'70'} <a id="ims">0 $templ_txt{'71'}</a>.~;
     $temptime  = timeformat( $date, 1 );
     my $tempsearchbox =
  qq~<input type="text" name="search" size="16" id="search1" value="$img_txt{'182'}" style="font-size: 11px;" onfocus="txtInFields(this, '$img_txt{'182'}');" onblur="txtInFields(this, '$img_txt{'182'}')" /><input type="image" src="$imagesdir/search.png" alt="$maintxt{'searchimg'} $showsearchboxnum $maintxt{'searchimg2'}" style="background-color: transparent; margin-right: 5px; vertical-align: middle;" />
  ~;
     my $tempsearchform = q~<form>~;
     $altbrdcolor = q~windowbg2~;
     $boardtable = q~id="General"~;
     $templatejump  = 1;
     $tempforumjump = jumpto();
   
     $fulltemplate =~ s/({|<)yabb bottom(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb fixtop(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb javascripta(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb javascript(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
     $fulltemplate =~ s/({|<)yabb mycharset(}|>)/$yymycharset/gsm;
     $fulltemplate =~ s/({|<)yabb title(}|>)/$temptitle/gsm;
     $fulltemplate =~ s/({|<)yabb style(}|>)/$tempstyles/gsm;
     $fulltemplate =~ s/({|<)yabb html_root(}|>)/$yyhtml_root/gsm;
     $fulltemplate =~ s/({|<)yabb images(}|>)/$tempimages/gsm;
     $fulltemplate =~ s/({|<)yabb uname(}|>)/$tempuname/gsm;
     $fulltemplate =~ s/({|<)yabb boardlink(}|>)/$tempforumurl/gsm;
     $fulltemplate =~ s/({|<)yabb navigation(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb searchbox(}|>)/$tempsearchbox/gsm;
     $fulltemplate =~ s/({|<)yabb searchform(}|>)/<form>/gsm;
     $fulltemplate =~ s/({|<)yabb searchformend(}|>)/<\/form>/gsm;
     $fulltemplate =~ s/({|<)yabb im(}|>)/$tempuim/gsm;
     $fulltemplate =~ s/({|<)yabb time(}|>)/$temptime/gsm;
     $fulltemplate =~ s/({|<)yabb langChooser(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb menu(}|>)/$temp21menu/gsm;
     $fulltemplate =~ s/({|<)yabb tabmenu(}|>)/$tempmenu/gsm;
     $fulltemplate =~ s/({|<)yabb rss(}|>)/$rssbutton/gsm;
     $fulltemplate =~ s/<span id="newsdiv"><\/span>/<span id="newsdiv">$tempnews<\/span>/gsm;
     $fulltemplate =~ s/({|<)yabb newstitle(}|>)/$tempnewstitle/gsm;
     $fulltemplate =~ s/({|<)yabb copyright(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb debug(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb forumjump(}|>)/$tempforumjump/gsm;
     $fulltemplate =~ s/({|<)yabb freespace(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb navback(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb admin_alert(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb tabadd(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb addtab(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb syntax_js(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb grayscript(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb high(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb ubbc(}|>)//gsm;
     $fulltemplate =~ s/({|<)yabb news(}|>)//gsm;
  ## Mod Hook fulltemplate
  ## End Mod Hook fulltemplate
   
     if ( $selectedsection eq 'vboard' ) {
         $boardtempl = BoardTempl( $viewboard, $tempimages, $tempimagesdir );
         $fulltemplate =~ s/({|<)yabb main(}|>)/$boardtempl/gsm;
         $fulltemplate =~ s/({|<)yabb colboardtable(}|>)//gsm;
         $fulltemplate =~ s/({|<)yabb boardtable(}|>)/$boardtable/gsm;
         $fulltemplate =~ s/({|<)yabb altbrdcolor(}|>)/$altbrdcolor/gsm;
     }
     elsif ( $selectedsection eq 'vmessage' ) {
         $messagetempl =
           MessageTempl( $viewmessage, $tempimages, $tempimagesdir );
         $fulltemplate =~ s/({|<)yabb main(}|>)/$messagetempl/gsm;
     }
     elsif ( $selectedsection eq 'vdisplay' ) {
         $displaytempl =
           DisplayTempl( $viewdisplay, $tempimages, $tempimagesdir );
         $fulltemplate =~ s/({|<)yabb main(}|>)/$displaytempl/gsm;
     }
     elsif ( $selectedsection eq 'vmycenter' ) {
         $mycentertempl =
           MyCenterTempl( $viewmycenter, $tempimages, $tempimagesdir );
         $fulltemplate =~ s/({|<)yabb main(}|>)/$mycentertempl/gsm;
     }
     $fulltemplate =~
  s/img src\=\"$tempimages\/(.+?)\"/TmpImgLoc($1, $tempimages, $tempimagesdir)/eisgm;
     $fulltemplate =~
       s/<a href="http:\/\/validator.w3.org\/check\/referer">.+?<\/a>//gsm;
     $fulltemplate =~
  s/<a href="http:\/\/jigsaw.w3.org\/css\-validator\/validator\?uri\=\{yabb url}">.+?<\/a>//gsm;
     $fulltemplate =~ s/[\n\r]//gxsm;
     ToHTML($fulltemplate);
   
     $yymain .= qq~
  <form action="$adminurl?action=modskin2" name="selskin" method="post" style="display: inline;" accept-charset="$yymycharset">
  <div class="bordercolor rightboxdiv">
     <table class="border-space pad-cell">
         <tr>
             <td class="titlebg">
                 $admin_img{'xx'} <b> $templ_txt{'6'}</b>
                 <span class="small">(<a href="$adminurl?action=modtemp;"><b>$templ_txt{'edit_files'}</b></a>)</span>
             </td>
         </tr>
     </table>
     <table class="border-space" style="margin-bottom: -1px;">
         <tr>
             <td class="windowbg2 center">
                 <iframe id="TempManager" name="TempManager" style="border:0" scrolling="yes"></iframe>
             </td>
         </tr>
     </table>
     <table class="border-space pad-cell" style="margin-bottom: .5em;">
         <tr>
             <td class="windowbg2">
                 <div style="float: left; width: 30%; padding: 3px;"><label for="templateset"><b>$templ_txt{'10'}</b>$templ_txt{'10b'}</label></div>
                 <div style="float: left; width: 69%;">
                     <input type="hidden" name="button" value="0" />
                     <select name="templateset" id="templateset" size="1" onchange="submit();">
                         $templatesel
                     </select>
  ~;
     if ( $akttemplate ne 'Forum default' ) {
         $yymain .=
  qq~                        <input type="submit" value="$templ_txt{'14'}" onclick="document.selskin.button.value = '3'; return confirm('$templ_txt{'15'} $thistemplate?')" class="button" />~;
     }
     $yymain .= qq~
                 </div>
             </td>
         </tr><tr>
             <td class="windowbg2">
                 <div style="float: left; width: 30%; padding: 3px;">
                         <b>$templ_txt{'11'}</b><br /><span class="small">$templ_txt{'7'}</span>
                 </div>
                 <div style="float: left; width: 69%;">
                     <div style="float: left; width: 32%; text-align: left;">
                         <label for="menutype"><span class="small">$templ_txt{'521'}</span></label><br />
                             <select name="menutype" id="menutype" size="1" style="width: 90%;">
                                 <option value="0"$menutype0>$admin_txt{'521a'}</option>
                                 <option value="1"$menutype1>$admin_txt{'521b'}</option>
                                 <option value="2"$menutype2>$admin_txt{'521c'}</option>
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <label for="threadtools"><span class="small">$templ_txt{'528'}</span></label><br />
                             <input type="checkbox" name="threadtools" id="threadtools" value="1"$ttoolschecked />
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <label for="headfile" class="small">$templ_txt{'527'}</label><br />
                             <input type="checkbox" name="posttools" id="posttools" value="1"$ptoolschecked />
                         </div>
                         <br style="clear:left" />
                         <div style="float: left; width: 32%; text-align: left;">
                             <label for="cssfile"><span class="small">$templ_txt{'1'}</span></label><br />
                             <select name="cssfile" id="cssfile" size="1" style="width: 90%;">
                                 $forumcss
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <label for="imgfolder"><span class="small">$templ_txt{'8'}</span></label><br />
                             <select name="imgfolder" id="imgfolder" size="1" style="width: 90%;">
                                 $imgdirs
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <label for="headfile" class="small">$templ_txt{'2'}</label><br />
                             <select name="headfile" id="headfile" size="1" style="width: 90%;">
                                 $headtemplates
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <input type="radio" name="selsection" id="bradio" value="vboard" class="windowbg2" style="border: 0; vertical-align: middle;"$boardsel /><label for="bradio" class="small">$templ_txt{'3'}</label><br />
                             <select name="boardfile" id="boardfile" size="1" style="width: 90%;">
                                 $boardtemplates
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <input type="radio" name="selsection" id="mradio" value="vmessage" class="windowbg2" style="border: 0; vertical-align: middle;"$messagesel /><label for="mradio" class="small">$templ_txt{'4'}</label><br />
                             <select name="messagefile" id="messagefile" size="1" style="width: 90%;">
                                 $messagetemplates
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <input type="radio" name="selsection" id="dradio" value="vdisplay" class="windowbg2" style="border: 0; vertical-align: middle;"$displaysel /><label for="dradio" class="small">$templ_txt{'5'}</label><br />
                             <select name="displayfile" id="displayfile" size="1" style="width: 90%;">
                                 $displaytemplates
                             </select>
                         </div>
                         <div style="float: left; width: 32%; text-align: left;">
                             <input type="radio" name="selsection" id="myradio" value="vmycenter" class="windowbg2" style="border: 0; vertical-align: middle;"$mycentersel /><label for="myradio" class="small">$templ_txt{'67'}</label><br />
                             <select name="mycenterfile" id="mycenterfile" size="1" style="width: 90%;">
                                 $mycentertemplates
                             </select>
                         </div>
                     </div>
                 </td>
             </tr>
     </table>
  </div>
  <div class="bordercolor rightboxdiv">
  <table class="border-space pad-cell" style="margin-bottom: .5em;">
     <tr>
         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
     </tr><tr>
         <td class="catbg center">
            <label for="saveas"><b>$templ_txt{'12'}</b></label>
             <input type="hidden" name="tempname" value="$fulltemplate" />
             <input type="text" name="saveas" id="saveas" value="$thistemplate" size="30" maxlength="50" />
             <input type="submit" value="$templ_txt{'13'}" onclick="document.selskin.button.value = '2';" class="button" />
             <input type="submit" value="$templ_txt{'9'}" onclick="document.selskin.button.value = '1';" class="button" />
         </td>
     </tr>
  </table>
  </div>
  </form>
  <script type="text/javascript">
  function updateTemplate() {
         var thetemplate = document.selskin.tempname.value;
         thetemplate=thetemplate.replace(/\\&amp\\;/g, "&");
         thetemplate=thetemplate.replace(/\\&quot\\;/g, '"');
         thetemplate=thetemplate.replace(/\\&nbsp\\;/g, " ");
         thetemplate=thetemplate.replace(/\\&\\#124\\;/g, "|");
         thetemplate=thetemplate.replace(/\\&lt\\;/g, "<");
         thetemplate=thetemplate.replace(/\\&gt\\;/g, ">");
         TempManager.document.open("text/html");
         TempManager.document.write(thetemplate);
         TempManager.document.close();
  }
  document.onload = updateTemplate();
  </script>
  ~;
     $yytitle     = $templ_txt{'6'};
     $action_area = 'modskin';
     AdminTemplate();
     return;
  }
   
  sub ModifySkin2 {
     is_admin_or_gmod();
     $formattemp = $FORM{'templateset'};
     formatTempname();
     if ( $FORM{'button'} == 1 ) {
         $mythreads = 1;
         if ( $FORM{'threadtools'} eq q{} ) {
             $mythreads = 0;
         }
         $yySetLocation =
  qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'};threadtools=$mythreads;posttools=$FORM{'posttools'}~;
   
     }
     elsif ( $FORM{'button'} == 2 ) {
         $template_name = $FORM{'saveas'};
         if ( $template_name eq 'default' ) {
             fatal_error('no_delete_default');
         }
         if ( $template_name !~
             m{\A[0-9a-zA-Z_\ \.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z}sm
             || $template_name eq q{} )
         {
             fatal_error('invalid_template');
         }
         ( $template_css, undef, undef ) = split /\./xsm, $FORM{'cssfile'};
         $template_images = $FORM{'imgfolder'};
         ( $template_head,     undef ) = split /\./xsm, $FORM{'headfile'};
         ( $template_board,    undef ) = split /\//xsm, $FORM{'boardfile'};
         ( $template_message,  undef ) = split /\//xsm, $FORM{'messagefile'};
         ( $template_display,  undef ) = split /\//xsm, $FORM{'displayfile'};
         ( $template_mycenter, undef ) = split /\//xsm, $FORM{'mycenterfile'};
         ( $template_menutype, undef ) = split /\//xsm, $FORM{'menutype'};
         $template_threadtools = $FORM{'threadtools'} || 0;
         $template_posttools = $FORM{'posttools'} || 0;
         $formattemp = $FORM{'saveas'};
         formatTempname();
         UpdateTemplates( $template_name, 'save' );
         $yySetLocation =
  qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'};threadtools=$mythreads;posttools=$FORM{'posttools'}~;
   
     }
     elsif ( $FORM{'button'} == 3 ) {
         $template_name = $FORM{'templateset'};
         if ( $template_name eq 'default' ) {
             fatal_error('no_delete_default');
         }
         if ( $template_name eq 'Forum default' ) {
             fatal_error('no_delete_default');
         }
         UpdateTemplates( $template_name, 'delete' );
         $yySetLocation = qq~$adminurl?action=modskin~;
     }
     else {
         $yySetLocation = qq~$adminurl?action=modskin;templateset=$formattemp~;
     }
     redirectexit();
     return;
  }
   
  sub formatTempname {
     my ($formattemp) = @_;
     $formattemp =~ s/\%/%25/gsm;
     $formattemp =~ s/\#/%23/gsm;
     $formattemp =~ s/\+/%2B/gsm;
     $formattemp =~ s/\,/%2C/gsm;
     $formattemp =~ s/\-/%2D/gsm;
     $formattemp =~ s/\./%2E/gsm;
     $formattemp =~ s/\@/%40/gsm;
     $formattemp =~ s/\^/%5E/gsm;
     return;
  }
   
  sub TmpImgLoc {
     my @x = @_;
     if ( !-e "$x[2]/$x[0]" ) {
         $thisimgloc = qq~img src="$yyhtml_root/Templates/Forum/default/$x[0]"~;
     }
     else { $thisimgloc = qq~img src="$x[1]/$x[0]"~; }
     return $thisimgloc;
  }
   
  sub BoardTempl {
     my @x = @_;
     LoadLanguage('BoardIndex');
     my $tmpimagesdir = $imagesdir;
     $imagesdir = qq~$x[1]~;
     require "$templatesdir/$x[0]/BoardIndex.template";
   
     if ( -e ("$vardir/mostlog.txt") ) {
         fopen( MOSTUSERS, "$vardir/mostlog.txt" );
         @mostentries = <MOSTUSERS>;
         fclose(MOSTUSERS);
         ( $mostmemb,  $datememb )  = split /\|/xsm, $mostentries[0];
         ( $mostguest, $dateguest ) = split /\|/xsm, $mostentries[1];
         ( $mostusers, $dateusers ) = split /\|/xsm, $mostentries[2];
         ( $mostbots,  $datebots )  = split /\|/xsm, $mostentries[3];
         chomp $datememb;
         chomp $dateguest;
         chomp $dateusers;
         chomp $datebots;
         $themostmembdate  = timeformat($datememb);
         $themostguestdate = timeformat($dateguest);
         $themostuserdate  = timeformat($dateusers);
         $themostbotsdate  = timeformat($datebots);
         $themostuser      = $mostusers;
         $themostmemb      = $mostmemb;
         $themostguest     = $mostguest;
         $themostbots      = $mostbots;
     }
     else {
         $themostmembdate  = timeformat($date);
         $themostguestdate = timeformat($date);
         $themostuserdate  = timeformat($date);
         $themostbotsdate  = timeformat($date);
         $themostuser      = 23;
         $themostmemb      = 12;
         $themostguest     = 19;
         $themostbots      = 4;
     }
   
     $grpcolors = q{};
     ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
       $Group{'Administrator'}, 5;
     my $admcolor = qq~$color~;
     if ( $color && $noshow != 1 ) {
         $grpcolors .=
  qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
     }
     ( $title, undef, undef, $color, $noshow ) =
       split /\|/xsm, $Group{'Global Moderator'}, 5;
     if ( $color && $noshow != 1 ) {
         $grpcolors .=
  qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
     }
     ( $title, undef, undef, $color, $noshow ) =
       split /\|/xsm, $Group{'Mid Moderator'}, 5;
     if ( $color && $noshow != 1 ) {
         $grpcolors .=
  qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
     }
     foreach my $nopostamount ( sort { $a <=> $b } keys %NoPost ) {
         ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
           $NoPost{$nopostamount}, 5;
         if ( $color && $noshow != 1 ) {
             $grpcolors .=
  qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
         }
     }
     foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) {
         ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
           $Post{$postamount}, 5;
         if ( $color && $noshow != 1 ) {
             $grpcolors .=
  qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
         }
     }
   
     my $latestmemberlink =
  qq~$boardindex_txt{'201'} <a href="javascript:;"><b>${$uid.$username}{'realname'}</b></a>.<br />~;
     my $tempims =
  qq~$boardindex_txt{'795'} <a href="javascript:;"><b>2</b></a> $boardindex_txt{'796'} $boardindex_imtxt{'24'} <a href="javascript:;"><b>2</b></a> $boardindex_imtxt{'26'}.~;
     my $tempforumurl    = $mbname;
     my $tempnew         = qq~$admin_img{'off'}~;
     my $tempcurboard    = $templ_txt{'77'};
     my $tempcurboardurl = q~javascript:;~;
     my $tempboardanchor = $templ_txt{'78'};
     my $tempbddescr     = $templ_txt{'79'};
     my $tempshowmods =
  qq~$boardindex_txt{'63'}: $templ_txt{'74'}<br />$boardindex_txt{'63a'}: $templ_txt{'74a'}~;
     my $templastposttme = timeformat($date);
     my $templastpostlink =
       qq~<a href="javascript:;">$img{'lastpost'}</a> $templastposttme~;
     my $templastposter =
       qq~<a href="javascript:;">${$uid.$username}{'realname'}</a>~;
     my $tmplasttopiclink = qq~<a href="javascript:;">$templ_txt{'80'}</a>~;
     $tempcatlink =
  qq~<img src="$x[1]/cat_collapse.png" alt="" /> <a href="javascript:;">$templ_txt{'81'}</a>~;
     my $templatecat = $catheader;
     $templatecat =~ s/({|<)yabb catlink(}|>)/$tempcatlink/gsm;
     my $tmptemplateblock = $templatecat;
     my $templastpostdate = timeformat($date);
     $templastpostdate = qq~($templastpostdate).<br />~;
     my $temprecentposts =
  qq~$boardindex_txt{'791'} <select style="font-size: 7pt;"><option>--</option><option>5</option></select> $boardindex_txt{'792'} $boardindex_txt{'793'}~;
     my $tempguestson =
       qq~<span class="small">$boardindex_txt{'141'}: <b>2</b></span>~;
     my $tempbotson =
       qq~<span class="small">$boardindex_txt{'143'}: <b>3</b></span>~;
     my $tempbotlist =
       q~<span class="small">Googlebot (1), MSN Search (2)</span>~;
     my $tempuserson =
       qq~<span class="small">$boardindex_txt{'142'}: <b>1</b></span>~;
     my $tempusers =
  qq~<span class="small" style="color: $admcolor;"><b>${$uid.$username}{'realname'}</b></span><br />~;
     my $tempmembercount = q~<b>2</b>~;
     my $tempboardpic =
       qq~ <img src="$imagesdir/boards.png" alt="$tempcurboard" />~;
   
     for my $i ( 1 .. 2 ) {
         my $templateblock = $boardblock;
         $templateblock =~ s/({|<)yabb new(}|>)/$tempnew/gsm;
         $templateblock =~ s/({|<)yabb boardrss(}|>)//gsm; ### RSS on Board Index ###
         $templateblock =~ s/({|<)yabb boardanchor(}|>)/$tempboardanchor_$i/gsm;
         $templateblock =~ s/({|<)yabb boardurl(}|>)/$tempcurboardurl/gsm;
         $templateblock =~ s/({|<)yabb boardpic(}|>)/$tempboardpic/gsm;
         $templateblock =~ s/({|<)yabb boardname(}|>)/$tempcurboard $i/gsm;
         $templateblock =~ s/({|<)yabb boardviewers(}|>)/$boardviewers/gsm;
         $templateblock =~ s/({|<)yabb boarddesc(}|>)/$tempbddescr/gsm;
         $templateblock =~ s/({|<)yabb moderators(}|>)/$tempshowmods/gsm;
         $templateblock =~ s/({|<)yabb threadcount(}|>)/$i/gsm;
         $templateblock =~ s/({|<)yabb messagecount(}|>)/$i/gsm;
         $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/gsm;
         $templateblock =~ s/({|<)yabb lastposter(}|>)/$templastposter/gsm;
         $templateblock =~ s/({|<)yabb lasttopiclink(}|>)/$tmplasttopiclink/gsm;
         $tmptemplateblock .= $templateblock;
     }
     $tmptemplateblock .= $catfooter;
     $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)//sm;
     $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/gsm;
     require Sources::Menu;
     $collapselink = SetImage('collapse', $UseMenuType);
     $markalllink  = SetImage('markallread', $UseMenuType);
     $menusep = q{&nbsp;};
     if ( $UseMenuType == 1 ) {
         $menusep = q{ | };
     }
     my $templasttopiclink =
  qq~$boardindex_txt{'236'} <a href="javascript:;"><b>$templ_txt{'80'}</b></a>~;
   
     $boardhandellist =~ s/({|<)yabb collapse(}|>)/$menusep$collapselink/gsm;
     $boardhandellist =~ s/({|<)yabb expand(}|>)//gsm;
     $boardhandellist =~ s/({|<)yabb markallread(}|>)/$menusep$markalllink/gsm;
     $boardhandellist =~ s/\Q$menusep//ism;
     $boardindex_template =~
       s/({|<)yabb boardhandellist(}|>)/$boardhandellist/gsm;
     $boardindex_template =~ s/({|<)yabb catimage(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb catrss(}|>)//gsm; ### RSS on Board Index ###
     $boardindex_template =~
       s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
   
     $boardindex_template =~ s/({|<)yabb newmsg start(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb newmsg icon(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb newmsg(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb newmsg end(}|>)//gsm;
   
     $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/3/gsm;
     $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/3/gsm;
     $boardindex_template =~
       s/({|<)yabb lastpostlink(}|>)/$templasttopiclink/gsm;
     $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$templastpostdate/gsm;
     $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$temprecentposts/gsm;
     $boardindex_template =~ s/({|<){yabb recenttopics(}|>)//gsm;
   
     $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$themostuser/gsm;
     $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$themostmemb/gsm;
     $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$themostguest/gsm;
     $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$themostbots/gsm;
     $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/gsm;
     $boardindex_template =~
       s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/gsm;
     $boardindex_template =~
       s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/gsm;
     $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/gsm;
     $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/gsm;
   
     $boardindex_template =~ s/({|<)yabb membercount(}|>)/$tempmembercount/gsm;
     $boardindex_template =~ s/({|<)yabb expandmessages(}|>)/$temp_expandmessages/gsm;
     $boardindex_template =~ s/({|<)yabb latestmember(}|>)/$latestmemberlink/gsm;
     $boardindex_template =~ s/({|<)yabb ims(}|>)/$tempims/gsm;
     $boardindex_template =~ s/({|<)yabb users(}|>)/$tempuserson/gsm;
     $boardindex_template =~ s/({|<)yabb spc(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$tempusers/gsm;
     $boardindex_template =~ s/({|<)yabb guests(}|>)/$tempguestson/gsm;
     $boardindex_template =~ s/({|<)yabb onlineguests(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb bots(}|>)/$tempbotson/gsm;
     $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$tempbotlist/gsm;
     $boardindex_template =~ s/({|<)yabb caldisplay(}|>)/$cal_display/gsm;
     $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//gsm;
     $boardindex_template =~ s/({|<)yabb new_load(}|>)//gsm;
     $boardindex_template =~
                   s/({|<)yabb subboardlist(}|>)//gsm;
     $boardindex_template =~
                   s/({|<)yabb messagedropdown(}|>)//gsm;
  ## Mod Hook BoardIndex ##
  ## End Mod Hook BoardIndex ##
     $boardindex_template =~
       s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $boardindex_template =~ s/^\s+//gsm;
     $boardindex_template =~ s/\s+$//gsm;
     $imagesdir = $tmpimagesdir;
     return $boardindex_template;
  }
   
  sub MessageTempl {
     my @x = @_;
     LoadLanguage('MessageIndex');
     my $tmpimagesdir = $imagesdir;
     $imagesdir = "$x[1]";
     require "$templatesdir/$x[0]/MessageIndex.template";
     my $tempcatnm   = $templ_txt{'72'};
     my $tempboardnm = $templ_txt{'73'};
     my $tempmodslink =
  qq~($messageindex_txt{'298'}: $templ_txt{'74'} - $messageindex_txt{'298a'}: $templ_txt{'74a'})~;
     my $tempbdescrip     = $templ_txt{'79'};
     my $temppageindextgl = qq~<img src="$x[1]/xx.gif" alt="" />~;
     my $temppageindex =
  qq~<span class="small" style="vertical-align: middle;"> <b>$messageindex_txt{'139'}:</b> 1</span>~;
     my $tempthreadpic = qq~<img src="$x[1]/thread.gif" alt="" />~;
     my $tempmicon     = qq~<img src="$x[1]/xx.gif" alt="" />~;
     my $tempnew       = qq~<img src="$x[1]/new.gif" alt="" />~;
     my $tempmsublink  = $templ_txt{'83'};
     my $tempmname     = ${ $uid . $username }{'realname'};
     my $templastpostlink =
       qq~<img src="$x[1]/lastpost.gif" alt="" /> $templ_txt{'82'}~;
     my $templastposter = $tempmname;
     my $tempyabbicons  = qq~<img src="$x[1]/thread.gif" alt="" /> $messageindex_txt{'457'}<br /><img src="$x[1]/hotthread.gif" alt="" /> $messageindex_txt{'454'} x $messageindex_txt{'454a'}<br /><img src="$x[1]/veryhotthread.gif" alt="" /> $messageindex_txt{'455'} x $messageindex_txt{'454a'}<br /><img src="$x[1]/locked.gif" alt="" /> $messageindex_txt{'456'}<br /><img src="$x[1]/locked_moved.gif" alt="" /> $messageindex_txt{'845'}
  ~;
     my $tempyabbadminicons .= qq~<img src="$x[1]/hide.gif" alt="" /> $messageindex_txt{'458'}<br /><img src="$x[1]/hidesticky.gif" alt="" /> $messageindex_txt{'459'}<br /><img src="$x[1]/hidelock.gif" alt="" /> $messageindex_txt{'460'}<br /><img src="$x[1]/hidestickylock.gif" alt="" /> $messageindex_txt{'461'}<br /><img src="$x[1]/announcement.gif" alt="" /> $messageindex_txt{'779a'}<br /><img src="$x[1]/announcementlock.gif" alt="" /> $messageindex_txt{'779b'}<br /><img src="$x[1]/sticky.gif" alt="" /> $messageindex_txt{'779'}<br /><img src="$x[1]/stickylock.gif" alt="" /> $messageindex_txt{'780'}
  ~;
   
     $bdpic = qq~ <img src="$x[1]/boards.png" alt="$templ_txt{'72'}" /> ~;
     $message_permalink = $messageindex_txt{'10'};
     $temp_attachment =
       qq~<img src="$x[1]/paperclip.gif" alt="$messageindex_txt{'5'}" />~;
   
     $messageindex_template =~ s/({|<)yabb home(}|>)/$mbname/gsm;
     $messageindex_template =~ s/({|<)yabb category(}|>)/$tempcatnm/gsm;
     $messageindex_template =~ s/({|<)yabb board(}|>)/$tempboardnm/gsm;
     $messageindex_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/gsm;
     $messageindex_template =~ s/({|<)yabb sortsubject(}|>)/$messageindex_txt{'70'}/gsm;
     $messageindex_template =~ s/({|<)yabb sortstarter(}|>)/$messageindex_txt{'109'}/gsm;
     $messageindex_template =~ s/({|<)yabb sortanswer(}|>)/$messageindex_txt{'110'}/gsm;
     $messageindex_template =~ s/({|<)yabb sortlastpostim(}|>)/$messageindex_txt{'22'}/gsm;
     $messageindex_template =~ s/({|<)yabb bdpicture(}|>)/$bdpic/gsm;
     $messageindex_template =~ s/({|<)yabb threadcount(}|>)/1/gsm;
     $messageindex_template =~ s/({|<)yabb messagecount(}|>)/2/gsm;
     $boarddescription =~ s/({|<)yabb boarddescription(}|>)/$tempbdescrip/gsm;
     $messageindex_template =~ s/({|<)yabb description(}|>)/$boarddescription/gsm;
     $messageindex_template =~ s/({|<)yabb colspan(}|>)/7/gsm;
   
     $messageindex_template =~
       s/({|<)yabb pageindex top(}|>)/$temppageindex1/gsm;
     $messageindex_template =~
       s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/gsm;
     $messageindex_template =~ s/({|<)yabb new_load(}|>)//gsm;
   
     require Sources::Menu;
     $notify_board = SetImage('notify', $UseMenuType);
     $markalllink  = SetImage('markboardread', $UseMenuType);
     $postlink     = SetImage('newthread', $UseMenuType);
     $polllink     = SetImage('createpoll', $UseMenuType);
     $menusep = q{&nbsp;};
     if ( $UseMenuType == 1 ) {
         $menusep = q{ | };
     }
     $topichandellist = q~{yabb notify button}{yabb markall button}~;
     if ( $useThreadtools == 1 ) {
         $notify_board = SetImage('notify', 3);
         ($notify_board_img, $notify_board_txt ) = split /[|]/xsm, $notify_board;
         $markall_board = SetImage('markboardread', 3);
         ($markall_board_img, $markall_board_txt ) = split /[|]/xsm, $markall_board;
         $topichandellist = qq~<td class="post_tools center template" style="width:10em"><div class="post_tools_a">
         <a href="javascript:quickLinks('threadtools1')">$maintxt{'62'}</a>
     </div>
     </td>
     <td class="center bottom" style="padding:0px; width:0">
     <div class="right cursor toolbutton_b">
         <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
             <li><div class="toolbutton_a" style="background-image: url($notify_board_img)">$notify_board_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($markall_board_img)">$markall_board_txt</div></li>
         </ul>
     </div>~;
     }
     $outside_threadtools = q~{yabb new post button}{yabb new poll button}~;
     $outside_threadtools =~ s/{yabb new post button}/$menusep$postlink/gsm;
     $outside_threadtools =~ s/{yabb new poll button}/$menusep$polllink/gsm;
     $topichandellist =~ s/{yabb notify button}/$menusep$notify_board/gsm;
     $topichandellist =~ s/{yabb markall button}/$menusep$markalllink/gsm;
     $topichandellist     = $outside_threadtools . $topichandellist;
   
     $topichandellist =~ s/\Q$menusep//ism;
   
     $messageindex_template =~
       s/({|<)yabb topichandellist(}|>)/$topichandellist/gsm;
     $messageindex_template =~
       s/({|<)yabb topichandellist2(}|>)/$topichandellist/gsm;
     $messageindex_template =~
       s/class="post_tools center" style="width:10em"/class="right"/gsm;
   
     $messageindex_template =~ s/({|<)yabb pageindex(}|>)/$temppageindex/gsm;
     $messageindex_template =~
       s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/gsm;
     $messageindex_template =~ s/({|<)yabb admin column(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb outsidethreadtools(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb topicpreview(}|>)//gsm;
   
     my $tempbar = $threadbar;
     $tempbar =~ s/({|<)yabb admin column(}|>)//gsm;
     $tempbar =~ s/({|<)yabb threadpic(}|>)/$tempthreadpic/gsm;
     $tempbar =~ s/({|<)yabb icon(}|>)/$tempmicon/gsm;
     $tempbar =~ s/({|<)yabb new(}|>)/$tempnew/gsm;
     $tempbar =~ s/({|<)yabb poll(}|>)//gsm;
     $tempbar =~ s/({|<)yabb favorite(}|>)//gsm;
     $tempbar =~ s/({|<)yabb subjectlink(}|>)/$tempmsublink/gsm;
     $tempbar =~ s/({|<)yabb pages(}|>)//gsm;
     $tempbar =~ s/({|<)yabb attachmenticon(}|>)/$temp_attachment/gsm;
     $tempbar =~ s/({|<)yabb starter(}|>)/$tempmname/gsm;
     $tempbar =~ s/({|<)yabb starttime(}|>)/ timeformat($date)/egsm;
     $tempbar =~ s/({|<)yabb replies(}|>)/2/gsm;
     $tempbar =~ s/({|<)yabb views(}|>)/12/gsm;
     $tempbar =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/gsm;
     $tempbar =~ s/({|<)yabb lastposter(}|>)/$templastposter/gsm;
   
     if ( $accept_permalink == 1 ) {
         $tempbar =~ s/({|<)yabb permalink(}|>)/$message_permalink/gsm;
     }
     else {
         $tempbar =~ s/({|<)yabb permalink(}|>)//gsm;
     }
   
     $tmptempbar .= $tempbar;
   
     $messageindex_template =~ s/({|<)yabb threadblock(}|>)/$tmptempbar/gsm;
     $messageindex_template =~ s/({|<)yabb modupdate(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb modupdateend(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb stickyblock(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb adminfooter(}|>)//gsm;
     $messageindex_template =~ s/({|<)yabb icons(}|>)/$tempyabbicons/gsm;
     $messageindex_template =~
       s/({|<)yabb admin icons(}|>)/$tempyabbadminicons/gsm;
     $messageindex_template =~ s/({|<)yabb access(}|>)//gsm;
     $messageindex_template =~
       s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $messageindex_template =~
       s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $messageindex_template =~ s/^\s+//gsm;
     $messageindex_template =~ s/\s+$//gsm;
     $imagesdir = $tmpimagesdir;
     return $messageindex_template;
  }
   
  sub DisplayTempl {
     my @x = @_;
     LoadLanguage('Display');
     my $tmpimagesdir = $imagesdir;
     $imagesdir = $x[1];
     require "$templatesdir/$x[0]/Display.template";
     (
         $title,     $stars,      $starpic,    $color,     $noshow,
         $viewperms, $topicperms, $replyperms, $pollperms, $attachperms
     ) = split /\|/xsm, $Group{'Administrator'};
   
     my $template_home = qq~<span class="nav">$mbname</span>~;
     my $tempcatnm     = $templ_txt{'72'};
     my $tempboardnm   = $templ_txt{'73'};
     my $tempmodslink =
  qq~($display_txt{'298'}: $templ_txt{'74'} - $display_txt{'298a'}: $templ_txt{'74a'})~;
     my $template_prev    = $display_txt{'768'};
     my $template_next    = $display_txt{'767'};
     my $temppageindextgl = qq~<img src="$x[1]/xx.gif" alt="" />~;
     my $temppageindex1 =
  qq~<span class="small" style="vertical-align: middle;"> <b>$display_txt{'139'}:</b> 1</span>~;
   
  ## Make Buttons ##
     require Sources::Menu;
     $replybutton          = SetImage('reply', $UseMenuType);
     $pollbutton           = SetImage('addpoll', $UseMenuType);
     $notify               = SetImage('notify', $UseMenuType);
     $favorite             = SetImage('favorites', $UseMenuType);
     $template_sendtopic   = SetImage('sendtopic', $UseMenuType);
     $template_print       = SetImage('print', $UseMenuType);
     $template_alertmod    = SetImage('alertmod', $UseMenuType);
     $template_quote       = SetImage('quote', $UseMenuType);
     $template_modify      = SetImage('modify', $UseMenuType);
     $template_split       = SetImage('admin_split', $UseMenuType);
     $template_delete      = SetImage('delete', $UseMenuType);
     $template_print_post  = SetImage('printp', $UseMenuType);
     $template_email  = SetImage('email_sm', $UseMenuType);
     $template_pm     = SetImage('message_sm', $UseMenuType);
     $template_remove = SetImage('admin_rem', $UseMenuType);
     $template_splice = SetImage('admin_move_split_splice', $UseMenuType);
     $template_lock   = SetImage('admin_lock', $UseMenuType);
     $template_hide   = SetImage('hide', $UseMenuType);
     $template_sticky = SetImage('admin_sticky', $UseMenuType);
     $replybutton          = qq~$menusep$replybutton~;
     $pollbutton           = qq~$menusep$pollbutton~;
     $notify               = qq~$menusep$notify~;
     $favorite             = qq~$menusep$favorite~;
     $template_sendtopic   = qq~$menusep$template_sendtopic~;
     $template_print       = qq~$menusep$template_print~;
     $menusep = q{&nbsp;};
     if ( $UseMenuType == 1 ) {
         $menusep = q{ | };
     }
     $outside_threadtools = q~{yabb reply}{yabb poll}~;
     $threadhandellist = q~{yabb notify}{yabb favorite}{yabb sendtopic}{yabb print}{yabb markunread}~;
     if ( $useThreadtools == 1 ) {
         $notify               = SetImage('notify', 3);
         ($notify_board_img, $notify_board_txt ) = split /[|]/xsm, $notify;
         $favorite             = SetImage('favorites', 3);
         ($fav_board_img, $fav_board_txt ) = split /[|]/xsm, $favorite;
         $template_sendtopic   = SetImage('sendtopic', 3);
         ($send_board_img, $send_board_txt ) = split /[|]/xsm, $template_sendtopic;
         $template_print       = SetImage('print', 3);
         ($print_board_img, $print_board_txt ) = split /[|]/xsm, $template_print;
         $threadhandellist = qq~<td class="post_tools center template" style="width:10em"><div class="post_tools_a">
         <a href="javascript:quickLinks('threadtools')">$maintxt{'62'}</a>
     </div>
     </td>
     <td class="center bottom" style="padding:0px; width:0">
     <div class="right cursor toolbutton_b">
         <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
             <li><div class="toolbutton_a" style="background-image: url($notify_board_img)">$notify_board_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($fav_board_img)">$fav_board_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($send_board_img)">$send_board_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($print_board_img)">$print_board_txt</div></li>
         </ul>
     </div>~;
     }
   
     $outside_threadtools =~ s/{yabb reply}/$menusep$replybutton/gsm;
     $outside_threadtools =~ s/{yabb poll}/$menusep$pollbutton/gsm;
     my $template_threadimage = qq~<img src="$x[1]/thread.gif" alt="" />~;
     my $threadurl            = $templ_txt{'75'};
     $template_alertmod    = qq~$menusep$template_alertmod~;
     $template_quote       = qq~$menusep$template_quote~;
     $template_modify      = qq~$menusep$template_modify~;
     $template_split       = qq~$menusep$template_split~;
     $template_delete      = qq~$menusep$template_delete~;
     $template_print_post  = qq~$menusep$template_print_post~;
     my $memberinfo        = qq~<span class="small"><b>$title</b></span>~;
     my $usernamelink =
  qq~<span style="color: $color;"><b>${$uid.$username}{'realname'}</b></span><br />~;
   
     for ( 1 .. 5 ) {
         $star .= qq(<img src="$x[1]/$starpic" alt="*" />);
     }
     my $msub     = $templ_txt{'76'};
     my $msgimg   = qq~<img src="$x[1]/xx.gif" alt="" />~;
     my $messdate = timeformat($date);
     my $template_postinfo =
       qq~$display_txt{'21'}: ${$uid.$username}{'postcount'}<br />~;
     my $template_usertext = qq~${$uid.$username}{'usertext'}<br />~;
     my $px = 'px';
     my $avatar =
  qq~<img src="$facesurl/elmerfudd.gif" alt="" style="max-width: 50px; max-height: 50px" />~;
     my $message =
       qq~$templ_txt{'65'}<br /><a href="javascript:;">$templ_txt{'66'}</a>~;
     $template_email  = qq~$menusep$template_email~;
     $template_pm     = qq~$menusep$template_pm~;
     my $ipimg           = qq~<img src="$imagesdir/ip.gif" alt="" />~;
     $template_remove = qq~$menusep$template_remove~;
     $template_splice = qq~$menusep$template_splice~;
     $template_lock   = qq~$menusep$template_lock~;
     $template_hide   = qq~$menusep$template_hide~;
     $template_sticky = qq~$menusep$template_sticky~;
   
     $online = qq~<span class="useronline">$maintxt{'60'}</span>~;
     for my $i ( 0 .. 1 ) {
         my $outblock        = $messageblock;
         my $posthandelblock = $posthandellist;
         my $contactblock    = $contactlist;
   
         if ( $i == 0 ) {
             $css          = q~windowbg~;
             $counterwords = q{};
         }
         else {
             $css          = q~windowbg2~;
             $counterwords = "$display_txt{'146'} #$i";
         }
         $posthandelblock =~ s/({|<)yabb modalert(}|>)/$template_alertmod/gsm;
         $posthandelblock =~ s/({|<)yabb quote(}|>)/$template_quote/gsm;
         $posthandelblock =~ s/({|<)yabb modify(}|>)/$template_modify/gsm;
         $posthandelblock =~ s/({|<)yabb split(}|>)/$template_split/gsm;
         $posthandelblock =~ s/({|<)yabb delete(}|>)/$template_delete/gsm;
         $posthandelblock =~ s/({|<)yabb admin(}|>)/$template_admin/gsm;
         $posthandelblock =~ s/({|<)yabb print_post(}|>)/$template_print_post/gsm;
         $posthandelblock =~ s/\Q$menusep//ism;
         $outside_posttools = qq~{yabb quote}{yabb markquote}~;
         $posthandellist = qq~{yabb modalert}{yabb print_post}{yabb modify}{yabb split}{yabb delete}~;
         if ( $usePosttools == 1 ) {
             $template_alertmod    = SetImage('alertmod', 3);
             ($template_alertmod_img, $template_alertmod_txt ) = split /[|]/xsm, $template_alertmod;
             $template_modify      = SetImage('modify', 3);
             ($template_modify_img, $template_modify_txt ) = split /[|]/xsm, $template_modify;
             $template_split       = SetImage('admin_split', 3);
             ($template_split_img, $template_split_txt ) = split /[|]/xsm, $template_split;
             $template_delete      = SetImage('delete', 3);
             ($template_delete_img, $template_delete_txt ) = split /[|]/xsm, $template_delete;
             $template_print_post  = SetImage('printp', 3);
             ($template_print_post_img, $template_print_post_txt ) = split /[|]/xsm, $template_print_post;
             $posthandelblock = qq~<td class="post_tools center dividerbot template" style="width:100px; height: 2em; vertical-align:middle"><div class="post_tools_a">
         <a href="javascript:quickLinks('threadtools')">$maintxt{'63'}</a>
     </div>
     </td>
     <td class="center bottom" style="padding:0px; width:0">
     <div class="right cursor toolbutton_b">
         <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
             <li><div class="toolbutton_a" style="background-image: url($template_modify_img)">$template_modify_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($template_split_img)">$template_split_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($template_delete_img)">$template_delete_txt</div></li>
             <li><div class="toolbutton_a" style="background-image: url($template_print_post_img)">$template_print_post_txt</div></li>
         </ul>
     </div>~;
         }
         $contactblock =~ s/({|<)yabb email(}|>)/$template_email/gsm;
         $contactblock =~ s/({|<)yabb profile(}|>)//gsm;
         $contactblock =~ s/({|<)yabb pm(}|>)/$template_pm/gsm;
         $contactblock =~ s/({|<)yabb www(}|>)//gsm;
         $contactblock =~ s/({|<)yabb aim(}|>)//gsm;
         $contactblock =~ s/({|<)yabb yim(}|>)//gsm;
         $contactblock =~ s/({|<)yabb icq(}|>)//gsm;
         $contactblock =~ s/({|<)yabb gtalk(}|>)//gsm;
         $contactblock =~ s/({|<)yabb skype(}|>)//gsm;
         $contactblock =~ s/({|<)yabb myspace(}|>)//gsm;
         $contactblock =~ s/({|<)yabb facebook(}|>)//gsm;
         $contactblock =~ s/({|<)yabb twitter(}|>)//gsm;
         $contactblock =~ s/({|<)yabb youtube(}|>)//gsm;
         $contactblock =~ s/({|<)yabb addbuddy(}|>)//gsm;
         $contactblock =~ s/\Q$menusep//ism;
   
         $outblock =~ s/({|<)yabb images(}|>)/$tmpimagesdir/gsm;
         $outblock =~ s/({|<)yabb messageoptions(}|>)//gsm;
         $outblock =~ s/({|<)yabb memberinfo(}|>)/$memberinfo/gsm;
         $outblock =~ s/({|<)yabb userlink(}|>)/$usernamelink/gsm;
         $outblock =~ s/({|<)yabb stars(}|>)/$star/gsm;
         $outblock =~ s/({|<)yabb subject(}|>)/$msub/gsm;
         $outblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/gsm;
         $outblock =~ s/({|<)yabb msgdate(}|>)/$messdate/gsm;
         $outblock =~ s/({|<)yabb replycount(}|>)/$counterwords/gsm;
         $outblock =~ s/({|<)yabb count(}|>)//gsm;
         $outblock =~ s/({|<)yabb att(}|>)//gsm;
         $outblock =~ s/({|<)yabb css(}|>)/$css/gsm;
         $outblock =~ s/({|<)yabb gender(}|>)//gsm;
         $outblock =~ s/({|<)yabb zodiac(}|>)//gsm;
         $outblock =~ s/({|<)yabb age(}|>)//gsm;
         $outblock =~ s/({|<)yabb regdate(}|>)//gsm;
         $outblock =~ s/({|<)yabb ext_prof(}|>)/$template_ext_prof/gsm;
         $outblock =~ s/({|<)yabb location(}|>)//gsm;
         $outblock =~ s/({|<)yabb isbuddy(}|>)//gsm;
         $outblock =~ s/({|<)yabb useronline(}|>)/$online/gsm;
         $outblock =~ s/({|<)yabb postinfo(}|>)/$template_postinfo/gsm;
         $outblock =~ s/({|<)yabb usertext(}|>)/$template_usertext/gsm;
         $outblock =~ s/({|<)yabb userpic(}|>)/$avatar/gsm;
         $outblock =~ s/({|<)yabb message(}|>)/$message/gsm;
         $outblock =~ s/({|<)yabb showatt(}|>)//gsm;
         $outblock =~ s/({|<)yabb showatthr(}|>)//gsm;
         $outblock =~ s/({|<)yabb modified(}|>)//gsm;
         $outblock =~ s/({|<)yabb signature(}|>)//gsm;
         $outblock =~ s/({|<)yabb signaturehr(}|>)//gsm;
         $outblock =~ s/({|<)yabb ipimg(}|>)/$ipimg/gsm;
         $outblock =~ s/({|<)yabb ip(}|>)//gsm;
         $outblock =~ s/({|<)yabb permalink(}|>)//gsm;
         $outblock =~ s/({|<)yabb posthandellist(}|>)/$posthandelblock/gsm;
         $outblock =~ s/({|<)yabb outsideposttools(}|>)//gsm;
         $outblock =~ s/({|<)yabb admin(}|>)//gsm;
         $outblock =~ s/({|<)yabb contactlist(}|>)/$contactblock/gsm;
  ## Mod Hook Outblock ##
  ## End Mod Hook Outblock ##
         $tempoutblock .= $outblock;
     }
     $threadhandellist     = $outside_threadtools . $threadhandellist;
     $threadhandellist =~ s/({|<)yabb notify(}|>)/$notify/gsm;
     $threadhandellist =~ s/({|<)yabb favorite(}|>)/$favorite/gsm;
     $threadhandellist =~ s/({|<)yabb sendtopic(}|>)/$template_sendtopic/gsm;
     $threadhandellist =~ s/({|<)yabb print(}|>)/$template_print/gsm;
     $threadhandellist =~ s/({|<)yabb markunread(}|>)//gsm;
     $threadhandellist =~ s/<td class="dividerbot" colspan="3" style="vertical-align:middle;">/<td class="dividerbot" colspan="2" style="vertical-align:middle;">/gsm;
     $threadhandellist =~ s/<td class="post_tools center dividerbot" style="width:100px; height: 2em; vertical-align:middle">/<td class="center dividerbot" style="height: 2em; vertical-align:middle">/gsm;
     $threadhandellist =~ s/\Q$menusep//ism;
   
     $adminhandellist =~ s/({|<)yabb remove(}|>)/$template_remove/gsm;
     $adminhandellist =~ s/({|<)yabb splice(}|>)/$template_splice/gsm;
     $adminhandellist =~ s/({|<)yabb lock(}|>)/$template_lock/gsm;
     $adminhandellist =~ s/({|<)yabb hide(}|>)/$template_hide/gsm;
     $adminhandellist =~ s/({|<)yabb sticky(}|>)/$template_sticky/gsm;
     $adminhandellist =~ s/({|<)yabb multidelete(}|>)/$template_multidelete/gsm;
     $adminhandellist =~ s/\Q$menusep//ism;
   
     $display_template =~ s/({|<)yabb pollmain(}|>)//gsm;
     $display_template =~ s/({|<)yabb topicviewers(}|>)//gsm;
   
     $display_template =~ s/({|<)yabb home(}|>)/$template_home/gsm;
     $display_template =~ s/({|<)yabb category(}|>)/$tempcatnm/gsm;
     $display_template =~ s/({|<)yabb board(}|>)/$tempboardnm/gsm;
     $display_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/gsm;
     $display_template =~ s/({|<)yabb prev(}|>)/$template_prev/gsm;
     $display_template =~ s/({|<)yabb next(}|>)/$template_next/gsm;
     $display_template =~
       s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/gsm;
     $display_template =~ s/({|<)yabb pageindex top(}|>)/$temppageindex1/gsm;
     $display_template =~ s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/gsm;
     $display_template =~ s/({|<)yabb bookmarks(}|>)//gsm; # Social Bookmarks
     $display_template =~
       s/({|<)yabb threadhandellist(}|>)/$threadhandellist/gsm;
     $display_template =~
       s/({|<)yabb threadhandellist2(}|>)/$threadhandellist/gsm;
     $display_template =~ s/({|<)yabb outsidethreadtools(}|>)//gsm;
     $display_template =~ s/({|<)yabb threadimage(}|>)/$template_threadimage/gsm;
     $display_template =~ s/({|<)yabb threadurl(}|>)/$threadurl/gsm;
     $display_template =~ s/({|<)yabb views(}|>)/12/gsm;
     $display_template =~ s/({|<)yabb multistart(}|>)//gsm;
     $display_template =~ s/({|<)yabb multiend(}|>)//gsm;
     $display_template =~ s/({|<)yabb postsblock(}|>)/$tempoutblock/gsm;
     $display_template =~ s/({|<)yabb adminhandellist(}|>)/$adminhandellist/gsm;
     $display_template =~ s/({|<)yabb forumselect(}|>)//gsm;
     $display_template =~ s/({|<)yabb guestview(}|>)//gsm;
     $display_template =~ s/({|<)yabb reason(}|>)//gsm;
     $display_template =~ s/<td class="dividerbot" style="vertical-align:middle;">/<td class="dividerbot" style="vertical-align:middle;" colspan="2">/gsm;
     $display_template =~ s/<td class="post_tools center dividerbot" style="width:100px; height: 2em; vertical-align:middle">/<td class="center dividerbot" style="height: 2em; vertical-align:middle">/gsm;
     $display_template =~ s/class="post_tools center" style="width:100px"/class="right"/gsm;
     $display_template =~ s/class="post_tools center" style="width:10em"/class="right"/gsm;
     $display_template =~ s/class="windowbg2 vtop" style="height:10em" colspan="3"/class="windowbg2 vtop" colspan="4" style="height:10em"/gsm;
     $display_template =~ s/class="windowbg vtop" style="height:10em" colspan="3"/class="windowbg vtop" colspan="4" style="height:10em"/gsm;
     $display_template =~ s/class="windowbg2 bottom" style="height:12px" colspan="3"/class="windowbg2 bottom" colspan="4" style="height:12px"/gsm;
     $display_template =~ s/class="windowbg bottom" style="height:12px" colspan="3"/class="windowbg bottom" colspan="4" style="height:12px"/gsm;
     $display_template =~ s/class="windowbg2 bottom" colspan="3"/class="windowbg2 bottom" colspan="4"/gsm;
     $display_template =~ s/class="windowbg bottom" colspan="3"/class="windowbg bottom" colspan="4"/gsm;
     $display_template =~ s/class="windowbg2 bottom dividertop" colspan="3"/class="windowbg2 bottom dividertop" colspan="4"/gsm;
     $display_template =~ s/class="windowbg bottom dividertop" colspan="3"/class="windowbg bottom dividertop" colspan="4"/gsm;
     $display_template =~
       s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $display_template =~
       s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $display_template =~ s/^\s+//gsm;
     $display_template =~ s/\s+$//gsm;
     $imagesdir = $tmpimagesdir;
     return $display_template;
  }
   
  sub MyCenterTempl {
     my @x = @_;
     LoadLanguage('InstantMessage');
     LoadLanguage('MyCenter');
     my $tmpimagesdir = $imagesdir;
     $imagesdir = $x[1];
     require "$templatesdir/$x[0]/MyCenter.template";
   
     $tabsep = q{};
     $tabfill = qq~<img src="$imagesdir/tabfill.gif" alt="" />~;
   
     if (   $PM_level == 1
         || ( $PM_level == 2 && ( $iamadmin || $iamgmod || $iammod ) )
         || ( $PM_level == 3 && ( $iamadmin || $iamgmod ) ) )
     {
         $yymcmenu .=
  qq~<span title="$mc_menus{'messages'}" class="selected">$tabsep$tabfill$mc_menus{'messages'}$tabfill</span>
                 ~;
     }
   
     $yymcmenu .=
  qq~$tabsep<span title="$mc_menus{'profile'}">$tabfill$mc_menus{'profile'}$tabfill</span>~;
     $yymcmenu .=
  qq~$tabsep<span title="$mc_menus{'posts'}">$tabfill$mc_menus{'posts'}$tabfill</span>~;
     $yymcmenu .= qq~$tabsep~;
   
     $mycenter_template =~ s/{yabb mcviewmenu}/$MCViewMenu/gsm;
     $mycenter_template =~ s/{yabb mcmenu}/$yymcmenu/gsm;
     $mycenter_template =~ s/{yabb mcpmmenu}/$MCPmMenu/gsm;
     $mycenter_template =~ s/{yabb mcprofmenu}/$MCProfMenu/gsm;
     $mycenter_template =~ s/{yabb mcpostsmenu}/$MCPostsMenu/gsm;
     $mycenter_template =~ s/{yabb mcglobformstart}/$MCGlobalFormStart/gsm;
     $mycenter_template =~
       s/{yabb mcglobformend}/ ($MCGlobalFormStart ? "<\/form>" : q{}) /esm;
     $mycenter_template =~ s/{yabb mccontent}/$MCContent/gsm;
     $mycenter_template =~ s/{yabb mctitle}/$mctitle/gsm;
     $mycenter_template =~ s/{yabb selecthtml}/$selecthtml/gsm;
   
     $mycenter_template =~
       s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $mycenter_template =~
       s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
     $mycenter_template =~ s/^\s+//gsm;
     $mycenter_template =~ s/\s+$//gsm;
     $imagesdir = $tmpimagesdir;
     return $mycenter_template;
  }
   
  sub UpdateTemplates {
     my ( $tempelement, $tempjob ) = @_;
     if ( $tempjob eq 'save' ) {
         $templateset{"$tempelement"} = "$template_css";
         $templateset{"$tempelement"} .= "|$template_images";
         $templateset{"$tempelement"} .= "|$template_head";
         $templateset{"$tempelement"} .= "|$template_board";
         $templateset{"$tempelement"} .= "|$template_message";
         $templateset{"$tempelement"} .= "|$template_display";
         $templateset{"$tempelement"} .= "|$template_mycenter";
         $templateset{"$tempelement"} .= "|$template_menutype";
         $templateset{"$tempelement"} .= "|$template_threadtools";
         $templateset{"$tempelement"} .= "|$template_posttools";
     }
     elsif ( $tempjob eq 'delete' ) {
         delete $templateset{$tempelement};
     }
   
     require Admin::NewSettings;
     SaveSettingsTo('Settings.pm');
     return;
} }
   
sub ModifyStyle { sub ModifyStyle {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my ($fullcss, $line, $csstype);     my ( $fullcss, $line, $csstype ); 
   $admincs = 0;    $admincs = 0;
   if ($FORM{'cssfile'}) { $cssfile = $FORM{'cssfile'}; $csstype = qq~$forumstylesdir/$cssfile~; }     if ( $FORM{'cssfile'} ) { 
   elsif ($FORM{'admcssfile'}) { $cssfile = $FORM{'admcssfile'}; $csstype = qq~$adminstylesdir/$cssfile~; $admincs = 1; }         $cssfile = $FORM{'cssfile'}; 
   else { $cssfile = "default.css"; $csstype = qq~$forumstylesdir/$cssfile~; }         $csstype = qq~$htmldir/Templates/Forum/$cssfile~; 
   opendir(TMPLDIR, "$forumstylesdir");     } 
   @styles = readdir(TMPLDIR);     elsif ( $FORM{'admcssfile'} ) { 
   closedir(TMPLDIR);         $cssfile = $FORM{'admcssfile'}; 
   $forumcss = "";         $csstype = qq~$htmldir/Templates/Admin/$cssfile~; 
   $forumcss = qq~<option value=""></option>\n~;         $admincs = 1; 
     }
   foreach $file (sort @styles) {     else { $cssfile = 'default.css'; 
       ($name, $ext) = split(/\./, $file);         $csstype = qq~$htmldir/Templates/Forum/$cssfile~; 
       $selected = "";     } 
       if ($ext eq 'css') {     opendir TMPLDIR, "$htmldir/Templates/Forum"; 
           if ($file eq $cssfile && !$admincs) { $selected = qq~ selected="selected"~; }     @styles = readdir TMPLDIR; 
           $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;     closedir TMPLDIR; 
       }  
   }     $forumcss = qq~<option value="" disabled="disabled">--</option>\n~; 
     foreach my $file ( sort @styles ) {
   opendir(TMPLDIR, "$adminstylesdir");         if ( $file ne 'calscroller.css' && $file ne 'setup.css' ) { 
   @astyles = readdir(TMPLDIR);             ( $name, $ext, $bak ) = split /\./xsm, $file; 
   closedir(TMPLDIR);             $selected = q{}; 
   $admincss = "";             if ( !$bak && $ext eq 'css' ) { 
   $admincss = qq~<option value=""></option>\n~;                 if ( $file eq $cssfile && !$admincs ) { 
   foreach $file (sort @astyles) {                     $selected = q~ selected="selected"~; 
       ($name, $ext) = split(/\./, $file);                 } 
       $selected = "";                 $forumcss .= qq~<option value="$file"$selected>$name</option>\n~; 
       if ($ext eq 'css') {             } 
           if ($file eq $cssfile && $admincs) { $selected = qq~ selected="selected"~; }        }
           $admincss .= qq~<option value="$file"$selected>$name</option>\n~;     } 
       }  
   }     opendir TMPLDIR, "$htmldir/Templates/Admin"; 
     @astyles = readdir TMPLDIR;
   fopen(CSS, "$csstype") or &admin_fatal_error("cannot_open","$csstype");     closedir TMPLDIR; 
   while ($line = <CSS>) {     $admincss = qq~<option value="" disabled="disabled">--</option>\n~; 
       $line =~ s~[\r\n]~~g;     foreach my $file ( sort @astyles ) { 
       $line =~ s~&nbsp;~&#38;nbsp;~g;         ( $name, $ext, $bak ) = split /\./xsm, $file; 
       $line =~ s~&amp;~&#38;amp;~g;         $selected = q{}; 
       &FromHTML($line);         if ( !$bak && $ext eq 'css' ) { 
       $fullcss .= qq~$line\n~;             if ( $file eq $cssfile && $admincs ) { 
   }                 $selected = q~ selected="selected"~; 
   fclose(CSS);             } 
             $admincss .= qq~<option value="$file"$selected>$name</option>\n~;
   $yymain .= qq~         } 
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">     } 
  <table width="100%" cellspacing="1" cellpadding="4">  
   <form action="$adminurl?action=modcss;cssfile=$cssfile" name="modcss" method="post" style="display: inline;">     fopen( CSS, "$csstype" ) or fatal_error( 'cannot_open', "$csstype" ); 
   <tr>     while ( $line = <CSS> ) { 
       <td align="left" valign="middle" class="titlebg">         $line =~ s/[\r\n]//gxsm; 
       <img src="$imagesdir/xx.gif" alt="" border="0" /><b> $templ_txt{'51'}</b> - $cssfile &nbsp;         $line =~ s/&nbsp;/&#38;nbsp;/gsm; 
       <input type="submit" name="wysiwyg" id="wysiwyg" value="wysiwyg" class="button" />         $line =~ s/&amp;/&#38;amp;/gsm; 
       <input type="button" name="source" id="source" value=" source " disabled="disabled" />         FromHTML($line); 
       </td>         $fullcss .= qq~$line\n~; 
   </tr>     } 
   </form>     fclose(CSS); 
   <form action="$adminurl?action=modstyle2" method="post">  
   <tr valign="middle">     $yymain .= qq~ 
       <td align="center" class="windowbg2">  <div class="bordercolor rightboxdiv"> 
       <input type="hidden" name="filename" value="$cssfile" />     <form action="$adminurl?action=modcss;cssfile=$cssfile" name="modcss" method="post" style="display: inline;" accept-charset="$yymycharset"> 
       <input type="hidden" name="type" value="$admincs" />     <table class="border-space pad-cell"> 
       <textarea rows="20" cols="95" name="css" style="width: 99%; height: 350px;">$fullcss</textarea>         <tr> 
       </td>             <td class="titlebg"> 
   </tr>                 $admin_img{'xx'} <b> $templ_txt{'51'}</b> - $cssfile &nbsp; 
   <tr valign="middle">                 <input type="submit" name="wysiwyg" id="wysiwyg" value=" wysiwyg " class="button" /> 
       <td align="center" class="catbg">                 <input type="button" name="source" id="source" value=" source " disabled="disabled" /> 
       <input type="submit" value="$admin_txt{'10'} $cssfile" class="button" />             </td> 
       </td>         </tr> 
   </tr>     </table> 
   </form>    </form>
   <tr>     <table class="border-space pad-cell" style="margin-bottom:.5em"> 
       <td align="left" class="windowbg2">         <tr> 
       <div style="float: left; width: 30%; padding: 3px;"><b>$templ_txt{'1'}</b></div>             <td class="windowbg2"> 
       <div style="float: left; width: 69%;">                 <div style="float: left; width: 30%; padding: 3px;"><b>$templ_txt{'1'}</b></div> 
       <form action="$adminurl?action=modstyle" name="selcss" method="post" style="display: inline;">                 <div style="float: left; width: 69%;"> 
       <div class="small" style="float: left; width: 25%;"><label for="cssfile">$templ_txt{'forum'}:</label><br />                     <form action="$adminurl?action=modstyle" name="selcss" method="post" style="display: inline;" accept-charset="$yymycharset"> 
         <select name="cssfile" id="cssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.aselcss.admcssfile.selectedIndex = '0'; submit(); }">                     <div class="small" style="float: left; width: 25%;"><label for="cssfile" style="font-weight:bold">$templ_txt{'forum'}:</label><br /> 
           $forumcss                     <select name="cssfile" id="cssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.aselcss.admcssfile.selectedIndex = '0'; submit(); }"> 
         </select><br />                         $forumcss 
       <noscript><input type="submit" value="$admin_txt{'32'}" style="width: 90%;" class="button" /></noscript>                     </select> 
       </div>                     <br /> 
       </form>                     </div> 
       <form action="$adminurl?action=modstyle" name="aselcss" method="post" style="display: inline;">                     </form> 
       <div class="small" style="float: left; width: 25%;"><label for="admcssfile">$templ_txt{'admincenter'}:</label><br />                     <form action="$adminurl?action=modstyle" name="aselcss" method="post" style="display: inline;" accept-charset="$yymycharset"> 
         <select name="admcssfile" id="admcssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.selcss.cssfile.selectedIndex = '0'; submit(); }">                     <div class="small" style="float: left; width: 25%;"><label for="admcssfile" style="font-weight:bold">$templ_txt{'admincenter'}:</label><br /> 
           $admincss                     <select name="admcssfile" id="admcssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.selcss.cssfile.selectedIndex = '0'; submit(); }"> 
         </select><br />                         $admincss 
       <noscript><input type="submit" value="$admin_txt{'32'}" style="width: 90%;" class="button" /></noscript>                     </select> 
       </div>                     <br /> 
       </form>                     </div> 
       </div>                     </form> 
       </td>                 </div> 
   </tr>             </td> 
  </table>         </tr> 
</div>     </table> 
  </div>
  <div class="bordercolor borderstyle rightboxdiv">
     <form action="$adminurl?action=modstyle2" method="post" accept-charset="$yymycharset">
     <table class="border-space pad-cell" style="margin-bottom: .5em;">
         <tr>
             <td class="windowbg2 center">
                 <input type="hidden" name="filename" value="$cssfile" />
                 <input type="hidden" name="type" value="$admincs" />
                 <textarea rows="20" cols="95" name="css" style="width: 99%; height: 350px;; font-family:Courier">$fullcss</textarea>
             </td>
         </tr>
     </table>
  </div>
  <div class="bordercolor rightboxdiv">
     <table class="border-space pad-cell">
         <tr>
             <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
         </tr><tr>
             <td class="catbg center">
                 <input type="submit" value="$admin_txt{'10'} $cssfile" class="button" />
             </td>
         </tr>
     </table>
     </form>
  </div>
   
~; ~;
   $yytitle = $templ_txt{'1'};    $yytitle     = $templ_txt{'1'};
   $action_area = "modcss";     $action_area = 'modcss'; 
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub ModifyStyle2 { sub ModifyStyle2 {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   $FORM{'css'} =~ tr/\r//d;    $FORM{'css'} =~ tr/\r//d;
   $FORM{'css'} =~ s~\A\n~~;     $FORM{'css'} =~ s/\A\n//xsm; 
   $FORM{'css'} =~ s~\n\Z~~;     $FORM{'css'} =~ s/\n\Z//xsm; 
   
   if ($FORM{'filename'}) { $cssfile = $FORM{'filename'}; }    if   ( $FORM{'filename'} ) { $cssfile = $FORM{'filename'}; }
   else { $cssfile = "default.css"; }    else                       { $cssfile = 'default.css'; }
   if ($FORM{'type'}) {    if ( $FORM{'type'} ) {
       fopen(CSS, ">$adminstylesdir/$cssfile") || &admin_fatal_error("cannot_open","$adminstylesdir/$cssfile", 1);         fopen( CSS, ">$htmldir/Templates/Admin/$cssfile" ) 
   } else {           || fatal_error( 'cannot_open', "$htmldir/Templates/Admin/$cssfile", 1 ); 
       fopen(CSS, ">$forumstylesdir/$cssfile") || &admin_fatal_error("cannot_open","$forumstylesdir/$cssfile", 1);     } 
   }     else { 
   print CSS "$FORM{'css'}\n";         fopen( CSS, ">$htmldir/Templates/Forum/$cssfile" ) 
   fclose(CSS);           || fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile", 1 ); 
   $yySetLocation = qq~$adminurl?action=modcss;cssfile=$cssfile~;     } 
   &redirectexit;     print {CSS} "$FORM{'css'}\n" or croak "$croak{'print'} CSS"; 
     fclose(CSS);
     $yySetLocation = qq~$adminurl?action=modcss;cssfile=$cssfile~;
     redirectexit();
     return;
} }
   
sub ModifyCSS { sub ModifyCSS {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   
   if ($INFO{'templateset'}) { $thistemplate = $INFO{'templateset'}; }    if   ( $INFO{'templateset'} ) { $thistemplate = $INFO{'templateset'}; }
   else { $thistemplate = "$template"; }    else                          { $thistemplate = "$template"; }
   
   while (($curtemplate, $value) = each(%templateset)) {    while ( ( $curtemplate, $value ) = each %templateset ) {
       if ($curtemplate eq $thistemplate) { $akttemplate = $curtemplate; }        if ( $curtemplate eq $thistemplate ) { $akttemplate = $curtemplate; }
   }    }
   
   ($aktstyle, $aktimages, $akthead, $aktboard, $aktmessage, $aktdisplay) = split(/\|/, $templateset{"$akttemplate"});     ( $aktstyle, $aktimages, $akthead, $aktboard, $aktmessage, $aktdisplay, $aktmenutype, $aktthreadtools, $aktposttools ) = 
       split /\|/xsm, $templateset{$akttemplate};
   my ($fullcss, $line);  
   if ($INFO{'cssfile'}) { $cssfile = $INFO{'cssfile'}; }     my ( $fullcss, $line ); 
   else { $cssfile = "$aktstyle.css"; }    if   ( $INFO{'cssfile'} ) { $cssfile = $INFO{'cssfile'}; }
     else                      { $cssfile = "$aktstyle.css"; }
   $tempimages = qq~$forumstylesurl/$aktimages~;  
   my $istabbed = 0;     $tempimages = qq~$yyhtml_root/Templates/Forum/$aktimages~; 
     my $istabbed = 0;
   $stylestr = "";  
     $cssbuttons = 0;
   opendir(TMPLDIR, "$forumstylesdir");     $stylestr = q{}; 
   @styles = readdir(TMPLDIR);  
   closedir(TMPLDIR);     opendir TMPLDIR, "$htmldir/Templates/Forum"; 
   $forumcss = "";     @styles = readdir TMPLDIR; 
   $imgdirs  = "";     closedir TMPLDIR; 
   foreach $file (sort @styles) {     $forumcss = q{}; 
       ($name, $ext) = split(/\./, $file);     $imgdirs  = q{}; 
       $selected = "";     foreach my $file ( sort @styles ) { 
       if ($ext eq 'css') {        if ( $file ne 'calscroller.css' && $file ne 'setup.css' ) {
           if ($file eq $cssfile) { $selected = qq~ selected="selected"~; $viewcss = $name; }         ( $name, $ext ) = split /\./xsm, $file; 
           $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;         $selected = q{}; 
       }             if ( $ext eq 'css' ) { 
   }                 if ( $file eq $cssfile ) { 
                     $selected = q~ selected="selected"~;
   fopen(CSS, "$forumstylesdir/$cssfile") or &admin_fatal_error("cannot_open","$forumstylesdir/$cssfile");                     $viewcss  = $name; 
   @thecss = <CSS>;                 } 
   fclose(CSS);                 $forumcss .= qq~<option value="$file"$selected>$name</option>\n~; 
   foreach $style_sgl (@thecss) {             } 
       $style_sgl =~ s/[\n\r]//g;         } 
       $style_sgl =~ s/\A\s*//;     } 
       $style_sgl =~ s/\s*\Z//;  
       $style_sgl =~ s/\t//g;     fopen( CSS, "$htmldir/Templates/Forum/$cssfile" ) 
       $style_sgl =~ s/\.\/default/$forumstylesurl\/default/g;       or fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile" ); 
       $style_sgl =~ s/\.\/$viewcss/$forumstylesurl\/$viewcss/g;     @thecss = <CSS>; 
       $stylestr .= qq~$style_sgl ~;     fclose(CSS); 
   }     foreach my $style_sgl (@thecss) { 
   $stylestr =~ s/\s{2,}/ /g;         $style_sgl =~ s/[\n\r]//gxsm; 
   my ($selstyl, $selhidden, $postsstyle, $seperatorstyle, $bodycontainerstyle, $bodystyle, $containerstyle, $titlestyle, $titlestyle_a, $categorystyle, $categorystyle_a, $window1style, $window2style, $inputstyle, $textareastyle, $selectstyle, $quotestyle, $codestyle, $editbgstyle, $highlightstyle,$gen_fontsize);         $style_sgl =~ s/\A\s*//xsm; 
         $style_sgl =~ s/\s*\Z//xsm;
   $gen_fontsize = qq~<select name="cssfntsize" id="cssfntsize" style="vertical-align: middle;" onchange="previewFont()">~;         $style_sgl =~ s/\t//gsm; 
   for ($i = 7; $i < 21; $i++) {         $style_sgl =~ s/^\s+//gsm; 
       $gen_fontsize .= qq~<option value="$i">$i</option>~;         $style_sgl =~ s/\s+$//gsm; 
   }         $style_sgl =~ s/\.\/default/$yyhtml_root\/Templates\/Forum\/default/gsm; 
   $gen_fontsize .= qq~</select>~;         $style_sgl =~ s/\.\/$viewcss/$yyhtml_root\/Templates\/Forum\/$viewcss/gsm; 
   $gen_fontface = qq~<select name="cssfntface" id="cssfntface" style="vertical-align: middle;" onchange="previewFontface()">         $style_sgl =~ s/\.\.\/\.\.\/Buttons/$yyhtml_root\/Buttons/gsm; 
       <option value="verdana">Verdana</option>         $stylestr .= qq~$style_sgl ~; 
       <option value="helvetica">Helvetica</option>     } 
       <option value="arial">Arial</option>     $stylestr =~ s/\s{2,}/ /gsm; 
       <option value="courier">Courier</option>     my ( 
       <option value="courier new">Courier New</option>         $selstyl,            $postsstyle,    $seperatorstyle, 
   </select>~;         $bodycontainerstyle, $bodystyle,     $containerstyle, 
   $gen_borderweigth = qq~<select name="borderweigth" id="borderweigth" style="vertical-align: middle;" onchange="previewBorder()">~;         $titlestyle,         $titlestyle_a,  $categorystyle, 
   for ($i = 0; $i < 6; $i++) {         $categorystyle_a,    $window1style,  $window2style, 
       $gen_borderweigth .= qq~<option value="$i">$i</option>~;         $inputstyle,         $textareastyle, $selectstyle, 
   }         $quotestyle,         $codestyle,     $editbgstyle, 
   $gen_borderweigth .= qq~</select>~;         $highlightstyle,     $gen_fontsize,  $userinfostyle 
   $gen_borderstyle = qq~<select name="borderstyle" id="borderstyle" style="vertical-align: middle;" onchange="previewBorder()">     ); 
       <option value="solid">$templ_txt{'43'}</option>  
       <option value="dashed">$templ_txt{'44'}</option>     $gen_fontsize = 
       <option value="dotted">$templ_txt{'45'}</option>  q~              <select name="cssfntsize" id="cssfntsize" style="vertical-align: middle;" onchange="previewFont()">~; 
       <option value="double">$templ_txt{'46'}</option>     for my $i ( 7 .. 20 ) { 
       <option value="groove">$templ_txt{'47'}</option>         $gen_fontsize .= qq~                <option value="$i">$i</option>~; 
       <option value="ridge">$templ_txt{'48'}</option>     } 
       <option value="inset">$templ_txt{'49'}</option>     $gen_fontsize .= q~ 
       <option value="outset">$templ_txt{'50'}</option>                 </select>~; 
   </select>~;     $gen_fontface = 
  q~              <select name="cssfntface" id="cssfntface" style="vertical-align: middle;" onchange="previewFontface()">
   if ($stylestr =~ /body/) {                     <option value="verdana">Verdana</option> 
       $bodystyle = $stylestr;                     <option value="helvetica">Helvetica</option> 
       $bodystyle =~ s/.*?(body\s*?\{.+?\}).*/$1/ig;                     <option value="arial">Arial</option> 
       $selstyl .= qq~<option value='$bodystyle' selected="selected">$templ_txt{'25'}</option>\n~;                     <option value="courier">Courier</option> 
   }                     <option value="courier new">Courier New</option> 
   if ($stylestr =~ /\#container/) {                 </select>~; 
       $containerstyle = $stylestr;     $gen_borderweigth = 
       $containerstyle =~ s/.*?(\#container\s*?\{.+?\}).*/$1/ig;  q~              <select name="borderweigth" id="borderweigth" style="vertical-align: middle;" onchange="previewBorder()">~; 
       $selstyl .= qq~<option value='$containerstyle'>$templ_txt{'26'}</option>\n~;     for my $i ( 0 .. 5 ) { 
   }         $gen_borderweigth .= qq~<option value="$i">$i</option>~; 
   if ($stylestr =~ /\.tabmenu/) {     } 
       $istabbed = 1;     $gen_borderweigth .= q~ 
   }                 </select>~; 
   if ($stylestr =~ /\.tabtitle/ && $istabbed) {     $gen_borderstyle = 
       $tabtitlestyle = $stylestr;  qq~             <select name="borderstyle" id="borderstyle" style="vertical-align: middle;" onchange="previewBorder()"> 
       $tabtitlestyle =~ s/.*?(\.tabtitle\s*?\{.+?\}).*/$1/ig;                     <option value="solid">$templ_txt{'43'}</option> 
       $tabtitlestyle = $tabtitlestyle;                     <option value="dashed">$templ_txt{'44'}</option> 
       $selstyl .= qq~<option value='$tabtitlestyle'>$templ_txt{'tabtitle'}</option>\n~;                     <option value="dotted">$templ_txt{'45'}</option> 
       if ($stylestr =~ /\.tabtitle a/) {                     <option value="double">$templ_txt{'46'}</option> 
           $tabtitlestyle_a = $stylestr;                     <option value="groove">$templ_txt{'47'}</option> 
           $tabtitlestyle_a =~ s/.*?(\.tabtitle a\s*?\{.+?\}).*/$1/ig;                     <option value="ridge">$templ_txt{'48'}</option> 
           $selstyl .= qq~<option value='$tabtitlestyle_a'>$templ_txt{'tabtitlea'}</option>\n~;                     <option value="inset">$templ_txt{'49'}</option> 
       }                     <option value="outset">$templ_txt{'50'}</option> 
   }                 </select>~; 
   if ($stylestr =~ /\.seperator/) {  
       $seperatorstyle = $stylestr;     if ( $stylestr =~ /body/sm ) { 
       $seperatorstyle =~ s/.*?(\.seperator\s*?\{.+?\}).*/$1/ig;         $bodystyle = $stylestr; 
       $selstyl .= qq~<option value='$seperatorstyle'>$templ_txt{'27'}</option>\n~;         $bodystyle =~ s/.*?(body\s*?\{.+?\}).*/$1/igsm; 
   }         $selstyl .= 
   if ($stylestr =~ /\.bordercolor/) {  qq~                 <option value="$bodystyle" selected="selected">$templ_txt{'25'}</option>\n~; 
       $bordercolorstyle = $stylestr;     } 
       $bordercolorstyle =~ s/.*?(\.bordercolor\s*?\{.+?\}).*/$1/ig;     if ( $stylestr =~ /\#container/sm ) { 
       $selstyl .= qq~<option value='$bordercolorstyle'>$templ_txt{'28'}</option>\n~;         $containerstyle = $stylestr; 
   }         $containerstyle =~ s/.*?(\#container.*?\{.+?\}).*/$1/igsm; 
   if ($stylestr =~ /\.hr/) {         $selstyl .= 
       $hrstyle = $stylestr;           qq~                   <option value='$containerstyle'>$templ_txt{'26'}</option>\n~; 
       $hrstyle =~ s/.*?(\.hr\s*?\{.+?\}).*/$1/ig;     } 
       $selstyl .= qq~<option value='$hrstyle'>$templ_txt{'29'}</option>\n~;     if ( $stylestr =~ /\#header/sm ) { 
   }         $headerstyle = $stylestr; 
   if ($stylestr =~ /\.titlebg/) {         $headerstyle =~ s/.*?(\#header.*?\{.+?\}).*/$1/igsm; 
       $titlestyle = $stylestr;         $selstyl .= 
       $titlestyle =~ s/.*?(\.titlebg\s*?\{.+?\}).*/$1/ig;           qq~                   <option value='$headerstyle'>$templ_txt{'26b'}</option>\n~; 
       $titlestyle = $titlestyle;     } 
       $selstyl .= qq~<option value='$titlestyle'>$templ_txt{'30'}</option>\n~;     if ( $stylestr =~ /\#header a/sm ) { 
       if ($stylestr =~ /\.titlebg a/) {         $headerastyle = $stylestr; 
           $titlestyle_a = $stylestr;         $headerastyle =~ s/.*?(\#header a.*?\{.+?\}).*/$1/igsm; 
           $titlestyle_a =~ s/.*?(\.titlebg a\s*?\{.+?\}).*/$1/ig;         $selstyl .= 
           $selstyl .= qq~<option value='$titlestyle_a'>$templ_txt{'30a'}</option>\n~;           qq~                   <option value='$headerastyle'>$templ_txt{'26c'}</option>\n~; 
       }    }
   }     if ( $stylestr =~ /\.tabmenu/sm ) { 
   if ($stylestr =~ /\.catbg/) {         $istabbed = 1; 
       $categorystyle = $stylestr;        $tabmenustyle = $stylestr;
       $categorystyle =~ s/.*?(\.catbg\s*?\{.+?\}).*/$1/ig;         $tabmenustyle =~ s/.*?(\.tabmenu\s*?\{.+?\}).*/$1/igsm; 
       $categorystyle = $categorystyle;         $selstyl .= 
       $selstyl .= qq~<option value='$categorystyle'>$templ_txt{'31'}</option>\n~;           qq~                   <option value='$tabmenustyle'>$templ_txt{'tabmenu'}</option>\n~; 
       if ($stylestr =~ /\.catbg a/) {     } 
           $categorystyle_a = $stylestr;     if ( $stylestr =~ /\.tabtitle/sm && $istabbed ) { 
           $categorystyle_a =~ s/.*?(\.catbg a\s*?\{.+?\}).*/$1/ig;         $tabtitlestyle = $stylestr; 
           $selstyl .= qq~<option value='$categorystyle_a'>$templ_txt{'31a'}</option>\n~;         $tabtitlestyle =~ s/.*?(\.tabtitle\s*?\{.+?\}).*/$1/igsm; 
       }         $selstyl .= 
   }           qq~                   <option value='$tabtitlestyle'>$templ_txt{'tabtitle'}</option>\n~; 
   if ($stylestr =~ /\.windowbg/) {        if ( $stylestr =~ /\.tabtitle a, .tabtitle-bottom a/ ) {
       $window1style = $stylestr;            $tabtitlestyle_a = $stylestr;
       $window1style =~ s/.*?(\.windowbg\s*?\{.+?\}).*/$1/ig;             $tabtitlestyle_a =~ s/.*?(\.tabtitle a, \.tabtitle-bottom a\s*?\{.+?\}).*/$1/igsm; 
       $selstyl .= qq~<option value='$window1style'>$templ_txt{'32'}</option>\n~;             $selstyl .= 
   }  qq~                 <option value='$tabtitlestyle_a'>$templ_txt{'tabtitlea'}</option>\n~; 
   if ($stylestr =~ /\.windowbg2/) {         } 
       $window2style = $stylestr;     } 
       $window2style =~ s/.*?(\.windowbg2\s*?\{.+?\}).*/$1/ig;     if ( $stylestr =~ /\.buttonleft/sm && $stylestr =~ /\.buttonright/sm && $stylestr =~ /\.buttonimage/sm && $stylestr =~ /\.buttontext/sm ) { 
       $windowcol2 = $window2style;         $cssbuttons = 1; 
       $windowcol2 =~ s/.*?(\#[a-f0-9]{3,6}).*/$1/i;         $buttonstyle = $stylestr; 
       $selstyl .= qq~<option value='$window2style'>$templ_txt{'33'}</option>\n~;         $buttonstyle =~ s/.*?(\.buttontext\s*?\{.+?\}).*/$1/igsm; 
   }         $selstyl .= qq~<option value='$buttonstyle'>$templ_txt{'buttontext'}</option>\n~; 
   if ($stylestr =~ /\.message/) {         $prevtext = $buttonstyle; 
       $postsstyle = $stylestr;         $prevtext =~ s/\.buttontext\s*?\{(.+?)\}/$1/igsm; 
       $postsstyle =~ s/.*?(\.message\s*?\{.+?\}).*/$1/ig;         $drawtxtpos = $prevtext; 
       $selstyl .= qq~<option value='$postsstyle'>$templ_txt{'65'}</option>\n~;         $drawtxtpos =~ m/.*?top\s*?\:\s*?(\d{1,2})px.*/ism; 
         $viewtxty = $1;
       if ($stylestr =~ /\.message a/) {         $viewtxty .= 'px'; 
           $postsstyle_a = $stylestr;         $drawpos4 = ($1 * 5) + 213; 
           $postsstyle_a =~ s/.*?(\.message a\s*?\{.+?\}).*/$1/ig;         $drawpos4 .= 'px'; 
           $selstyl .= qq~<option value='$postsstyle_a'>$templ_txt{'66'}</option>\n~;         $buttonleftstyle = $stylestr; 
       }         $buttonleftstyle =~ s/.*?(\.buttonleft\s*?\{.+?\}).*/$1/igsm; 
   }         $buttonleftbg = qq~<input type="hidden" id="buttonleftbg" name="buttonleftbg" value="$buttonleftstyle" />\n~; 
   if ($stylestr =~ /input/) {         $buttonbg = $buttonleftstyle; 
       $inputstyle = $stylestr;         $buttonbg =~ s~.*?($yyhtml_root/Buttons/)(.*?)\.(.*)~$2~gsm; 
       $inputstyle =~ s/.*?(input\s*?\{.+?\}).*/$1/ig;         $prevleft = $buttonleftstyle; 
       $selstyl .= qq~<option value='$inputstyle'>$templ_txt{'34a'}</option>\n~;         $prevleft =~ s/\.buttonleft\s*?\{(.+?)\}/$1/igsm; 
   }         $buttonrightstyle = $stylestr; 
   if ($stylestr =~ /button/) {         $buttonrightstyle =~ s/.*?(\.buttonright\s*?\{.+?\}).*/$1/igsm; 
       $buttonstyle = $stylestr;         $buttonrightbg = qq~<input type="hidden" id="buttonrightbg" name="buttonrightbg" value="$buttonrightstyle" />\n~; 
       $buttonstyle =~ s/.*?(button\s*?\{.+?\}).*/$1/ig;         $prevright = $buttonrightstyle; 
       $selstyl .= qq~<option value='$buttonstyle'>$templ_txt{'34b'}</option>\n~;         $prevright =~ s/\.buttonright\s*?\{(.+?)\}/$1/igsm; 
   }         $buttonimagestyle = $stylestr; 
   if ($stylestr =~ /textarea/) {         $buttonimagestyle =~ s/.*?(\.buttonimage\s*?\{.+?\}).*/$1/igsm; 
       $textareastyle = $stylestr;         $buttonimagebg = qq~<input type="hidden" id="buttonimagebg" name="buttonimagebg" value="$buttonimagestyle" />\n~; 
       $textareastyle =~ s/.*?(textarea\s*?\{.+?\}).*/$1/ig;         $previmage = $buttonimagestyle; 
       $selstyl .= qq~<option value='$textareastyle'>$templ_txt{'35'}</option>\n~;         $previmage =~ s/\.buttonimage\s*?\{(.+?)\}/$1/igsm; 
   }         $drawimgpos = $previmage; 
   if ($stylestr =~ /select/) {         $drawimgpos =~ m/.*?background\-position\s*?\:\s*?(\d{1,2})px\s*?(\d{1,2})px.*/ism; 
       $selectstyle = $stylestr;         $viewimgy = $2; 
       $selectstyle =~ s/.*?(select\s*?\{.+?\}).*/$1/ig;         $viewimgy .= 'px'; 
       $selstyl .= qq~<option value='$selectstyle'>$templ_txt{'36'}</option>\n~;         $drawpos1 = ($2 * 5) + 213; 
   }         $drawpos1 .= 'px'; 
   if ($stylestr =~ /.quote/) {         $viewimgx = $1; 
       $quotestyle = $stylestr;         $viewimgx .= 'px'; 
       $quotestyle =~ s/.*?(\.quote\s*?\{.+?\}).*/$1/ig;         $drawpos2 = $1 + 213; 
       $selstyl .= qq~<option value='$quotestyle'>$templ_txt{'37'}</option>\n~;         $drawpos2 .= 'px'; 
       $message = qq~\[quote\]$templ_txt{'53'}\[/quote\]~;         $drawimgwd = $previmage; 
       if ($enable_ubbc) {         $drawimgwd =~ m/.*?padding\s*?\:\s*?\d{1,2}px\s*?\d{1,2}px\s*?\d{1,2}px\s*?(\d{1,2})px.*/ism; 
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }         $viewimgpad = $1; 
           &DoUBBC;         $viewimgpad .= 'px'; 
       }         $drawpos3 = $1 + 213; 
       $aquote = $message;         $drawpos3 .= 'px'; 
   }    }
   if ($stylestr =~ /.code/) {    if ( $stylestr =~ /\.seperator/sm ) {
       $codestyle = $stylestr;        $seperatorstyle = $stylestr;
       $codestyle =~ s/.*?(\.code\s*?\{.+?\}).*/$1/ig;         $seperatorstyle =~ s/.*?(\.seperator\s*?\{.+?\}).*/$1/igsm; 
       $selstyl .= qq~<option value='$codestyle'>$templ_txt{'38'}</option>\n~;         $selstyl .= 
       $message = qq~\[code\]$templ_txt{'54'}\[/code\]~;           qq~                   <option value='$seperatorstyle'>$templ_txt{'27'}</option>\n~; 
       if ($enable_ubbc) {     } 
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }     if ( $stylestr =~ /\.bordercolor/sm ) { 
           &DoUBBC;         $bordercolorstyle = $stylestr; 
       }         $bordercolorstyle =~ s/.*?(\.bordercolor\s*?\{.+?\}).*/$1/igsm; 
       $acode = $message;         $selstyl .= 
   }           qq~                   <option value='$bordercolorstyle'>$templ_txt{'28'}</option>\n~; 
   if ($stylestr =~ /.editbg/) {     } 
       $editbgstyle = $stylestr;     if ( $stylestr =~ /\.hr/sm ) { 
       $editbgstyle =~ s/.*?(\.editbg\s*?\{.+?\}).*/$1/ig;         $hrstyle = $stylestr; 
       $selstyl .= qq~<option value='$editbgstyle'>$templ_txt{'24'}</option>\n~;         $hrstyle =~ s/.*?(\.hr\s*?\{.+?\}).*/$1/igsm; 
       $message = qq~\[edit\]$templ_txt{'55'}\[/edit\]~;         $selstyl .= qq~                 <option value='$hrstyle'>$templ_txt{'29'}</option>\n~; 
       if ($enable_ubbc) {     } 
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }     if ( $stylestr =~ /\.titlebg/sm ) { 
           &DoUBBC;         $titlestyle = $stylestr; 
       }         $titlestyle =~ s/.*?(\.titlebg\s*?\{.+?\}).*/$1/igsm; 
       $aedit = $message;         $titlestyle = $titlestyle; 
   }         $selstyl .= qq~                 <option value='$titlestyle'>$templ_txt{'30'}</option>\n~; 
   if ($stylestr =~ /.highlight/) {        if ( $stylestr =~ /\.titlebg a/sm ) {
       $highlightstyle = $stylestr;            $titlestyle_a = $stylestr;
       $highlightstyle =~ s/.*?(\.highlight\s*?\{.+?\}).*/$1/ig;             $titlestyle_a =~ s/.*?(\.titlebg a\s*?\{.+?\}).*/$1/igsm; 
       $selstyl .= qq~<option value='$highlightstyle'>$templ_txt{'39'}</option>\n~;             $selstyl .= 
       $message = qq~\[highlight\]$templ_txt{'56'}\[/highlight\]~;               qq~                   <option value='$titlestyle_a'>$templ_txt{'30a'}</option>\n~; 
       if ($enable_ubbc) {         } 
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }    }
           &DoUBBC;     if ( $stylestr =~ /\.catbg/sm ) { 
       }         $categorystyle = $stylestr; 
       $ahighlight = $message;         $categorystyle =~ s/.*?(\.catbg\s*?\{.+?\}).*/$1/igsm; 
   }         $categorystyle = $categorystyle; 
   if ($stylestr =~ /\.bodycontainer/) {         $selstyl .= 
       $bodycontainerstyle = 1;           qq~                   <option value='$categorystyle'>$templ_txt{'31'}</option>\n~; 
   }         if ( $stylestr =~ /\.catbg a/sm ) { 
             $categorystyle_a = $stylestr;
   $yymain .= qq~             $categorystyle_a =~ s/.*?(\.catbg a\s*?\{.+?\}).*/$1/igsm; 
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">             $selstyl .= 
<table width="100%" cellspacing="1" cellpadding="4">               qq~                   <option value='$categorystyle_a'>$templ_txt{'31a'}</option>\n~; 
   <tr>         } 
       <td align="left" valign="middle" class="titlebg">     } 
       <form action="$adminurl?action=modstyle" name="modstyles" id="modstyles" method="post">     if ( $stylestr =~ /\.windowbg/sm ) { 
       <img src="$imagesdir/xx.gif" alt="" border="0" style="vertical-align: middle;" /> <b>$templ_txt{'51'}</b> - $viewcss &nbsp;         $window1style = $stylestr; 
       <input type="hidden" name="cssfile" value="$cssfile" />         $window1style =~ s/.*?(\.windowbg\s*?\{.+?\}).*/$1/igsm; 
       <input type="button" name="wysiwyg" id="wysiwyg" value="wysiwyg" disabled="disabled" />         $selstyl .= 
       <input type="submit" name="source" id="source" value=" source " class="button" />           qq~                   <option value='$window1style'>$templ_txt{'32'}</option>\n~; 
       </form>     } 
       </td>     if ( $stylestr =~ /\.windowbg2/sm ) { 
   </tr>         $window2style = $stylestr; 
</table>        $window2style =~ s/.*?(\.windowbg2.*?\{.+?\}).*/$1/igsm; 
<form action="$adminurl?action=modcss2" name="allstyles" id="allstyles" method="post">         $windowcol2 = $window2style; 
<table width="100%" cellspacing="1" cellpadding="0">         $windowcol2 =~ s/.*?(\#[a-f0-9]{3,6}).*/$1/ism; 
   <tr>         $selstyl .= 
       <td class="windowbg2" align="center" valign="middle">           qq~                   <option value='$window2style'>$templ_txt{'33'}</option>\n~; 
       <iframe id="StyleManager" name="StyleManager" width="100%" height="350" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes" style="border-top: 1px inset; border-bottom: 1px inset; visibility: visible; display: inline"></iframe>     } 
       </td>     if ( $stylestr =~ /\.post-userinfo/sm ) { 
   </tr>         $userinfostyle = $stylestr; 
</table>        $userinfostyle =~ s/.*?(\.post-userinfo.*?\{.+?\}).*/$1/igsm; 
<table width="100%" cellspacing="1" cellpadding="4">         $selstyl .= 
   <tr>           qq~                   <option value='$userinfostyle'>$templ_txt{'userinfo'}</option>\n~; 
       <td align="left" class="windowbg2">     } 
       <div style="float: left; width: 30%; padding: 3px;"><label for="cssfile"><b>$templ_txt{'1'}</b></label></div>     if ( $stylestr =~ /\.message/sm ) { 
       <div style="float: left; width: 69%;">         $postsstyle = $stylestr; 
               <input type="hidden" name="button" value="0" />         $postsstyle =~ s/.*?(\.message\s*?\{.+?\}).*/$1/igsm; 
               <select name="cssfile" id="cssfile" size="1" onchange="document.allstyles.button.value = '1'; submit();">         $selstyl .= qq~                 <option value='$postsstyle'>$templ_txt{'65'}</option>\n~; 
               $forumcss  
               </select>         if ( $stylestr =~ /\.message a/sm ) { 
               <input type="button" value="$templ_txt{'14'}" onclick="document.allstyles.button.value = '3'; if (confirm('$templ_txt{'15'} $cssfile?')) submit();" />             $postsstyle_a = $stylestr; 
       </div>             $postsstyle_a =~ s/.*?(\.message a\s*?\{.+?\}).*/$1/igsm; 
       </td>             $selstyl .= 
   </tr>               qq~                   <option value='$postsstyle_a'>$templ_txt{'66'}</option>\n~; 
   <tr>         } 
       <td align="left" class="windowbg2">     } 
       <div style="float: left; width: 30%; padding: 3px;">     if ( $stylestr =~ /input/sm ) { 
           <label for="csselement"><b>$templ_txt{'18'}</b><br /><span class="small">$templ_txt{'19'}<br /><br /></span></label>         $inputstyle = $stylestr; 
       </div>         $inputstyle =~ s/.*?(input\s*?\{.+?\}).*/$1/igsm; 
       <div style="float: left; width: 69%;">         $selstyl .= 
       <div style="float: left; text-align: center; margin-left: 0px; margin-right: 6px; vertical-align: middle;">           qq~                   <option value='$inputstyle'>$templ_txt{'34a'}</option>\n~; 
               <select name="csselement" id="csselement" size="5" onchange="setElement()">     } 
               $selstyl     if ( $stylestr =~ /button/sm ) { 
               </select>         $buttonstyle = $stylestr; 
       </div>         $buttonstyle =~ s/.*?(button\s*?\{.+?\}).*/$1/igsm; 
       <div style="float: left;">         $selstyl .= 
           <div class="small" style="float: left; vertical-align: middle;">           qq~                   <option value='$buttonstyle'>$templ_txt{'34b'}</option>\n~; 
               <span style="width: 70px;">     } 
               <input type="radio" name="selopt" id="selopt1" value="color" class="windowbg2" style="border: 0px; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt1"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'22'}</b></span></label>     if ( $stylestr =~ /textarea/sm ) { 
               </span>         $textareastyle = $stylestr; 
               <span>         $textareastyle =~ s/.*?(textarea\s*?\{.+?\}).*/$1/igsm; 
               <input type="text" size="9" name="textcol" id="textcol" value="$textcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />         $selstyl .= 
               $gen_fontface $gen_fontsize           qq~                   <option value='$textareastyle'>$templ_txt{'35'}</option>\n~; 
               <img src="$imagesdir/cssbold.gif" border="0" alt="bold" name="cssbold" id="cssbold" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontweight()" />     } 
               <img src="$imagesdir/cssitalic.gif" border="0" alt="italic" name="cssitalic" id="cssitalic" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontstyle()" />     if ( $stylestr =~ /select/sm ) { 
               </span><br />         $selectstyle = $stylestr; 
               <span style="width: 70px;">         $selectstyle =~ s/.*?(select\s*?\{.+?\}).*/$1/igsm; 
               <input type="radio" name="selopt" id="selopt2" value="background-color" class="windowbg2" style="border: 0px; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt2"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'21'}</b></span></label>         $selstyl .= 
               </span>           qq~                   <option value='$selectstyle'>$templ_txt{'36'}</option>\n~; 
               <span>     } 
               <input type="text" size="9" name="backcol" id="backcol" value="$backcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />     if ( $stylestr =~ /.quote/sm ) { 
               </span><br />         $quotestyle = $stylestr; 
               <span style="width: 70px;">         $quotestyle =~ s/.*?(\.quote\s*?\{.+?\}).*/$1/igsm; 
               <input type="radio" name="selopt" id="selopt3" value="border" class="windowbg2" style="border: 0px; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt3"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'23'}</b></span></label>         $selstyl .= qq~                 <option value='$quotestyle'>$templ_txt{'37'}</option>\n~; 
               </span>         $message = qq~\[quote\]$templ_txt{'53'}\[/quote\]~; 
               <span>         if ($enable_ubbc) { 
               <input type="text" size="9" name="bordcol" id="bordcol" value="$bordcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewBorder()" />             enable_yabbc(); 
               $gen_borderstyle $gen_borderweigth             DoUBBC(); 
               </span><br />         } 
           </div>         $aquote = $message; 
           <div style="float: left; height: 68px; width: 92px; overflow: auto; border: 0px; margin-left: 8px;">     } 
               <div style="float: left; height: 22px; width: 91px;">     if ( $stylestr =~ /.code/sm ) { 
                   <div class="bordercolor" style="height: 20px; width: 66px; padding-left: 1px; padding-top: 1px; margin-top: 1px; float: left;">         $codestyle = $stylestr; 
                       <span style="float: left; background-color: #000000; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#000000')">&nbsp;</span>         $codestyle =~ s/.*?(\.code\s*?\{.+?\}).*/$1/igsm; 
                       <span style="float: left; background-color: #333333; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#333333')">&nbsp;</span>         $selstyl .= qq~                 <option value='$codestyle'>$templ_txt{'38'}</option>\n~; 
                       <span style="float: left; background-color: #666666; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#666666')">&nbsp;</span>         $message = qq~\[code\]$templ_txt{'54'}\[/code\]~; 
                       <span style="float: left; background-color: #999999; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#999999')">&nbsp;</span>         if ($enable_ubbc) { 
                       <span style="float: left; background-color: #cccccc; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#cccccc')">&nbsp;</span>             enable_yabbc(); 
                       <span style="float: left; background-color: #ffffff; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#ffffff')">&nbsp;</span>             DoUBBC(); 
                       <span id="defaultpal1" style="float: left; background-color: $pallist[0]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>         } 
                       <span id="defaultpal2" style="float: left; background-color: $pallist[1]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>         $acode = $message; 
                       <span id="defaultpal3" style="float: left; background-color: $pallist[2]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>     } 
                       <span id="defaultpal4" style="float: left; background-color: $pallist[3]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>     if ( $stylestr =~ /.editbg/sm ) { 
                       <span id="defaultpal5" style="float: left; background-color: $pallist[4]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>         $editbgstyle = $stylestr; 
                       <span id="defaultpal6" style="float: left; background-color: $pallist[5]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>         $editbgstyle =~ s/.*?(\.editbg\s*?\{.+?\}).*/$1/igsm; 
                   </div>         $selstyl .= 
                   <div style="height: 22px; width: 23px; padding-left: 1px; float: right;">           qq~                   <option value='$editbgstyle'>$templ_txt{'24'}</option>\n~; 
                       <img src="$imagesdir/palette1.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=palette;task=templ', '', 'height=308,width=302,menubar=no,toolbar=no,scrollbars=no')" alt="" border="0" />         $message = qq~\[edit\]$templ_txt{'55'}\[/edit\]~; 
                   </div>         if ($enable_ubbc) { 
               </div>             enable_yabbc(); 
           </div>             DoUBBC(); 
       </div>         } 
       </div>         $aedit = $message; 
       </td>     } 
   </tr>     if ( $stylestr =~ /.highlight/sm ) { 
   ~;         $highlightstyle = $stylestr; 
         $highlightstyle =~ s/.*?(\.highlight\s*?\{.+?\}).*/$1/igsm;
         $selstyl .=
           qq~                   <option value='$highlightstyle'>$templ_txt{'39'}</option>\n~;
         $message = qq~\[highlight\]$templ_txt{'56'}\[/highlight\]~;
         if ($enable_ubbc) {
             enable_yabbc();
             DoUBBC();
         }
         $ahighlight = $message;
     }
     if ( $stylestr =~ /\.bodycontainer/sm ) {
         $bodycontainerstyle = 1;
     }
   
     $yymain .= qq~
  <form action="$adminurl?action=modstyle" name="modstyles" id="modstyles" method="post" accept-charset="$yymycharset">
  <div class="bordercolor rightboxdiv">
     <table class="border-space pad-cell">
         <tr>
             <td class="titlebg">
                     $admin_img{'xx'} <b>$templ_txt{'51'}</b> - $viewcss &nbsp;
                     <input type="hidden" name="cssfile" value="$cssfile" />
                     <input type="button" name="wysiwyg" id="wysiwyg" value="wysiwyg" disabled="disabled" />
                     <input type="submit" name="source" id="source" value="source" class="button" />
             </td>
         </tr>
     </table>
  </div>
  </form>
  <form action="$adminurl?action=modcss2" name="allstyles" id="allstyles" method="post" accept-charset="$yymycharset">
  <div class="bordercolor borderstyle rightboxdiv">
     <table class="border-space" style="margin-bottom: -1px;">
         <tr>
             <td class="windowbg2 center">
                 <iframe id="StyleManager" name="StyleManager" style="border:0" scrolling="yes"></iframe>
             </td>
         </tr>
     </table>
     <table class="border-space pad-cell" style="margin-bottom: .5em;">
         <tr>
             <td class="windowbg2">
                 <div style="float: left; width: 30%; padding: 3px;"><label for="cssfile"><b>$templ_txt{'1'}</b>$templ_txt{'1b'}</label></div>
                 <div style="float: left; width: 69%;">
                     <input type="hidden" name="button" value="0" />
                     <select name="cssfile" id="cssfile" size="1" onchange="document.allstyles.button.value = '1'; submit();">
                         $forumcss
                     </select>
                     <input type="button" value="$templ_txt{'14'}" onclick="document.allstyles.button.value = '3'; if (confirm('$templ_txt{'15'} $cssfile?')) submit();" />
                 </div>
             </td>
         </tr><tr>
             <td class="windowbg2">
                 <div style="float: left; width: 30%; padding: 3px;">
                     <label for="csselement"><b>$templ_txt{'18'}</b><br /><span class="small">$templ_txt{'19'}<br /><br /></span></label>
                 </div>
                 <div style="float: left; width: 69%;">
                     <div style="float: left; text-align: center; margin-left: 0; margin-right: 6px; vertical-align: middle;">
                         <select name="csselement" id="csselement" size="5" onchange="setElement()">
                             $selstyl
                         </select>
                     </div>
                     <div style="float: left;">
                         <div class="small" style="float: left; vertical-align: middle;">
                             <span style="width: 70px;">
                                 <input type="radio" name="selopt" id="selopt1" value="color" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt1"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'22'}</b></span></label>
                             </span>
                             <span>
                                 <input type="text" size="9" name="textcol" id="textcol" value="$textcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />
                                 $gen_fontface $gen_fontsize
                                 <img src="$imagesdir/cssbold.gif" alt="bold" name="cssbold" id="cssbold" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontweight()" />
                                 <img src="$imagesdir/cssitalic.gif" alt="italic" name="cssitalic" id="cssitalic" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontstyle()" />
                             </span>
                             <br />
                             <span style="width: 70px;">
                                 <input type="radio" name="selopt" id="selopt2" value="background-color" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt2"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'21'}</b></span></label>
                             </span>
                             <span>
                                 <input type="text" size="9" name="backcol" id="backcol" value="$backcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />
                             </span>
                             <br />
                             <span style="width: 70px;">
                                 <input type="radio" name="selopt" id="selopt3" value="border" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt3"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'23'}</b></span></label>
                             </span>
                             <span>
                                 <input type="text" size="9" name="bordcol" id="bordcol" value="$bordcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewBorder()" />
                                 $gen_borderstyle $gen_borderweigth
                             </span>
                             <br />
                         </div>
                         <div style="float: left; height: 68px; width: 93px; overflow: auto; border: 0; margin-left: 8px;">
                             <div style="float: left; height: 22px; width: 92px;">
                                 <div class="palettebox" style="width:68px">
                                     <span class="deftpal" style="background-color: #000000;" onclick="ConvShowcolor('#000000')">&nbsp;</span>
                                     <span class="deftpal" style="background-color: #333333;" onclick="ConvShowcolor('#333333')">&nbsp;</span>
                                     <span class="deftpal" style="background-color: #666666;" onclick="ConvShowcolor('#666666')">&nbsp;</span>
                                     <span class="deftpal" style="background-color: #999999;" onclick="ConvShowcolor('#999999')">&nbsp;</span>
                                     <span class="deftpal" style="background-color: #cccccc;" onclick="ConvShowcolor('#cccccc')">&nbsp;</span>
                                     <span class="deftpal" style="background-color: #ffffff;" onclick="ConvShowcolor('#ffffff')">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal1" style="background-color: $pallist[0];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal2" style="background-color: $pallist[1];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal3" style="background-color: $pallist[2];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal4" style="background-color: $pallist[3];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal5" style="background-color: $pallist[4];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                     <span class="deftpal" id="defaultpal6" style="background-color: $pallist[5];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
                                 </div>
                                 <div style="float:left; height:22px; padding-left: 1px; padding-right: 1px; width:23px; margin-top:-11px">
                                     <img src="$admin_images/palette1.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=palette;task=templ', '', 'height=308,width=302,menubar=no,toolbar=no,scrollbars=no')" alt="" />
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>
             </td>
         </tr>
         ~;
   
     $thisbutton = q{};
     opendir DIR, "$htmldir/Buttons";
     @contents = readdir DIR;
     closedir DIR;
     $optbuttons = q{};
     $x = 1;
     foreach my $line (sort @contents){
         ($name, $extension) = split /\./xsm, $line;
         ($tmpname, $tmpside) = split /\_/xsm, $name;
         $checked = q{};
         if ($name eq $buttonbg) { $checked = q~ checked = "checked"~; }
         if (($extension =~ /gif/ism || $extension =~ /png/ism) && $tmpside eq 'left') {
             $bleft = qq~_left.$extension~;
             $bright = qq~_right.$extension~;
             $thisbutton .= qq~<div style="float: left; width: 99%; margin: 2px; vertical-align: bottom;"><div style="float: left; height: 20px; width: 112px; padding: 0 0 0 6px; background-image: url($yyhtml_root/Buttons/$tmpname$bleft); background-repeat: no-repeat; vertical-align: bottom; cursor: pointer;" onclick="updateButtons('$line');">~;
             $thisbutton .= qq~<div style="float: left; height: 20px; padding: 0 80px 0 0; background-image: url($yyhtml_root/Buttons/$tmpname$bright); background-position: right; background-repeat: no-repeat; vertical-align: bottom;"><div style="float: left; height: 20px; padding: 0 0 0 25px;"></div></div></div>~;
             $thisbutton .= qq~<div style="float: left; height: 20px;"><input type="radio" name="selbutton" id="selbutton$x" value="$line" class="windowbg2" style="border: 0; vertical-align: middle;"$checked onclick="updateButtons(this.value);" /> <label for="selbutton$x" style="vertical-align: middle;"><b>$tmpname</b></label></div></div>\n~;
             $x++;
         }
     }
   
  $yymain .= qq~<tr>
         <td align="left" class="windowbg2">
         <div style="float: left; width: 99%; padding: 3px;">
             <b>$templ_txt{'buttontext'}</b><br /><span class="small">$templ_txt{'buttondescription'}<br /><br /></span>
         </div>
         <div style="float: left; width: 330px; height: 136px; padding: 3px;">
         <div class="catbg" style="position: relative; top: 0; left: 5px; width: 280px; text-align: center; border-width: 1px; border-style: outset; padding: 3px 0;">
         <img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />
         <span id="butleft" style="height: 20px; border: 0; margin: 1px 1px; background-position: top left; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block; $prevleft">
         <span id="butright" style="height: 20px; border: 0; margin: 0; background-position: top right; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block; $prevright">
         <span id="butimage" style="$previmage background-image: url($defaultimagesdir/home.gif); height: 20px; border: 0; margin: 0; background-repeat: no-repeat; vertical-align: top; text-decoration: none; font-size: 18px; display: inline-block;">
         <span id="buttext" style="height: 20px; border: 0; margin: 0; padding: 0; text-align: left; text-decoration: none; vertical-align: top; white-space: nowrap; display: inline-block; $prevtext">$img_txt{'103'}</span>
         </span></span></span>
         <img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />
         </div>
         <div class="catbg" style="position: relative; top: 4px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
         <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'moveicon1'}</b>
         <input class="catbg" name="viewimgy" id="viewimgy" type="text" value="$viewimgy" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
         <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
         <img id="knapImg1" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos1; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt=""  />
         </div>
         <div class="catbg" style="position: relative; top: 8px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
         <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'moveicon2'}</b>
         <input class="catbg" name="viewimgx" id="viewimgx" type="text" value="$viewimgx" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
         <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
         <img id="knapImg2" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos2; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
         </div>
         <div class="catbg" style="position: relative; top: 12px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
         <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'iconspace'}</b>
         <input class="catbg" name="viewimgpad" id="viewimgpad" type="text" value="$viewimgpad" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
         <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
         <img id="knapImg3" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos3; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
         </div>
         <div class="catbg" style="position: relative; top: 16px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
         <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'movetext'}</b>
         <input class="catbg" name="viewtxty" id="viewtxty" type="text" value="$viewtxty" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
         <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
         <img id="knapImg4" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos4; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
         </div>
         </div>
         <div style="float: left; width: 300px; padding: 3px; padding-left: 13px;">
             $thisbutton
         </div>
         $buttonleftbg
         $buttonrightbg
         $buttonimagebg
   
  <script type="text/javascript">
   
  var skydobject={
  x: 0, temp2 : null, targetobj : null, skydNu : 0, delEnh : 0,
  initialize:function() {
     document.onmousedown = this.skydeKnap
     document.onmouseup=function(){
         if(this.skydNu) updateStyles();
         this.skydNu = 0;
     }
  },
  changeStyle:function(deleEnh, knapId) {
     if (knapId == "knapImg1") {
         newypos = parseInt(deleEnh/5);
         thenewstyle = document.allstyles.stylelink.value;
         cssoption = document.allstyles.buttonimagebg.value;
         oldxpos=cssoption.replace(/\.*?background\\-position\\s*?\\:\\s*?(\\d{1,2})\.*/i, "\$1");
         newcssoption=cssoption.replace(/(background\\-position\\s*?\\:\.*?\\d{1,2}px\\s*?)\\d{1,2}(px\\;)/i, "\$1" + newypos + "\$2");
         document.allstyles.buttonimagebg.value = newcssoption;
         re=cssoption.replace(/(.*)/, "\$1");
         thenewstyle=thenewstyle.replace(re, newcssoption);
         document.allstyles.stylelink.value = thenewstyle;
         document.getElementById('butimage').style.backgroundPosition = oldxpos+'px '+newypos+'px';
         document.getElementById('viewimgy').value = newypos+'px';
     }
     if (knapId == "knapImg2") {
         newxpos = parseInt(deleEnh);
         thenewstyle = document.allstyles.stylelink.value;
         cssoption = document.allstyles.buttonimagebg.value;
         oldypos=cssoption.replace(/\.*?background\\-position\\s*?\\:\\s*?\\d{1,2}px\\s*?(\\d{1,2})\.*/i, "\$1");
         newcssoption=cssoption.replace(/(background\\-position\\s*?\\:\.*?)\\d{1,2}(px\\s*?\\d{1,2}px\\;)/i, "\$1" + newxpos + "\$2");
         document.allstyles.buttonimagebg.value = newcssoption;
         re=cssoption.replace(/(.*)/, "\$1");
         thenewstyle=thenewstyle.replace(re, newcssoption);
         document.allstyles.stylelink.value = thenewstyle;
         document.getElementById('butimage').style.backgroundPosition = newxpos+'px '+oldypos+'px';
         document.getElementById('viewimgx').value = newxpos+'px';
     }
     if (knapId == "knapImg3") {
         newimgpad = parseInt(deleEnh);
         thenewstyle = document.allstyles.stylelink.value;
         cssoption = document.allstyles.buttonimagebg.value;
         newcssoption=cssoption.replace(/(padding\\s*?\\:\.*?\\d{1,2}px\\s*?\\d{1,2}px\\s*?\\d{1,2}px\\s*?)\\d{1,2}(px\\;)/i, "\$1" + newimgpad + "\$2");
         document.allstyles.buttonimagebg.value = newcssoption;
         re=cssoption.replace(/(.*)/, "\$1");
         thenewstyle=thenewstyle.replace(re, newcssoption);
         document.allstyles.stylelink.value = thenewstyle;
         document.getElementById('butimage').style.padding = '0 0 0 '+newimgpad+'px';
         document.getElementById('viewimgpad').value = newimgpad+'px';
     }
     if (knapId == "knapImg4") {
         newtxtpad = parseInt(deleEnh/5);
         thenewstyle = document.allstyles.stylelink.value;
         allstyleslen = document.allstyles.csselement.length;
         for (i = 0; i < allstyleslen; i++) {
             tmpselelement = document.allstyles.csselement[i].value;
             if (tmpselelement.match(/\\.buttontext/)) {
                 cssoption = document.allstyles.csselement.options[i].value;
                 newcssoption=cssoption.replace(/(top\\s*?\\:\.*?)\\d{1,2}(px\\s*?\\;)/i, "\$1" + newtxtpad + "\$2");
                 document.allstyles.csselement.options[i].value = newcssoption;
             }
         }
         re=cssoption.replace(/(.*)/, "\$1");
         thenewstyle=thenewstyle.replace(re, newcssoption);
         document.allstyles.stylelink.value = thenewstyle;
         document.getElementById('buttext').style.top = newtxtpad+'px';
         document.getElementById('viewtxty').value = newtxtpad+'px';
     }
  },
  flytKnap:function(e) {
     var evtobj = window.event ? window.event : e
     if (this.skydNu == 1) {
         glX = parseInt(this.targetobj.style.left)
         this.targetobj.style.left = this.temp2 + evtobj.clientX - this.x + "px" 
         nyX = parseInt(this.temp2 + evtobj.clientX - this.x)
         if (nyX > glX) retning = "vn"; else retning = "hj";
         if (nyX < 213 && retning == "hj") { this.targetobj.style.left = 213 + "px"; nyX = 213; retning = "vn"; }
         if (nyX > 263 && retning == "vn") { this.targetobj.style.left = 263 + "px"; nyX = 263; retning = "hj"; }
         delEnh = parseInt(nyX)-213
         var knapObj = this.targetobj.id
         skydobject.changeStyle(delEnh, knapObj)
         return false
     }
  },
  skydeKnap:function(e) {
     var evtobj = window.event ? window.event : e
     this.targetobj = window.event ? event.srcElement : e.target
     if (this.targetobj.className == "skyd") {
         this.skydNu = 1
         this.knapObj = this.targetobj
         if (isNaN(parseInt(this.targetobj.style.left))) this.targetobj.style.left = 0
         this.temp2 = parseInt(this.targetobj.style.left)
         this.x = evtobj.clientX
         if (evtobj.preventDefault) evtobj.preventDefault()
         document.onmousemove = skydobject.flytKnap
     }
  }
  }
   
  skydobject.initialize()
  </script>
         </td>
     </tr>~;
   
   $viewstylestart = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     $viewstylestart = 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  q~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{yabb xml_lang}" lang="{yabb xml_lang}">
<head> <head>
<title>Test Styles</title> <title>Test Styles</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
~; ~;
   $viewstyle = qq~     $viewstyle = q~ 
<body> <body>
<div id="maincontainer"> <div id="maincontainer">
~; ~;
   if ($containerstyle) {    if ($containerstyle) {
       $viewstyle .= qq~         $viewstyle .= q~ 
<div id="container"> <div id="container">
~; ~;
   }    }
   if ($istabbed) {    if ($istabbed) {
       $tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="float: left; vertical-align: middle;" />~;         $tabsep = q{}; 
       $tabfill = qq~<img src="$imagesdir/tabfill.gif" border="0" alt="" style="vertical-align: middle;" />~;         $tabfill = q{}; 
       $tabtime = &timeformat($date, 1);         $tabtime = timeformat( $date, 1 ); 
   
       $viewstyle .= qq~        $viewstyle .= qq~
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="menutop">    <table class="menutop">
   <tr>        <tr>
       <td class="small" align="left" valign="middle" width="2%" height="23">&nbsp;</td>             <td class="small h_23px" style="padding-left:1%">$tabtime</td> 
       <td class="small" align="left" valign="middle" width="98%" height="23">$tabtime</td>             <td class="right vtop"><div class="yabb_searchbox"> 
   </tr>                 <input id="search1" type="text" onblur="txtInFields(this, 'Search')" onfocus="txtInFields(this, 'Search');" style="font-size: 11px;" value="Search" size="16" name="search"><input type="image" style="background-color: transparent; margin-right: 5px; vertical-align: middle;" title="Posts no more than 31 days old" alt="Posts no more than 31 days old" src="$imagesdir/search.png"></div> 
</table>             </td> 
<table class="windowbg2" width="100%" cellpadding="4" cellspacing="0" border="0">         </tr> 
   <tr>     </table> 
       <td align="left" valign="top" width="100%" height="30">&nbsp;</td>     <table id="header" class="pad_4px"> 
   </tr>         <tr> 
</table>             <td class="vtop" style="height:50px">Header (#header) <a href="javascript:;">Header Link (#header a)</a></td> 
<table width="100%" cellpadding="0" cellspacing="0" border="0">         </tr> 
   <tr>     </table> 
       <td class="menutop" height="22" align="left">&nbsp;</td>     <table> 
   </tr>         <tr> 
</table>             <td id="tabmenu" class="tabmenu"> 
<table width="100%" cellpadding="0" cellspacing="0" border="0">                 <span class="selected"><a href="javascript:;">$tabfill$img_txt{'103'}$tabfill</a></span> 
                 $tabsep<span style="cursor:help;"><a href="javascript:;" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>
<tr>                 $tabsep<span><a href="javascript:;">$tabfill$img_txt{'182'}$tabfill</a></span> 
   <td id="tabmnleft" class="tabmenuleft" width="40">&nbsp;</td>                 $tabsep<span><a href="javascript:;">$tabfill$img_txt{'331'}$tabfill</a></span> 
   <td id="tabmn" class="tabmenu">                 $tabsep<span><a href="javascript:;">$tabfill$img_txt{'mycenter'}$tabfill</a></span> 
   <span class="selected"><a href="javascript:;">$tabfill$img_txt{'103'}$tabfill</a></span>                 $tabsep<span><a href="javascript:;">$tabfill$img_txt{'108'}$tabfill</a></span> 
   $tabsep<span style="cursor:help;"><a href="javascript:;" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>             </td> 
   $tabsep<span><a href="javascript:;">$tabfill$img_txt{'182'}$tabfill</a></span>         </tr> 
   $tabsep<span><a href="javascript:;">$tabfill$img_txt{'331'}$tabfill</a></span>     </table> 
   $tabsep<span><a href="javascript:;">$tabfill$img_txt{'mycenter'}$tabfill</a></span>  
   $tabsep<span><a href="javascript:;">$tabfill$img_txt{'108'}$tabfill</a></span>  
   $tabsep  
   </td>  
   <td id="tabmnrss" class="tabmenu" width="40" valign="top"></td>  
   <td id="tabmnright" class="tabmenuright" width="45">&nbsp;    </td>  
   <td id="tabmnbox" class="rightbox" width="160" valign="top">  
       <div style="float: left; width: 160px; height: 21px; text-align: center; padding-top: 3px; display: inline;">  
       <input type="text" name="search" size="16" style="font-size: 11px; vertical-align: middle;" />  
       <img src="$imagesdir/search.gif" style="border: 0; background-color: transparent; margin-right: 5px; vertical-align: middle;" />  
       </div>  
   </td>  
</tr>  
<tr>  
   <td colspan="5"><br />&nbsp;</td>  
</tr>  
</table>  
~; ~;
   }    }
   if ($containerstyle) {    if ($containerstyle) {
       $viewstyle .= qq~        $viewstyle .= qq~
 $templ_txt{'64'}  $templ_txt{'64'}
<br /><br /> <br /><br />
~; ~;
   }    }
   if ($bodycontainerstyle) {    if ($bodycontainerstyle) {
       $viewstyle .= qq~<div class="bodycontainer">~;        $viewstyle .= q~<div class="bodycontainer">~;
   }    }
   if ($seperatorstyle) {    if ($seperatorstyle) {
       $viewstyle .= qq~<div class="seperator">~;        $viewstyle .= q~<div class="seperator">~;
   }    }
   if ($istabbed) {    if ($istabbed) {
       $viewstyle .= qq~        $viewstyle .= qq~
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="bordercolor"> <table style="border-spacing:0" class="bordercolor">
<tr>    <colgroup> 
   <td class="tabtitle" width="1%" height="25" align="left" valign="middle">         <col style="width:1%;  height:25px" /> 
       &nbsp;         <col style="width:49%;  height:25px" /> 
   </td>         <col style="width:50%;  height:25px" /> 
   <td class="tabtitle" width="49%" height="25" align="left" valign="middle">     </colgroup> 
       $templ_txt{'tabtitle'}     <tr> 
   </td>         <td class="tabtitle" colspan="3"> 
   <td class="tabtitle" width="50%" height="25" align="left" valign="middle">             $templ_txt{'tabtitle'} <a href="javascript:;">$templ_txt{'tabtitlea'}</a> 
       <a href="javascript:;">$templ_txt{'tabtitlea'}</a>         </td> 
   </td>     </tr> 
</tr>  
</table> </table>
<br /> <br />
~; ~;
   }    }
   $viewstyle .= qq~    $viewstyle .= qq~
<table class="bordercolor" cellpadding="4" cellspacing="1" border="0" width="100%">  <table class="bordercolor border-space pad-cell"> 
<tr>    <colgroup> 
<td id="title" class="titlebg" width="50%" align="left" valign="middle">         <col span="2" style="width: 50%" /> 
$templ_txt{'30'}     </colgroup> 
</td>     <tr> 
<td id="titlea" class="titlebg" width="50%" align="left" valign="middle">         <td id="title" class="titlebg"> 
<a href="javascript:;">$templ_txt{'30a'}</a>             $templ_txt{'30'} 
</td>        </td>
</tr>         <td id="titlea" class="titlebg"> 
             <a href="javascript:;">$templ_txt{'30a'}</a>
         </td>
     </tr>
</table> </table>
~; ~;
   if ($seperatorstyle) {    if ($seperatorstyle) {
       $viewstyle .= qq~</div>~;         $viewstyle .= q~</div>~; 
   }    }
   $viewstyle .= qq~     $viewstyle .= q~ 
<br /> <br />
~; ~;
   if ($seperatorstyle) {    if ($seperatorstyle) {
       $viewstyle .= qq~<div class="seperator">~;        $viewstyle .= q~<div class="seperator">~;
   }    }
   $viewstyle .= qq~    $viewstyle .= qq~
<table class="bordercolor" cellpadding="4" cellspacing="1" border="0" width="100%">  <table class="bordercolor border-space pad-cell"> 
<tr>    <colgroup> 
<td id="category" class="catbg" width="50%" align="left" valign="middle">         <col span="2" style="width: 50%" /> 
$templ_txt{'31'}     </colgroup> 
</td>     <tr> 
<td id="categorya" class="catbg" width="50%" align="left" valign="middle">         <td id="category" class="catbg"> 
<a href="javascript:;">$templ_txt{'31a'}</a>             $templ_txt{'31'} 
</td>        </td>
</tr>         <td id="categorya" class="catbg"> 
             <a href="javascript:;">$templ_txt{'31a'}</a>
         </td>
     </tr>
</table> </table>
  ~;
   
  $menusep = qq~<img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />~;
  $viewstyleleft = q~style="height: 20px; border: 0; margin: 1px 1px; background-position: top left; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block;"~;
  $viewstyleright = q~style="height: 20px; border: 0; margin: 0; background-position: top right; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block;"~;
  $viewstyleimage = q~height: 20px; border: 0; margin: 0; background-repeat: no-repeat; vertical-align: top; text-decoration: none; font-size: 18px; display: inline-block;~;
  $viewstyletext = q~style="height: 20px; border: 0; margin: 0; padding: 0; text-align: left; text-decoration: none; vertical-align: top; white-space: nowrap; display: inline-block;"~;
   
<table class="bordercolor" cellpadding="4" cellspacing="1" border="0" width="100%">  $viewstyle .= qq~ 
<tr>  <table class="bordercolor border-space pad-cell"> 
<td id="window1" class="windowbg" align="left" valign="top">     <tr> 
$templ_txt{'32'}         <td id="cssbuttons" class="windowbg2 vtop"> 
</td>             <div style="float: left; padding: 4px 0 0 0;">$templ_txt{'buttontext'}</div> 
<td id="window2" class="windowbg2" align="left" valign="top">             <div style="float: right;"> 
$templ_txt{'33'}<br />                 <a href="javascript:;"><span id="button1l" class="buttonleft" $viewstyleleft title="$img_txt{'145'}"><span id="button1r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/maq1.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'145'}</span></span></span></span></a>$menusep 
<hr class="hr">                 <a href="javascript:;"><span id="button2l" class="buttonleft" $viewstyleleft title="$img_txt{'66'}"><span id="button2r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/modify.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'66'}</span></span></span></span></a>$menusep 
<div id="messages" class="message">$templ_txt{'65'}</div>                 <a href="javascript:;"><span id="button3l" class="buttonleft" $viewstyleleft title="$img_txt{'620'}"><span id="button3r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/admin_split.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'620'}</span></span></span></span></a>$menusep 
<div id="messagesa" class="message"><a href="javascript:;">$templ_txt{'66'}</a><br /><br /></div>                 <a href="javascript:;"><span id="button4l" class="buttonleft" $viewstyleleft title="$img_txt{'121'}"><span id="button4r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/delete.gif); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'121'}</span></span></span></span></a> 
<textarea rows="4" cols="19">$templ_txt{'35'}</textarea><br />             </div> 
<input type="text" size="19" value="$templ_txt{'34a'}" />&nbsp;         </td> 
<select value="test">     </tr> 
<option>$templ_txt{'36'} $templ_txt{'61'}</option>  
<option>$templ_txt{'36'} 2</option>  
</select>&nbsp;  
<input type="button" value="$templ_txt{'34b'}" class="button" />  
</td>  
</tr>  
<tr>  
<td id="window1" class="windowbg" align="left" valign="top">  
&nbsp;  
</td>  
<td id="window2" class="windowbg2" align="left" valign="top">  
$aquote  
$acode  
$aedit<br />  
$ahighlight  
</td>  
</tr>  
</table> </table>
~; ~;
   if ($seperatorstyle) {  
       $viewstyle .= qq~</div>~;  
   }  
   if ($bodycontainerstyle) {  
       $viewstyle .= qq~</div>~;  
   }  
   if($istabbed) {  
$viewstyle .= qq~ $viewstyle .= qq~
       <br />  <table class="bordercolor border-space pad-cell"> 
       <div class="mainbottom">     <tr> 
       <table width="100%" cellpadding="0" cellspacing="0" border="0">         <td id="window1" class="windowbg vtop"> 
           <tr>             $templ_txt{'32'} 
               <td class="nav" height="22" width="100%" align="left">&nbsp;</td>         </td> 
           </tr>         <td id="window2" class="windowbg2 vtop"> 
       </table>             $templ_txt{'33'}<br /> 
       </div>             <hr class="hr"> 
             <div id="messages" class="message">$templ_txt{'65'}</div>
             <div id="messagesa" class="message"><a href="javascript:;">$templ_txt{'66'}</a><br /><br /></div>
             <textarea rows="4" cols="19">$templ_txt{'35'}</textarea><br />
             <input type="text" size="19" value="$templ_txt{'34a'}" />&nbsp;
             <select value="test">
                 <option>$templ_txt{'36'} $templ_txt{'61'}</option>
                 <option>$templ_txt{'36'} 2</option>
             </select>&nbsp;
             <input type="button" value="$templ_txt{'34b'}" class="button" />
         </td>
     </tr><tr>
         <td id="window3" class="post-userinfo vtop">$templ_txt{'userinfo'} (.post-userinfo)</td>
         <td id="window4" class="windowbg2 vtop">
             $aquote
             $acode
             $aedit<br />
             $ahighlight
         </td>
     </tr>
  </table>
  ~;
     if ($seperatorstyle) {
         $viewstyle .= q~</div>~;
     }
     if ($bodycontainerstyle) {
         $viewstyle .= q~</div>~;
     }
     if ($istabbed) {
         $viewstyle .= q~
     <br />
     <div class="mainbottom">
         <table>
             <tr>
                 <td class="nav" style="height:22px">&nbsp;</td>
             </tr>
         </table>
     </div>
~; ~;
   }    }
   if ($containerstyle) {    if ($containerstyle) {
       $viewstyle .= qq~</div>~;         $viewstyle .= q~</div>~; 
   }    }
   $viewstyle .= qq~     $viewstyle .= q~ 
<br /><br /> <br /><br />
</div> </div>
</body> </body>
</html>~; </html>~;
     $viewstylestart =~ s/^\s+//gsm;
     $viewstylestart =~ s/\s+$//gsm;
     $viewstylestart =~ s/[\n\r]//gxsm;
     $viewstylestart =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
     ToHTML($viewstylestart);
     $stylestr =~ s/^\s+//gsm;
     $stylestr =~ s/\s+$//gsm;
     $stylestr =~ s/[\n\r]//gxsm;
     $stylestr =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
     ToHTML($stylestr);
     $viewstyle =~ s/^\s+//gsm;
     $viewstyle =~ s/\s+$//gsm;
     $viewstyle =~ s/[\n\r]//gxsm;
     $viewstyle =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
     ToHTML($viewstyle);
   
     if($viewcss eq 'default') {
         $savecss = q{};
     }
     else {
         $savecss = $viewcss;
     }
   
   $viewstylestart =~ s~[\n\r]~~g;     $yymain .= qq~ 
   &ToHTML($viewstylestart);     </table> 
   $stylestr =~ s~[\n\r]~~g;  </div> 
   &ToHTML($stylestr);  <div class="bordercolor rightboxdiv"> 
   $viewstyle =~ s~[\n\r]~~g;  <table class="border-space pad-cell"> 
   &ToHTML($viewstyle);     <tr> 
         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
   $yymain .= qq~     </tr><tr> 
   <tr valign="middle">         <td class="catbg center"> 
       <td align="left" class="windowbg2">             <input type="hidden" name="stylestart" value="$viewstylestart" /> 
       <input type="hidden" name="stylestart" value="$viewstylestart" />            <input type="hidden" name="stylelink" value="$stylestr" />
       <input type="hidden" name="stylelink" value="$stylestr" />            <input type="hidden" name="stylebody" value="$viewstyle" />
       <input type="hidden" name="stylebody" value="$viewstyle" />             <label for="savecssas"><b>$templ_txt{'12'}</b></label> 
       <div style="float: left; width: 30%; padding: 3px;"><label for="savecssas"><b>$templ_txt{'12'}</b></label></div>             <input type="text" name="savecssas" id="savecssas" value="~ 
       <div style="float: left; width: 69%;">             . ( split /\./xsm, $cssfile )[0] . qq~" size="30" maxlength="30" /> 
           <input type="text" name="savecssas" id="savecssas" value="~ . (split(/\./, $cssfile))[0] . qq~" size="30" maxlength="30" />            <input type="submit" value="$templ_txt{'13'}" onclick="document.allstyles.button.value = '2';" class="button" />
           <input type="submit" value="$templ_txt{'13'}" onclick="document.allstyles.button.value = '2';" class="button" />             <div class="small" style="font-weight: normal;">$templ_txt{'noedit'}</div> 
       </div>         </td> 
       </td>     </tr> 
   </tr>  
</table> </table>
</form>  
</div> </div>
  </form>
<script type="text/javascript" language="JavaScript">  <script type="text/javascript"> 
<!--  
var cssbold; var cssbold;
var cssitalic; var cssitalic;
var stylesurl = '$forumstylesurl';  var stylesurl = '$yyhtml_root/Templates/Forum'; 
   
function initStyles() { function initStyles() {
   var thestylestart = document.allstyles.stylestart.value;        var thestylestart = document.allstyles.stylestart.value;
   var thestyles = document.allstyles.stylelink.value;        var thestyles = document.allstyles.stylelink.value;
   var thestylebody = document.allstyles.stylebody.value;        var thestylebody = document.allstyles.stylebody.value;
   var thestyle = thestylestart + '\\<style type="text/css"\\>\\<\\!\\-\\-' + thestyles + '\\-\\-\\>\\<\\/style\\>' + thestylebody;        var thestyle = thestylestart + '\\<style type="text/css"\\>\\<\\!\\-\\-' + thestyles + '\\-\\-\\>\\<\\/style\\>' + thestylebody;
   thestyle=thestyle.replace(/\\&quot\\;/g, '"');        thestyle=thestyle.replace(/\\&quot\\;/g, '"');
   thestyle=thestyle.replace(/\\&nbsp\\;/g, " ");        thestyle=thestyle.replace(/\\&nbsp\\;/g, " ");
   thestyle=thestyle.replace(/\\&\\#124\\;/g, "|");        thestyle=thestyle.replace(/\\&\\#124\\;/g, "|");
   thestyle=thestyle.replace(/\\&lt\\;/g, "<");        thestyle=thestyle.replace(/\\&lt\\;/g, "<");
   thestyle=thestyle.replace(/\\&gt\\;/g, ">");        thestyle=thestyle.replace(/\\&gt\\;/g, ">");
   thestyle=thestyle.replace(/\\&amp\\;/g, "&");        thestyle=thestyle.replace(/\\&amp\\;/g, "&");
   thestyle=thestyle.replace(/(url\\(\\")(.*?\\/.*?\\"\\))/gi, "\$1" + stylesurl + "\/\$2");        thestyle=thestyle.replace(/(url\\(\\")(.*?\\/.*?\\"\\))/gi, "\$1" + stylesurl + "\/\$2");
   StyleManager.document.open("text/html");        StyleManager.document.open("text/html");
   StyleManager.document.write(thestyle);        StyleManager.document.write(thestyle);
   StyleManager.document.close();        StyleManager.document.close();
} }
   
function updateStyles() { function updateStyles() {
   var currentTop = document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop;        var currentTop = document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop;
   initStyles();        initStyles();
   document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop = currentTop;        document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop = currentTop;
  }
  var buttonurl = '$yyhtml_root/Buttons/';
   
  function updateButtons(thebg) {
     len = document.allstyles.selbutton.length;
     for (i = 0; i <len; i++) {
         document.allstyles.selbutton[i].checked = false;
         if (document.allstyles.selbutton[i].value == thebg) document.allstyles.selbutton[i].checked = true;
     }
     thenewstyle = document.allstyles.stylelink.value;
     cssoption = document.allstyles.buttonleftbg.value;
     newcssoption=cssoption.replace(/(background\\-image\\s*?\\:\.*?\\/Buttons\\/).*?(\\)\\;)/i, "\$1" + thebg + "\$2");
     document.getElementById('butleft').style.backgroundImage = 'url(' + buttonurl + thebg + ')';
     document.allstyles.buttonleftbg.value = newcssoption;
     re=cssoption.replace(/(.*)/, "\$1");
     thenewstyle=thenewstyle.replace(re, newcssoption);
     document.allstyles.stylelink.value = thenewstyle;
     updateStyles();
     btside = '_right';
     cssoption = document.allstyles.buttonrightbg.value;
     newthebg = thebg.replace(/(.*?)\\_left(.*)/i, "\$1" + btside + "\$2");
     newcssoption=cssoption.replace(/(background\\-image\\s*?\\:\.*?\\/Buttons\\/).*?(\\)\\;)/i, "\$1" + newthebg + "\$2");
     document.getElementById('butright').style.backgroundImage = 'url(' + buttonurl + newthebg + ')';
     document.allstyles.buttonrightbg.value = newcssoption;
     re=cssoption.replace(/(.*)/, "\$1");
     thenewstyle=thenewstyle.replace(re, newcssoption);
     document.allstyles.stylelink.value = thenewstyle;
     updateStyles();
} }
   
function previewColor(thecolor) { function previewColor(thecolor) {
   thenewstyle = document.allstyles.stylelink.value;    thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;    cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   var cssfont = document.allstyles.selopt1;    var cssfont = document.allstyles.selopt1;
   var cssback = document.allstyles.selopt2;    var cssback = document.allstyles.selopt2;
   var cssborder = document.allstyles.selopt3;    var cssborder = document.allstyles.selopt3;
   if(cssfont.checked) {    if(cssfont.checked) {
       newcssoption=cssoption.replace(/( color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2");        newcssoption=cssoption.replace(/( color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2");
       document.allstyles.textcol.value = thecolor;        document.allstyles.textcol.value = thecolor;
       if(cssoption.match(/\\#container\\s*?\\{/)) {        if(cssoption.match(/\\#container\\s*?\\{/)) {
           thenewstyle=thenewstyle.replace(/(\\.tabmenu span a\\s*?\\{.*?color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");            thenewstyle=thenewstyle.replace(/(\\.tabmenu span a\\s*?\\{.*?color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
       }        }
   }         if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.color = thecolor; 
   if(cssback.checked) {     } 
       newcssoption=cssoption.replace(/(background-color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2");     if(cssback.checked) { 
       document.allstyles.backcol.value = thecolor;         newcssoption=cssoption.replace(/(background-color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2"); 
       if(cssoption.match(/\\#container\\s*?\\{/)) {         document.allstyles.backcol.value = thecolor; 
           thenewstyle=thenewstyle.replace(/(\\.tabmenu.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");         if(cssoption.match(/\\.tabmenu\\s*?\\{/)) { 
           thenewstyle=thenewstyle.replace(/(\\.menutop.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");            thenewstyle=thenewstyle.replace(/(\\.tabmenu.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
           thenewstyle=thenewstyle.replace(/(\\.mainbottom.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");            thenewstyle=thenewstyle.replace(/(\\.rightbox.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
           thenewstyle=thenewstyle.replace(/(\\.rightbox.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");         } 
       }    }
   }     if(cssborder.checked) { 
   if(cssborder.checked) {         tempnewcolor=cssoption; 
       tempnewcolor=cssoption;         if(tempnewcolor.match(/border\\s*?\\:/)) { 
             bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
       if(tempnewcolor.match(/border\\s*?\\:/)) {            if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
           bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");                 tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2"); 
           if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {                 viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1"); 
               tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");             } 
               viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1");         } 
           }         if(tempnewcolor.match(/border\\-top\\s*?\\:/)) { 
       }             bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1"); 
       if(tempnewcolor.match(/border\\-top\\s*?\\:/)) {            if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
           bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");                 tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2"); 
           if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {                 viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1"); 
               tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");             } 
               viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1");         } 
           }         if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) { 
       }             borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1"); 
       if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) {            if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
           borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");                 tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2"); 
           if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {                 viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1"); 
               tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");             } 
               viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1");         } 
           }         if(tempnewcolor.match(/border\\-left\\s*?\\:/)) { 
       }             borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1"); 
       if(tempnewcolor.match(/border\\-left\\s*?\\:/)) {            if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
           borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");                 tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2"); 
           if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {                 viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1"); 
               tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");             } 
               viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1");         } 
           }         if(tempnewcolor.match(/border\\-right\\s*?\\:/)) { 
       }             borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1"); 
       if(tempnewcolor.match(/border\\-right\\s*?\\:/)) {            if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
           borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");                 tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2"); 
           if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {                 viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1"); 
               tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");             } 
               viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1");         } 
           }         newcssoption=tempnewcolor; 
       }         nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2"); 
       newcssoption=tempnewcolor;         theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2"); 
       nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2");         thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1"); 
       theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2");         document.allstyles.bordcol.value = thecolor; 
       thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");     } 
       document.allstyles.bordcol.value = thecolor;     document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption; 
   }     re=cssoption.replace(/(.*)/, "\$1"); 
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;     thenewstyle=thenewstyle.replace(re, newcssoption); 
   re=cssoption.replace(/(.*)/, "\$1");     document.allstyles.stylelink.value = thenewstyle; 
   thenewstyle=thenewstyle.replace(re, newcssoption);     updateStyles(); 
   document.allstyles.stylelink.value = thenewstyle;  
   updateStyles();  
} }
   
function previewBorder() { function previewBorder() {
   thenewstyle = document.allstyles.stylelink.value;        thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   var cssborder = document.allstyles.selopt3;        var cssborder = document.allstyles.selopt3;
   var thebweigth = document.allstyles.borderweigth.value;        var thebweigth = document.allstyles.borderweigth.value;
   var thebcolor = document.allstyles.bordcol.value;        var thebcolor = document.allstyles.bordcol.value;
   var thebstyle = document.allstyles.borderstyle.value;        var thebstyle = document.allstyles.borderstyle.value;
   var thecolor = thebweigth + 'px ' + thebcolor + ' ' + thebstyle;        var thecolor = thebweigth + 'px ' + thebcolor + ' ' + thebstyle;
   if(cssborder.checked) {        if(cssborder.checked) {
       tempnewcolor=cssoption;                tempnewcolor=cssoption;
       if(tempnewcolor.match(/border\\s*?\\:/)) {                if(tempnewcolor.match(/border\\s*?\\:/)) {
           bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");                        bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
           if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {                        if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
               tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");                                tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
               viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1");                                viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1");
           }                        }
       }                }
       if(tempnewcolor.match(/border\\-top\\s*?\\:/)) {                if(tempnewcolor.match(/border\\-top\\s*?\\:/)) {
           bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");                        bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");
           if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {                        if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
               tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");                                tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
               viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1");                                viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1");
           }                        }
       }                }
       if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) {                if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) {
           borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");                        borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");
           if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {                        if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
               tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");                                tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
               viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1");                                viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1");
           }                        }
       }                }
       if(tempnewcolor.match(/border\\-left\\s*?\\:/)) {                if(tempnewcolor.match(/border\\-left\\s*?\\:/)) {
           borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");                        borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");
           if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {                        if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
               tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");                                tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
               viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1");                                viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1");
           }                        }
       }                }
       if(tempnewcolor.match(/border\\-right\\s*?\\:/)) {                if(tempnewcolor.match(/border\\-right\\s*?\\:/)) {
           borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");                        borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");
           if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {                        if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
               tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");                                tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
               viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1");                                viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1");
           }                        }
       }                }
       newcssoption=tempnewcolor;                newcssoption=tempnewcolor;
   
       nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2");                nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2");
       theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2");                theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2");
       thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");                thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");
       document.allstyles.bordcol.value = thebcolor;                document.allstyles.bordcol.value = thebcolor;
   }        }
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
   re=cssoption.replace(/(.*)/, "\$1");        re=cssoption.replace(/(.*)/, "\$1");
   thenewstyle=thenewstyle.replace(re, newcssoption);        thenewstyle=thenewstyle.replace(re, newcssoption);
   document.allstyles.stylelink.value = thenewstyle;        document.allstyles.stylelink.value = thenewstyle;
   updateStyles();        updateStyles();
} }
   
function previewFont() { function previewFont() {
   thesize = document.allstyles.cssfntsize.options[document.allstyles.cssfntsize.selectedIndex].value;        thesize = document.allstyles.cssfntsize.options[document.allstyles.cssfntsize.selectedIndex].value;
   thenewstyle = document.allstyles.stylelink.value;        thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   newcssoption=cssoption.replace(/(font\\-size\\s*?\\:\\s*?)[\\d]{1,2}(\\w+?\;)/i, "\$1" + thesize + "\$2");        newcssoption=cssoption.replace(/(font\\-size\\s*?\\:\\s*?)[\\d]{1,2}(\\w+?\;)/i, "\$1" + thesize + "\$2");
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
   re=cssoption.replace(/(.*)/, "\$1");        re=cssoption.replace(/(.*)/, "\$1");
   thenewstyle=thenewstyle.replace(re, newcssoption);        thenewstyle=thenewstyle.replace(re, newcssoption);
   document.allstyles.stylelink.value = thenewstyle;        document.allstyles.stylelink.value = thenewstyle;
   updateStyles();         if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontSize = thesize; 
         updateStyles();
} }
   
function previewFontface() { function previewFontface() {
   theface = document.allstyles.cssfntface.options[document.allstyles.cssfntface.selectedIndex].value;        theface = document.allstyles.cssfntface.options[document.allstyles.cssfntface.selectedIndex].value;
   thenewstyle = document.allstyles.stylelink.value;        thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   thetmpfontface=cssoption.replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*?\\}/i, "\$1");        thetmpfontface=cssoption.replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*?\\}/i, "\$1");
   thearrfontface=thetmpfontface.split(",");        thearrfontface=thetmpfontface.split(",");
   optnumb=thearrfontface.length;        optnumb=thearrfontface.length;
   newfontarr = theface;        newfontarr = theface;
   for(i = 0; i < optnumb; i++) {        for(i = 0; i < optnumb; i++) {
       thefontface = thearrfontface[i].toLowerCase();                thefontface = thearrfontface[i].toLowerCase();
       thefontface=thefontface.replace(/^\\s/g, "");                thefontface=thefontface.replace(/^\\s/g, "");
       thefontface=thefontface.replace(/\\s\$/g, "");                thefontface=thefontface.replace(/\\s\$/g, "");
       if(thefontface != theface) newfontarr += ', ' + thefontface;                if(thefontface != theface) newfontarr += ', ' + thefontface;
   }        }
   newcssoption=cssoption.replace(/(font\\-family\\s*?\\:).*?(\;)/i, "\$1 " + newfontarr + "\$2");        newcssoption=cssoption.replace(/(font\\-family\\s*?\\:).*?(\;)/i, "\$1 " + newfontarr + "\$2");
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
   re=cssoption.replace(/(.*)/, "\$1");        re=cssoption.replace(/(.*)/, "\$1");
   thenewstyle=thenewstyle.replace(re, newcssoption);        thenewstyle=thenewstyle.replace(re, newcssoption);
   document.allstyles.stylelink.value = thenewstyle;        document.allstyles.stylelink.value = thenewstyle;
   updateStyles();         if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontFamily = theface; 
         updateStyles();
} }
   
function previewFontweight() { function previewFontweight() {
   if(cssbold == false) return;        if(cssbold == false) return;
   thenewstyle = document.allstyles.stylelink.value;        thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   thetmpfontweight=cssoption.replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");        thetmpfontweight=cssoption.replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
   thetmpfontweight=thetmpfontweight.replace(/\\s/g, "");        thetmpfontweight=thetmpfontweight.replace(/\\s/g, "");
   if(thetmpfontweight == 'normal') {        if(thetmpfontweight == 'normal') {
       thefontweight = 'bold';                thefontweight = 'bold';
       document.getElementById('cssbold').style.borderStyle = 'inset';                document.getElementById('cssbold').style.borderStyle = 'inset';
   }        }
   else {        else {
       thefontweight = 'normal';                thefontweight = 'normal';
       document.getElementById('cssbold').style.borderStyle = 'outset';                document.getElementById('cssbold').style.borderStyle = 'outset';
   }        }
   newcssoption=cssoption.replace(/(font\\-weight\\s*?\\:).*?(\;)/ig, "\$1 " + thefontweight + "\$2");        newcssoption=cssoption.replace(/(font\\-weight\\s*?\\:).*?(\;)/ig, "\$1 " + thefontweight + "\$2");
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
   re=cssoption.replace(/(.*)/, "\$1");        re=cssoption.replace(/(.*)/, "\$1");
   thenewstyle=thenewstyle.replace(re, newcssoption);        thenewstyle=thenewstyle.replace(re, newcssoption);
   document.allstyles.stylelink.value = thenewstyle;        document.allstyles.stylelink.value = thenewstyle;
   updateStyles();         if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontWeight = thefontweight; 
         updateStyles();
} }
   
function previewFontstyle() { function previewFontstyle() {
   if(cssitalic == false) return;        if(cssitalic == false) return;
   thenewstyle = document.allstyles.stylelink.value;        thenewstyle = document.allstyles.stylelink.value;
   cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   thetmpfontstyle=cssoption.replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");        thetmpfontstyle=cssoption.replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
   thetmpfontstyle=thetmpfontstyle.replace(/\\s/g, "");        thetmpfontstyle=thetmpfontstyle.replace(/\\s/g, "");
   if(thetmpfontstyle == 'normal') {        if(thetmpfontstyle == 'normal') {
       thefontstyle = 'italic';                thefontstyle = 'italic';
       document.getElementById('cssitalic').style.borderStyle = 'inset';                document.getElementById('cssitalic').style.borderStyle = 'inset';
   }        }
   else {        else {
       thefontstyle = 'normal';                thefontstyle = 'normal';
       document.getElementById('cssitalic').style.borderStyle = 'outset';                document.getElementById('cssitalic').style.borderStyle = 'outset';
   }        }
   newcssoption=cssoption.replace(/(font\\-style\\s*?\\:).*?(\;)/ig, "\$1 " + thefontstyle + "\$2");        newcssoption=cssoption.replace(/(font\\-style\\s*?\\:).*?(\;)/ig, "\$1 " + thefontstyle + "\$2");
   document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
   re=cssoption.replace(/(.*)/, "\$1");        re=cssoption.replace(/(.*)/, "\$1");
   thenewstyle=thenewstyle.replace(re, newcssoption);        thenewstyle=thenewstyle.replace(re, newcssoption);
   document.allstyles.stylelink.value = thenewstyle;        document.allstyles.stylelink.value = thenewstyle;
   updateStyles();         if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontStyle = thefontstyle; 
         updateStyles();
} }
   
function manSelect() { function manSelect() {
   var cssfont = document.allstyles.selopt1;        var cssfont = document.allstyles.selopt1;
   var cssback = document.allstyles.selopt2;        var cssback = document.allstyles.selopt2;
   var cssborder = document.allstyles.selopt3;        var cssborder = document.allstyles.selopt3;
   document.allstyles.textcol.disabled = true;        document.allstyles.textcol.disabled = true;
   document.allstyles.backcol.disabled = true;        document.allstyles.backcol.disabled = true;
   document.allstyles.bordcol.disabled = true;        document.allstyles.bordcol.disabled = true;
   document.allstyles.borderweigth.disabled = true;        document.allstyles.borderweigth.disabled = true;
   document.allstyles.borderstyle.disabled = true;        document.allstyles.borderstyle.disabled = true;
   if(cssfont.checked == true) {        if(cssfont.checked == true) {
       document.allstyles.textcol.disabled = false;                document.allstyles.textcol.disabled = false;
   }        }
   if(cssback.checked == true) {        if(cssback.checked == true) {
       document.allstyles.backcol.disabled = false;                document.allstyles.backcol.disabled = false;
   }        }
   if(cssborder.checked == true) {        if(cssborder.checked == true) {
       document.allstyles.bordcol.disabled = false;                document.allstyles.bordcol.disabled = false;
       document.allstyles.borderweigth.disabled = false;                document.allstyles.borderweigth.disabled = false;
       document.allstyles.borderstyle.disabled = false;                document.allstyles.borderstyle.disabled = false;
   }        }
} }
   
function setElement() { function setElement() {
   cssbold = false;        cssbold = false;
   cssitalic = false;        cssitalic = false;
   
   tempcssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;        tempcssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
   tmpcssoption = tempcssoption.split("{");        tmpcssoption = tempcssoption.split("{");
   
   document.modstyles.wysiwyg.disabled = true;        document.modstyles.wysiwyg.disabled = true;
   
   document.allstyles.cssfntsize.disabled = true;        document.allstyles.cssfntsize.disabled = true;
   document.allstyles.cssfntface.disabled = true;        document.allstyles.cssfntface.disabled = true;
   document.getElementById('cssbold').style.backgroundColor = '#cccccc';        document.getElementById('cssbold').style.backgroundColor = '#cccccc';
   document.getElementById('cssbold').style.borderStyle = 'outset';        document.getElementById('cssbold').style.borderStyle = 'outset';
   document.getElementById('cssitalic').style.backgroundColor = '#cccccc';        document.getElementById('cssitalic').style.backgroundColor = '#cccccc';
   document.getElementById('cssitalic').style.borderStyle = 'outset';        document.getElementById('cssitalic').style.borderStyle = 'outset';
   
   var cssfont = document.allstyles.selopt1;        var cssfont = document.allstyles.selopt1;
   var cssback = document.allstyles.selopt2;        var cssback = document.allstyles.selopt2;
   var cssborder = document.allstyles.selopt3;        var cssborder = document.allstyles.selopt3;
   cssfont.checked = false;        cssfont.checked = false;
   cssback.checked = false;        cssback.checked = false;
   cssborder.checked = false;        cssborder.checked = false;
   cssfont.disabled = true;        cssfont.disabled = true;
   cssback.disabled = true;        cssback.disabled = true;
   cssborder.disabled = true;        cssborder.disabled = true;
   
   if(tmpcssoption[1].match(/font\-size/g)) {        if(tmpcssoption[1].match(/font\-size/g)) {
       cssfont.disabled = false;                cssfont.disabled = false;
       document.allstyles.cssfntsize.disabled = false;                document.allstyles.cssfntsize.disabled = false;
       thefontsize=tmpcssoption[1].replace(/.*?font\\-size\\s*?\\:\\s*?([\\d]{1,2})\\w+?\\;.*/, "\$1");                thefontsize=tmpcssoption[1].replace(/.*?font\\-size\\s*?\\:\\s*?([\\d]{1,2})\\w+?\\;.*/, "\$1");
       if(!thefontsize) thesel=0;                if(!thefontsize) thesel=0;
       else thesel=thefontsize-7;                else thesel=thefontsize-7;
       document.allstyles.cssfntsize.value = document.allstyles.cssfntsize.options[thesel].value;                document.allstyles.cssfntsize.value = document.allstyles.cssfntsize.options[thesel].value;
   }        }
   if(tmpcssoption[1].match(/font\-family/g)) {        if(tmpcssoption[1].match(/font\-family/g)) {
       cssfont.disabled = false;                cssfont.disabled = false;
       document.allstyles.cssfntface.disabled = false;                document.allstyles.cssfntface.disabled = false;
       optnumb=document.allstyles.cssfntface.options.length;                optnumb=document.allstyles.cssfntface.options.length;
       thetmpfontface=tmpcssoption[1].replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");                thetmpfontface=tmpcssoption[1].replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
       thearrfontface=thetmpfontface.split(",", 1);                thearrfontface=thetmpfontface.split(",", 1);
       thefontface = thearrfontface[0].toLowerCase();                thefontface = thearrfontface[0].toLowerCase();
       thefontface=thefontface.replace(/^\\s/g, "");                thefontface=thefontface.replace(/^\\s/g, "");
       thefontface=thefontface.replace(/\\s\$/g, "");                thefontface=thefontface.replace(/\\s\$/g, "");
       for(i = 0; i < optnumb; i++) {                for(i = 0; i < optnumb; i++) {
           selfontface = document.allstyles.cssfntface.options[i].value;                        selfontface = document.allstyles.cssfntface.options[i].value;
           if(selfontface == thefontface) document.allstyles.cssfntface.value = selfontface;                        if(selfontface == thefontface) document.allstyles.cssfntface.value = selfontface;
       }                }
   }        }
   
   if(tmpcssoption[1].match(/font\-weight/g)) {        if(tmpcssoption[1].match(/font\-weight/g)) {
       cssbold = true;                cssbold = true;
       document.getElementById('cssbold').style.backgroundColor = '#ffffff';                document.getElementById('cssbold').style.backgroundColor = '#ffffff';
       thetmpfontweight=tmpcssoption[1].replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");                thetmpfontweight=tmpcssoption[1].replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
       if(thetmpfontweight.match(/bold/)) document.getElementById('cssbold').style.borderStyle = 'inset';                if(thetmpfontweight.match(/bold/)) document.getElementById('cssbold').style.borderStyle = 'inset';
   }        }
   
   if(tmpcssoption[1].match(/font\-style/g)) {        if(tmpcssoption[1].match(/font\-style/g)) {
       cssitalic = true;                cssitalic = true;
       document.getElementById('cssitalic').style.backgroundColor = '#ffffff';                document.getElementById('cssitalic').style.backgroundColor = '#ffffff';
       thetmpfontstyle=tmpcssoption[1].replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");                thetmpfontstyle=tmpcssoption[1].replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
       if(thetmpfontstyle.match(/italic/)) document.getElementById('cssitalic').style.borderStyle = 'inset';                if(thetmpfontstyle.match(/italic/)) document.getElementById('cssitalic').style.borderStyle = 'inset';
   }        }
   
   if(tmpcssoption[1].match(/background\-color/g)) {        if(tmpcssoption[1].match(/background\-color/g)) {
       cssback.disabled = false;                cssback.disabled = false;
       thebackcolor=tmpcssoption[1].replace(/(.*?)background\\-color\\s*?\\:(.+?)\\;(.*)/i, "\$2");                thebackcolor=tmpcssoption[1].replace(/(.*?)background\\-color\\s*?\\:(.+?)\\;(.*)/i, "\$2");
       thebackcolor=thebackcolor.replace(/\\s/g, "");                thebackcolor=thebackcolor.replace(/\\s/g, "");
       document.allstyles.backcol.value = thebackcolor;                document.allstyles.backcol.value = thebackcolor;
   }        }
   else {        else {
       document.allstyles.backcol.value = '';                document.allstyles.backcol.value = '';
   }        }
   if(tmpcssoption[1].match(/ color/g)) {        if(tmpcssoption[1].match(/ color/g)) {
       cssfont.disabled = false;                cssfont.disabled = false;
       thefontcolor=tmpcssoption[1].replace(/(.*?) color\\s*?\\:(.+?)\\;(.*)/i, "\$2");                thefontcolor=tmpcssoption[1].replace(/(.*?) color\\s*?\\:(.+?)\\;(.*)/i, "\$2");
       thefontcolor=thefontcolor.replace(/\\s/g, "");                thefontcolor=thefontcolor.replace(/\\s/g, "");
       document.allstyles.textcol.value = thefontcolor;                document.allstyles.textcol.value = thefontcolor;
   }        }
   else {        else {
       document.allstyles.textcol.value = '';                document.allstyles.textcol.value = '';
   }        }
   
   if(tmpcssoption[1].match(/border/)) {        if(tmpcssoption[1].match(/border/)) {
       cssborder.disabled = false;                cssborder.disabled = false;
       document.allstyles.borderweigth.disabled = false;                document.allstyles.borderweigth.disabled = false;
       document.allstyles.borderstyle.disabled = false;                document.allstyles.borderstyle.disabled = false;
   }        }
   else {        else {
       document.allstyles.borderweigth.disabled = true;                document.allstyles.borderweigth.disabled = true;
       document.allstyles.borderstyle.disabled = true;                document.allstyles.borderstyle.disabled = true;
   }        }
   viewnewcolor = '';        viewnewcolor = '';
   
   if(tmpcssoption[1].match(/border\\s*?\\:/)) {        if(tmpcssoption[1].match(/border\\s*?\\:/)) {
       bordercol=tmpcssoption[1].replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");                bordercol=tmpcssoption[1].replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
       if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {                if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
           viewnewcolor=bordercol;                        viewnewcolor=bordercol;
       }                }
   }        }
   if(tmpcssoption[1].match(/border\\-top\\s*?\\:/)) {        if(tmpcssoption[1].match(/border\\-top\\s*?\\:/)) {
       bordertopcol=tmpcssoption[1].replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");                bordertopcol=tmpcssoption[1].replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");
       if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {                if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
           viewnewcolor=bordertopcol;                        viewnewcolor=bordertopcol;
       }                }
   }        }
   if(tmpcssoption[1].match(/border\\-bottom\\s*?\\:/)) {        if(tmpcssoption[1].match(/border\\-bottom\\s*?\\:/)) {
       borderbottomcol=tmpcssoption[1].replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");                borderbottomcol=tmpcssoption[1].replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");
       if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {                if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
           viewnewcolor=borderbottomcol;                        viewnewcolor=borderbottomcol;
       }                }
   }        }
   if(tmpcssoption[1].match(/border\\-left\\s*?\\:/)) {        if(tmpcssoption[1].match(/border\\-left\\s*?\\:/)) {
       borderleftcol=tmpcssoption[1].replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");                borderleftcol=tmpcssoption[1].replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");
       if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {                if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
           viewnewcolor=borderleftcol;                        viewnewcolor=borderleftcol;
       }                }
   }        }
   if(tmpcssoption[1].match(/border\\-right\\s*?\\:/)) {        if(tmpcssoption[1].match(/border\\-right\\s*?\\:/)) {
       borderrightcol=tmpcssoption[1].replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");                borderrightcol=tmpcssoption[1].replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");
       if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {                if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
           viewnewcolor=borderrightcol;                        viewnewcolor=borderrightcol;
       }                }
   }        }
   thebordercolor=viewnewcolor.replace(/.*?(\\#[0-9a-f]{3,6}).*/i, "\$1");        thebordercolor=viewnewcolor.replace(/.*?(\\#[0-9a-f]{3,6}).*/i, "\$1");
   nocolor=viewnewcolor.replace(/(.*?)(\\#[0-9a-f]{3,6})(.*)/i, "\$1\$3");        nocolor=viewnewcolor.replace(/(.*?)(\\#[0-9a-f]{3,6})(.*)/i, "\$1\$3");
   optnumb=document.allstyles.borderstyle.options.length;        optnumb=document.allstyles.borderstyle.options.length;
   theborderstyle=viewnewcolor.replace(/.*?(solid|dashed|dotted|double|groove|ridge|inset|outset).*/i, "\$1");        theborderstyle=viewnewcolor.replace(/.*?(solid|dashed|dotted|double|groove|ridge|inset|outset).*/i, "\$1");
   theborderstyle = theborderstyle.toLowerCase();        theborderstyle = theborderstyle.toLowerCase();
   theborderstyle=theborderstyle.replace(/^\\s/g, "");        theborderstyle=theborderstyle.replace(/^\\s/g, "");
   theborderstyle=theborderstyle.replace(/\\s\$/g, "");        theborderstyle=theborderstyle.replace(/\\s\$/g, "");
   for(i = 0; i < optnumb; i++) {        for(i = 0; i < optnumb; i++) {
       selborderstyle = document.allstyles.borderstyle.options[i].value;                selborderstyle = document.allstyles.borderstyle.options[i].value;
       if(selborderstyle == theborderstyle) document.allstyles.borderstyle.value = selborderstyle;                if(selborderstyle == theborderstyle) document.allstyles.borderstyle.value = selborderstyle;
   }        }
   
   thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");        thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");
   if(!thebordersize) thebordersize=0;        if(!thebordersize) thebordersize=0;
   document.allstyles.bordcol.value = thebordercolor;        document.allstyles.bordcol.value = thebordercolor;
   document.allstyles.borderweigth.value = document.allstyles.borderweigth.options[thebordersize].value;        document.allstyles.borderweigth.value = document.allstyles.borderweigth.options[thebordersize].value;
   
   if (cssfont.disabled == false) {        if (cssfont.disabled == false) {
       cssfont.checked = true;                cssfont.checked = true;
   }        }
   else if (cssback.disabled == false) {        else if (cssback.disabled == false) {
       cssback.checked = true;                cssback.checked = true;
   }        }
   else if (cssborder.disabled == false) {        else if (cssborder.disabled == false) {
       cssborder.checked = true;                cssborder.checked = true;
   }        }
   manSelect();        manSelect();
} }
   
initStyles(); initStyles();
setElement(); setElement();
   
// Palette // Palette
var thistask = 'templ'; var thistask = 'templ';
function tohex(i) { function tohex(i) {
   a2 = ''         a2 = '' 
   ihex = hexQuot(i);        ihex = hexQuot(i);
   idiff = eval(i + '-(' + ihex + '*16)')        idiff = eval(i + '-(' + ihex + '*16)')
   a2 = itohex(idiff) + a2;        a2 = itohex(idiff) + a2;
   while( ihex >= 16) {        while( ihex >= 16) {
       itmp = hexQuot(ihex);                itmp = hexQuot(ihex);
       idiff = eval(ihex + '-(' + itmp + '*16)');                idiff = eval(ihex + '-(' + itmp + '*16)');
       a2 = itohex(idiff) + a2;                a2 = itohex(idiff) + a2;
       ihex = itmp;                ihex = itmp;
   }        }
   a1 = itohex(ihex);        a1 = itohex(ihex);
   return a1 + a2 ;        return a1 + a2 ;
} }
   
function hexQuot(i) { function hexQuot(i) {
   return Math.floor(eval(i +'/16'));        return Math.floor(eval(i +'/16'));
} }
   
function itohex(i) { function itohex(i) {
   if( i == 0) { aa = '0' }        if( i === 0) { aa = '0' }
   else { if( i == 1 ) { aa = '1' }        else { if( i == 1 ) { aa = '1' }
   else { if( i == 2 ) { aa = '2' }        else { if( i == 2 ) { aa = '2' }
   else { if( i == 3 ) { aa = '3' }        else { if( i == 3 ) { aa = '3' }
   else { if( i == 4 ) { aa = '4' }        else { if( i == 4 ) { aa = '4' }
   else { if( i == 5 ) { aa = '5' }        else { if( i == 5 ) { aa = '5' }
   else { if( i == 6 ) { aa = '6' }        else { if( i == 6 ) { aa = '6' }
   else { if( i == 7 ) { aa = '7' }        else { if( i == 7 ) { aa = '7' }
   else { if( i == 8 ) { aa = '8' }        else { if( i == 8 ) { aa = '8' }
   else { if( i == 9 ) { aa = '9' }        else { if( i == 9 ) { aa = '9' }
   else { if( i == 10) { aa = 'a' }        else { if( i == 10) { aa = 'a' }
   else { if( i == 11) { aa = 'b' }        else { if( i == 11) { aa = 'b' }
   else { if( i == 12) { aa = 'c' }        else { if( i == 12) { aa = 'c' }
   else { if( i == 13) { aa = 'd' }        else { if( i == 13) { aa = 'd' }
   else { if( i == 14) { aa = 'e' }        else { if( i == 14) { aa = 'e' }
   else { if( i == 15) { aa = 'f' }        else { if( i == 15) { aa = 'f' }
   }}}}}}}}}}}}}}}        }}}}}}}}}}}}}}}
   return aa;        return aa;
} }
   
function ConvShowcolor(color) { function ConvShowcolor(color) {
   if ( c=color.match(/rgb\\((\\d+?)\\, (\\d+?)\\, (\\d+?)\\)/i) ) {        if ( c=color.match(/rgb\\((\\d+?)\\, (\\d+?)\\, (\\d+?)\\)/i) ) {
       var rhex = tohex(c[1]);                var rhex = tohex(c[1]);
       var ghex = tohex(c[2]);                var ghex = tohex(c[2]);
       var bhex = tohex(c[3]);                var bhex = tohex(c[3]);
       var newcolor = '#'+rhex+ghex+bhex;                var newcolor = '#'+rhex+ghex+bhex;
   }        }
   else {        else {
       var newcolor = color;                var newcolor = color;
   }        }
   if(thistask == "post") showcolor(newcolor);        if(thistask == "post") showcolor(newcolor);
   if(thistask == "templ") previewColor(newcolor);        if(thistask == "templ") previewColor(newcolor);
} }
//-->  
</script> </script>
   ~;  
   $yytitle = $templ_txt{'1'};  
   $action_area = "modcss";  
   &AdminTemplate;  
}  
   
sub ModifyCSS2 {  
   &is_admin_or_gmod;  
   if ($FORM{'button'} == 1) {  
       $yySetLocation = qq~$adminurl?action=modcss;cssfile=$FORM{'cssfile'}~;  
       &redirectexit;  
   
   } elsif ($FORM{'button'} == 2) {  
       $style_name = $FORM{'savecssas'};  
       if ($style_name eq "default") { &admin_fatal_error("no_delete_default"); }  
       if ($style_name !~ m^\A[0-9a-zA-Z_\.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z^ || $style_name eq "") { &admin_fatal_error("invalid_template"); }  
       $style_cnt = $FORM{'stylelink'};  
       &FromHTML($style_cnt);  
       $style_cnt =~ s~(\*\/)~$1\n\n~g;  
       $style_cnt =~ s~(\/\*)~\n$1~g;  
       $style_cnt =~ s~(\{)~$1\n~g;  
       $style_cnt =~ s~(\})~$1\n~g;  
       $style_cnt =~ s~(\;)~$1\n~g;  
       @style_arr = split(/\n/, $style_cnt);  
   
       fopen(TMPCSS, ">$forumstylesdir/$style_name.css") || &admin_fatal_error("cannot_open","$forumstylesdir/$style_name.css", 1);  
       foreach $style_sgl (@style_arr) {  
           $style_sgl =~ s~\A\s+?~~g;  
           if($style_sgl =~ m~\;+\Z~) { $style_sgl = qq~\t$style_sgl~; }  
           $style_sgl =~ s/$forumstylesurl/\./g;  
           print TMPCSS "$style_sgl\n";  
       }  
       fclose(TMPCSS);  
   
       $yySetLocation = qq~$adminurl?action=modcss;cssfile=$style_name.css~;  
       &redirectexit;  
   
   } elsif ($FORM{'button'} == 3) {  
       $style_name = $FORM{'cssfile'};  
       if ($style_name eq "default.css") { &admin_fatal_error("no_delete_default"); }  
       unlink "$forumstylesdir/$style_name";  
       $yySetLocation = qq~$adminurl?action=modcss;cssfile=default.css~;  
       &redirectexit;  
   }  
}  
   
sub ModifySkin {  
   &is_admin_or_gmod;  
   
   if ($INFO{'templateset'}) { $thistemplate = $INFO{'templateset'}; }  
   else { $thistemplate = "$template"; }  
   
   foreach my $curtemplate (sort{ $templateset{$a} cmp $templateset{$b} } keys %templateset) {  
       $selected = "";  
       if ($curtemplate eq $thistemplate) { $selected = qq~ selected="selected"~; $akttemplate = $curtemplate; }  
       $templatesel .= qq~<option value="$curtemplate"$selected>$curtemplate</option>\n~;  
   }  
   
   ($aktstyle, $aktimages, $akthead, $aktboard, $aktmessage, $aktdisplay, $aktmycenter, $aktmenutype) = split(/\|/, $templateset{$akttemplate});  
   $thisimagesdir = "$forumstylesurl/$aktimages";  
   
   my ($fullcss, $line);  
   if ($INFO{'cssfile'}) { $cssfile = $INFO{'cssfile'}; }  
   else { $cssfile = "$aktstyle.css"; }  
   if ($INFO{'imgfolder'}) { $imgfolder = $INFO{'imgfolder'}; }  
   else { $imgfolder = "$aktimages"; }  
   if ($INFO{'headfile'}) { $headfile = $INFO{'headfile'}; }  
   else { $headfile = "$akthead.html"; }  
   if ($INFO{'boardfile'}) { $boardfile = $INFO{'boardfile'}; }  
   else { $boardfile = "$aktboard/BoardIndex.template"; }  
   if ($INFO{'messagefile'}) { $messagefile = $INFO{'messagefile'}; }  
   else { $messagefile = "$aktmessage/MessageIndex.template"; }  
   if ($INFO{'displayfile'}) { $displayfile = $INFO{'displayfile'}; }  
   else { $displayfile = "$aktdisplay/Display.template"; }  
   
   if ($INFO{'mycenterfile'}) { $mycenterfile = $INFO{'mycenterfile'}; }  
   else { $mycenterfile = "$aktmycenter/MyCenter.template"; }  
   
   if ($INFO{'menutype'} ne '') { $UseMenuType = $INFO{'menutype'}; }  
   else {  
       $UseMenuType = $MenuType;  
       if ($aktmenutype ne '') { $UseMenuType = $aktmenutype; }  
   }  
   
   if ($INFO{'selsection'}) { $selectedsection = $INFO{'selsection'}; }  
   else { $selectedsection = "vboard"; }  
   my ($boardsel, $messagesel, $displaysel);  
   if    ($selectedsection eq "vboard")   { $boardsel   = qq~ checked="checked"~; }  
   elsif ($selectedsection eq "vmessage") { $messagesel = qq~ checked="checked"~; }  
   elsif ($selectedsection eq "vdisplay") { $displaysel = qq~ checked="checked"~; }  
   else  { $mycentersel = qq~ checked="checked"~; }  
   
   opendir(TMPLDIR, "$forumstylesdir");  
   @styles = readdir(TMPLDIR);  
   closedir(TMPLDIR);  
   $forumcss = "";  
   $imgdirs  = "";  
   foreach $file (sort @styles) {  
       ($name, $ext) = split(/\./, $file);  
       $selected = "";  
       if ($ext eq 'css') {  
           if ($file eq $cssfile) { $selected = qq~ selected="selected"~; $viewcss = $name; }  
           $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;  
       }  
       if (-d "$forumstylesdir/$file" && $file =~ m^\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z^) {  
           if ($imgfolder eq $file) { $imgdirs .= qq~<option value="$file" selected="selected">$file</option>~; $viewimg = $file; }  
           else { $imgdirs .= qq~<option value="$file">$file</option>~; }  
       }  
   }  
   
   fopen(CSS, "$forumstylesdir/$cssfile") or &admin_fatal_error("cannot_open","$forumstylesdir/$cssfile");  
   while ($line = <CSS>) {  
       $line =~ s~[\r\n]~~g;  
       &FromHTML($line);  
       $fullcss .= qq~$line\n~;  
   }  
   fclose(CSS);  
   
   opendir(TMPLDIR, "$templatesdir");  
   @temptemplates = readdir(TMPLDIR);  
   closedir(TMPLDIR);  
   
   foreach $tmpfile (@temptemplates) {  
       if (-d "$templatesdir/$tmpfile") {  
           push(@templates, $tmpfile);  
       } else {  
           next;  
       }  
   }  
   
   if ($UseMenuType == 0) { $menutype0 = ' selected="selected" ';  }  
   elsif ($UseMenuType == 1) { $menutype1 = ' selected="selected" '; }  
   elsif ($UseMenuType == 2) { $menutype2 = ' selected="selected" '; }  
   require "$vardir/Menu$UseMenuType.def";  
   
   $boardtemplates   = "";  
   $messagetemplates = "";  
   $displaytemplates = "";  
   $headtemplates    = "";  
   
   foreach $name (sort @templates) {  
       opendir(TMPLSDIR, "$templatesdir/$name");  
       @templatefiles = readdir(TMPLSDIR);  
       closedir(TMPLSDIR);  
   
       foreach $file (@templatefiles) {  
           if ($file eq "index.html") { next; }  
           $thefile = qq~$name/$file~;  
           ($section, $ext) = split(/\./, $file);  
           $hselected = "";  
           if ($ext eq 'html') {  
               if ($file eq $headfile) { $hselected = qq~ selected="selected"~; $viewhead = $name; }  
               $headtemplates .= qq~<option value="$file"$hselected>$name</option>\n~;  
           }  
           $bselected = "";  
           $mselected = "";  
           $dselected = "";  
           $myselected = "";  
           if ($section eq 'BoardIndex') {  
               if ($thefile eq $boardfile) { $bselected = qq~ selected="selected"~; $viewboard = $name; }  
               $boardtemplates .= qq~<option value="$thefile"$bselected>$name</option>\n~;  
           } elsif ($section eq 'MessageIndex') {  
               if ($thefile eq $messagefile) { $mselected = qq~ selected="selected"~; $viewmessage = $name; }  
               $messagetemplates .= qq~<option value="$thefile"$mselected>$name</option>\n~;  
           } elsif ($section eq 'Display') {  
               if ($thefile eq $displayfile) { $dselected = qq~ selected="selected"~; $viewdisplay = $name; }  
               $displaytemplates .= qq~<option value="$thefile"$dselected>$name</option>\n~;  
           } elsif ($section eq 'MyCenter') {  
               if ($thefile eq $mycenterfile) { $myselected = qq~ selected="selected"~; $viewmycenter = $name; }  
               $mycentertemplates .= qq~<option value="$thefile"$myselected>$name</option>\n~;  
           }  
       }  
   }  
   
   fopen(TMPL, "$templatesdir/$viewhead/$viewhead.html");  
   while ($line = <TMPL>) {  
       $line =~ s~[\r\n]~~g;  
       $fulltemplate .= qq~$line\n~;  
   }  
   fclose(TMPL);  
   
   $tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="float: left; vertical-align: middle;" />~;  
   $tabfill = qq~<img src="$imagesdir/tabfill.gif" border="0" alt="" style="vertical-align: middle;" />~;  
   
   $tempforumurl  = $mbname;  
   $temptitle     = qq~Template Config~;  
   $tempnewstitle = qq~<b>$templ_txt{'68'}:</b> ~;  
   $tempnews      = qq~$templ_txt{'84'}~;  
   $tempstyles    = qq~<link rel="stylesheet" href="$forumstylesurl/$viewcss.css" type="text/css" />~;  
   $tempimages    = qq~$forumstylesurl/$viewimg~;  
   $tempimagesdir = qq~$forumstylesdir/$viewimg~;  
   $tempmenu = qq~<span title="$img_txt{'103'}" class="selected">$tabfill$img_txt{'103'}$tabfill</span>~;  
   $tempmenu .= qq~$tabsep<span title="$img_txt{'119'}" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</span>~;  
   $tempmenu .= qq~$tabsep<span title="$img_txt{'331'}">$tabfill$img_txt{'331'}$tabfill</span>~;  
   $tempmenu .= qq~$tabsep<span title="$img_txt{'mycenter'}">$tabfill$img_txt{'mycenter'}$tabfill</span>~;  
   $tempmenu .= qq~$tabsep<span title="$img_txt{'108'}">$tabfill$img_txt{'108'}$tabfill</span>$tabsep~;  
   $tempmenu =~ s~img src\=\"$imagesdir\/(.+?)\"~&TmpImgLoc($1, $tempimages, $tempimagesdir)~eisg;  
   $temp21menu = qq~$img{'home'}$menusep$img{'help'}$menusep$img{'search'}$menusep$img{'memberlist'}$menusep$img{'profile'}$menusep$img{'notification'}$menusep$img{'logout'}~;  
   $temp21menu =~ s~img src\=\"$imagesdir\/(.+?)\"~&TmpImgLoc($1, $tempimages, $tempimagesdir)~eisg;  
   $rssbutton = qq~<img src="$imagesdir/rss.png" border="0" alt="" style="vertical-align: middle;" />~;  
   $tempuname = qq~$templ_txt{'69'} ${$uid.$username}{'realname'}, ~;  
   $tempuim   = qq~$templ_txt{'70'} <a name="ims">0 $templ_txt{'71'}</a>.~;  
   $temptime  = &timeformat($date, 1);  
   my $tempsearchbox = qq~<input type="text" name="search" size="16" style="font-size: 11px; vertical-align: middle;" />~;  
   $tempsearchbox .= qq~<img src="$imagesdir/search.gif" alt="" style="border: 0; background-color: transparent; margin-right: 5px; vertical-align: middle;" />~;  
   
   $templatejump = 1;  
   $tempforumjump = &jumpto;  
   
   $fulltemplate =~ s/({|<)yabb charset(}|>)/$yycharset/g;  
   $fulltemplate =~ s/({|<)yabb title(}|>)/$temptitle/g;  
   $fulltemplate =~ s/({|<)yabb style(}|>)/$tempstyles/g;  
   $fulltemplate =~ s/({|<)yabb html_root(}|>)/$yyhtml_root/g;  
   $fulltemplate =~ s/({|<)yabb images(}|>)/$tempimages/g;  
   $fulltemplate =~ s/({|<)yabb uname(}|>)/$tempuname/g;  
   $fulltemplate =~ s/({|<)yabb boardlink(}|>)/$tempforumurl/g;  
   $fulltemplate =~ s/({|<)yabb navigation(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb searchbox(}|>)/$tempsearchbox/g;  
   $fulltemplate =~ s/({|<)yabb im(}|>)/$tempuim/g;  
   $fulltemplate =~ s/({|<)yabb time(}|>)/$temptime/g;  
   $fulltemplate =~ s/({|<)yabb langChooser(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb menu(}|>)/$temp21menu/g;  
   $fulltemplate =~ s/({|<)yabb tabmenu(}|>)/$tempmenu/g;  
   $fulltemplate =~ s/({|<)yabb rss(}|>)/$rssbutton/g;  
   $fulltemplate =~ s/({|<)yabb news(}|>)/$tempnews/g;  
   $fulltemplate =~ s/({|<)yabb newstitle(}|>)/$tempnewstitle/g;  
   $fulltemplate =~ s/({|<)yabb copyright(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb debug(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb forumjump(}|>)/$tempforumjump/g;  
   $fulltemplate =~ s/({|<)yabb freespace(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb navback(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb admin_alert(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb tabadd(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb addtab(}|>)//g;  
   $fulltemplate =~ s/({|<)yabb syntax_js(}|>)//g;  
   
   if ($selectedsection eq "vboard") {  
       $boardtempl = &BoardTempl($viewboard, $tempimages, $tempimagesdir);  
       $fulltemplate =~ s/({|<)yabb main(}|>)/$boardtempl/g;  
   } elsif ($selectedsection eq "vmessage") {  
       $messagetempl = &MessageTempl($viewmessage, $tempimages, $tempimagesdir);  
       $fulltemplate =~ s/({|<)yabb main(}|>)/$messagetempl/g;  
   } elsif ($selectedsection eq "vdisplay") {  
       $displaytempl = &DisplayTempl($viewdisplay, $tempimages, $tempimagesdir);  
       $fulltemplate =~ s/({|<)yabb main(}|>)/$displaytempl/g;  
   } elsif ($selectedsection eq "vmycenter") {  
       $mycentertempl = &MyCenterTempl($viewmycenter, $tempimages, $tempimagesdir);  
       $fulltemplate =~ s/({|<)yabb main(}|>)/$mycentertempl/g;  
   }  
   $fulltemplate =~ s~img src\=\"$tempimages\/(.+?)\"~&TmpImgLoc($1, $tempimages, $tempimagesdir)~eisg;  
   $fulltemplate =~ s/<a href="http:\/\/validator.w3.org\/check\/referer">.+?<\/a>//g;  
   $fulltemplate =~ s/<a href="http:\/\/jigsaw.w3.org\/css\-validator\/validator\?uri\=<yabb url>">.+?<\/a>//g;  
   $fulltemplate =~ s~[\n\r]~~g;  
   &ToHTML($fulltemplate);  
   
   $yymain .= qq~  
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">  
<table width="100%" cellspacing="1" cellpadding="4">  
   <tr>  
       <td align="left" valign="middle" class="titlebg">  
       <img src="$imagesdir/xx.gif" alt="" border="0" style="vertical-align: middle;" /><b> $templ_txt{'6'}</b>  
       </td>  
   </tr>  
</table>  
<table width="100%" cellspacing="1" cellpadding="0">  
   <tr>  
       <td width="100%" align="center" valign="middle" class="windowbg2">  
           <iframe id="TempManager" name="TempManager" width="100%" height="350" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes" style="border-top: 1px inset; border-bottom: 1px inset; visibility: visible; display: inline"></iframe>  
       </td>  
   </tr>  
</table>  
<form action="$adminurl?action=modskin2" name="selskin" method="post" style="display: inline;">  
<table width="100%" cellspacing="1" cellpadding="4">  
   <tr valign="middle">  
       <td align="left" class="windowbg2">  
       <div style="float: left; width: 30%; padding: 3px;"><label for="templateset"><b>$templ_txt{'10'}</b></label></div>  
   
       <div style="float: left; width: 69%;">  
           <input type="hidden" name="button" value="0" />  
           <select name="templateset" id="templateset" size="1" onchange="submit();">  
           $templatesel  
           </select>  
~; ~;
   unless ($akttemplate eq "Forum default") {     $yytitle     = $templ_txt{'1'}; 
       $yymain .= qq~            <input type="submit" value="$templ_txt{'14'}" onclick="document.selskin.button.value = '3'; return confirm('$templ_txt{'15'} $thistemplate?')" class="button" />~;     $action_area = 'modcss'; 
   }     AdminTemplate(); 
   $yymain .= qq~     return; 
       </div>  
       </td>  
   </tr>  
   <tr>  
       <td align="left" class="windowbg2">  
       <div style="float: left; width: 30%; padding: 3px;">  
           <b>$templ_txt{'11'}</b><br /><span class="small">$templ_txt{'7'}</span>  
       </div>  
       <div style="float: left; width: 69%;">  
           <div style="float: left; width: 32%; text-align: left;">  
               <label for="menutype"><span class="small">$admin_txt{'521'}</span></label><br />  
               <select name="menutype" id="menutype" size="1" style="width: 90%;">  
                   <option value="0"$menutype0>$admin_txt{'521a'}</option>  
                   <option value="1"$menutype1>$admin_txt{'521b'}</option>  
                   <option value="2"$menutype2>$admin_txt{'521c'}</option>  
               </select>  
           </div>  
           <br /><br /><br />  
           <div style="float: left; width: 32%; text-align: left;">  
               <label for="cssfile"><span class="small">$templ_txt{'1'}</span></label><br />  
               <select name="cssfile" id="cssfile" size="1" style="width: 90%;">  
               $forumcss  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <label for="imgfolder"><span class="small">$templ_txt{'8'}</span></label><br />  
               <select name="imgfolder" id="imgfolder" size="1" style="width: 90%;">  
               $imgdirs  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <label for="headfile"><span class="small">$templ_txt{'2'}</span></label><br />  
               <select name="headfile" id="headfile" size="1" style="width: 90%;">  
               $headtemplates  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <input type="radio" name="selsection" id="bradio" value="vboard" class="windowbg2" style="border: 0px; vertical-align: middle;"$boardsel /><label for="bradio" class="small">$templ_txt{'3'}</label><br />  
               <select name="boardfile" id="boardfile" size="1" style="width: 90%;">  
               $boardtemplates  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <input type="radio" name="selsection" id="mradio" value="vmessage" class="windowbg2" style="border: 0px; vertical-align: middle;"$messagesel /><label for="mradio" class="small">$templ_txt{'4'}</label><br />  
               <select name="messagefile" id="messagefile" size="1" style="width: 90%;">  
               $messagetemplates  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <input type="radio" name="selsection" id="dradio" value="vdisplay" class="windowbg2" style="border: 0px; vertical-align: middle;"$displaysel /><label for="dradio" class="small">$templ_txt{'5'}</label><br />  
               <select name="displayfile" id="displayfile" size="1" style="width: 90%;">  
               $displaytemplates  
               </select>  
           </div>  
           <div style="float: left; width: 32%; text-align: left;">  
               <input type="radio" name="selsection" id="myradio" value="vmycenter" class="windowbg2" style="border: 0px; vertical-align: middle;"$mycentersel /><label for="myradio" class="small">$templ_txt{'67'}</label><br />  
               <select name="mycenterfile" id="mycenterfile" size="1" style="width: 90%;">  
               $mycentertemplates  
               </select>  
           </div>  
       </div>  
       </td>  
   </tr>  
   <tr valign="middle">  
       <td align="left" class="windowbg2">  
       <div style="float: left; width: 30%; padding: 3px;"><label for="saveas"><b>$templ_txt{'12'}</b></label></div>  
       <div style="float: left; width: 69%;">  
           <input type="hidden" name="tempname" value="$fulltemplate" />  
           <input type="text" name="saveas" id="saveas" value="$thistemplate" size="30" maxlength="50" />  
           <input type="submit" value="$templ_txt{'13'}" onclick="document.selskin.button.value = '2';" class="button" />  
           <input type="submit" value="$templ_txt{'9'}" onclick="document.selskin.button.value = '1';" class="button" />  
       </div>  
       </td>  
   </tr>  
</table>  
</form>  
</div>  
   
<script type="text/javascript" language="JavaScript">  
<!--  
function updateTemplate() {  
   var thetemplate = document.selskin.tempname.value;  
   thetemplate=thetemplate.replace(/\\&amp\\;/g, "&");  
   thetemplate=thetemplate.replace(/\\&quot\\;/g, '"');  
   thetemplate=thetemplate.replace(/\\&nbsp\\;/g, " ");  
   thetemplate=thetemplate.replace(/\\&\\#124\\;/g, "|");  
   thetemplate=thetemplate.replace(/\\&lt\\;/g, "<");  
   thetemplate=thetemplate.replace(/\\&gt\\;/g, ">");  
   TempManager.document.open("text/html");  
   TempManager.document.write(thetemplate);  
   TempManager.document.close();  
}  
document.onload = updateTemplate();  
//-->  
</script>  
~;  
   $yytitle = $templ_txt{'6'};  
   $action_area = "modskin";  
   &AdminTemplate;  
}  
   
sub ModifySkin2 {  
   &is_admin_or_gmod;  
   $formattemp = $FORM{'templateset'};  
   &formatTempname;  
   if ($FORM{'button'} == 1) {  
       $yySetLocation = qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'}~;  
   
   } elsif ($FORM{'button'} == 2) {  
       $template_name = $FORM{'saveas'};  
       if ($template_name eq "default") { &admin_fatal_error("no_delete_default"); }  
       if ($template_name !~ m^\A[0-9a-zA-Z_\ \.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z^ || $template_name eq "") { &admin_fatal_error("invalid_template"); }  
       ($template_css, undef, undef) = split(/\./, $FORM{'cssfile'});  
       $template_images = $FORM{'imgfolder'};  
       ($template_head, undef) = split(/\./, $FORM{'headfile'});  
       ($template_board, undef) = split(/\//, $FORM{'boardfile'});  
       ($template_message, undef) = split(/\//, $FORM{'messagefile'});  
       ($template_display, undef) = split(/\//, $FORM{'displayfile'});  
       ($template_mycenter, undef) = split(/\//, $FORM{'mycenterfile'});  
       ($template_menutype, undef) = split(/\//, $FORM{'menutype'});  
       $formattemp = $FORM{'saveas'};  
       &formatTempname;  
       &UpdateTemplates($template_name, "save");  
       $yySetLocation = qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'}~;  
   
   } elsif ($FORM{'button'} == 3) {  
       $template_name = $FORM{'templateset'};  
       if ($template_name eq "default")       { &admin_fatal_error("no_delete_default"); }  
       if ($template_name eq "Forum default") { &admin_fatal_error("no_delete_default"); }  
       &UpdateTemplates($template_name, "delete");  
       $yySetLocation = qq~$adminurl?action=modskin~;  
   } else {  
       $yySetLocation = qq~$adminurl?action=modskin;templateset=$formattemp~;  
   }  
   &redirectexit;  
} }
   
sub formatTempname { sub ModifyCSS2 {
   $formattemp =~ s~\%~%25~g;     is_admin_or_gmod(); 
   $formattemp =~ s~\#~%23~g;     if ( $FORM{'button'} == 1 ) { 
   $formattemp =~ s~\+~%2B~g;         $yySetLocation = qq~$adminurl?action=modcss;cssfile=$FORM{'cssfile'}~; 
   $formattemp =~ s~\,~%2C~g;         redirectexit(); 
   $formattemp =~ s~\-~%2D~g;  
   $formattemp =~ s~\.~%2E~g;     } 
   $formattemp =~ s~\@~%40~g;     elsif ( $FORM{'button'} == 2 ) { 
   $formattemp =~ s~\^~%5E~g;         $style_name = $FORM{'savecssas'}; 
}         if ( $style_name eq 'default' ) { 
             fatal_error('no_delete_default');
sub TmpImgLoc {         } 
   if (!-e "$_[2]/$_[0]") { $thisimgloc = qq~img src="$forumstylesurl/default/$_[0]"~; }         if (   $style_name !~ m{\A[0-9a-zA-Z_\.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z}sm 
   else { $thisimgloc = qq~img src="$_[1]/$_[0]"~; }             || $style_name eq q{} ) 
   $thisimgloc;         { 
}             fatal_error('invalid_template'); 
         }
sub BoardTempl {         $style_cnt = $FORM{'stylelink'}; 
   &LoadLanguage('BoardIndex');         FromHTML($style_cnt); 
   my $tmpimagesdir = $imagesdir;         $style_cnt =~ s/(\*\/)/$1\n\n/gsm; 
   $imagesdir = qq~$_[1]~;         $style_cnt =~ s/(\/\*)/\n$1/gsm; 
   require "$templatesdir/$_[0]/BoardIndex.template";         $style_cnt =~ s/(\{)/$1\n/gsm; 
         $style_cnt =~ s/(\})/$1\n/gsm;
   if (-e ("$vardir/mostlog.txt")) {         $style_cnt =~ s/(\;)/$1\n/gsm; 
       fopen(MOSTUSERS, "$vardir/mostlog.txt");         @style_arr = split /\n/xsm, $style_cnt; 
       @mostentries = <MOSTUSERS>;  
       fclose(MOSTUSERS);         fopen( TMPCSS, ">$htmldir/Templates/Forum/$style_name.css" ) 
       ($mostmemb,  $datememb) = split(/\|/, $mostentries[0]);           || fatal_error( 'cannot_open', 
       ($mostguest, $dateguest) = split(/\|/, $mostentries[1]);             "$htmldir/Templates/Forum/$style_name.css", 1 ); 
       ($mostusers, $dateusers) = split(/\|/, $mostentries[2]);         foreach my $style_sgl (@style_arr) { 
       ($mostbots, $datebots) = split(/\|/, $mostentries[3]);             $style_sgl =~ s/\A\s+?//gxsm; 
       chomp($datememb, $dateguest, $dateusers, $datebots);             if ( $style_sgl =~ m{\;+\Z}sm ) { $style_sgl = qq~\t$style_sgl~; } 
       $themostmembdate = &timeformat($datememb);             $style_sgl =~ s/$yyhtml_root\/Templates\/Forum/\./gsm; 
       $themostguestdate = &timeformat($dateguest);             $style_sgl =~ s/$yyhtml_root/\.\.\/\.\./gsm; 
       $themostuserdate = &timeformat($dateusers);             print {TMPCSS} "$style_sgl\n" or croak "$croak{'print'} TMPCSS"; 
       $themostbotsdate = &timeformat($datebots);         } 
       $themostuser = $mostusers;         fclose(TMPCSS); 
       $themostmemb = $mostmemb;  
       $themostguest = $mostguest;         $yySetLocation = qq~$adminurl?action=modcss;cssfile=$style_name.css~; 
       $themostbots = $mostbots;         redirectexit(); 
   } else {  
       $themostmembdate  = &timeformat($date);     } 
       $themostguestdate = &timeformat($date);     elsif ( $FORM{'button'} == 3 ) { 
       $themostuserdate  = &timeformat($date);         $style_name = $FORM{'cssfile'}; 
       $themostbotsdate = &timeformat($date);         if ( $style_name eq 'default.css' ) { 
       $themostuser = 23;             fatal_error('no_delete_default'); 
       $themostmemb = 12;         } 
       $themostguest = 19;         unlink "$htmldir/Templates/Forum/$style_name"; 
       $themostbots = 4;         $yySetLocation = qq~$adminurl?action=modcss;cssfile=default.css~; 
   }         redirectexit(); 
     }
   $grpcolors = "";     return; 
   ($title, undef, undef, $color, $noshow) = split(/\|/, $Group{'Administrator'}, 5);  
   my $admcolor = qq~$color~;  
   if ($color && $noshow != 1) { $grpcolors .= qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~; }  
   ($title, undef, undef, $color, $noshow) = split(/\|/, $Group{'Global Moderator'}, 5);  
   if ($color && $noshow != 1) { $grpcolors .= qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~; }  
   foreach $nopostamount (sort { $a <=> $b } keys %NoPost) {  
       ($title, undef, undef, $color, $noshow) = split(/\|/, $NoPost{$nopostamount}, 5);  
       if ($color && $noshow != 1) { $grpcolors .= qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~; }  
   }  
   foreach $postamount (sort { $b <=> $a } keys %Post) {  
       ($title, undef, undef, $color, $noshow) = split(/\|/, $Post{$postamount}, 5);  
       if ($color && $noshow != 1) { $grpcolors .= qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~; }  
   }  
   
   my $latestmemberlink = qq~$boardindex_txt{'201'} <a href="javascript:;"><b>${$uid.$username}{'realname'}</b></a>.<br />~;  
   my $tempims = qq~$boardindex_txt{'795'} <a href="javascript:;"><b>2</b></a> $boardindex_txt{'796'} $boardindex_imtxt{'24'} <a href="javascript:;"><b>2</b></a> $boardindex_imtxt{'26'}.~;  
   my $tempforumurl = $mbname;  
   my $tempnew = qq~<img src="$imagesdir/off.gif" alt="" border="0" />~;  
   my $tempcurboard = $templ_txt{'77'};  
   my $tempcurboardurl = qq~javascript:;~;  
   my $tempboardanchor = $templ_txt{'78'};  
   my $tempbddescr = $templ_txt{'79'};  
   my $tempshowmods = qq~$boardindex_txt{'63'}: $templ_txt{'74'}<br />$boardindex_txt{'63a'}: $templ_txt{'74a'}~;  
   my $templastposttme  = &timeformat($date);  
   my $templastpostlink = qq~<a href="javascript:;">$img{'lastpost'}</a> $templastposttme~;  
   my $templastposter = qq~<a href="javascript:;">${$uid.$username}{'realname'}</a>~;  
   my $tmplasttopiclink = qq~<a href="javascript:;">$templ_txt{'80'}</a>~;  
   $tempcatlink = qq~<img src="$_[1]/cat_collapse.gif" alt="" border="0" /> <a href="javascript:;">$templ_txt{'81'}</a>~;  
   my $templatecat = $catheader;  
   $templatecat =~ s/({|<)yabb catlink(}|>)/$tempcatlink/g;  
   my $tmptemplateblock = $templatecat;  
   my $templastpostdate = &timeformat($date);  
   $templastpostdate = qq~($templastpostdate).<br />~;  
   my $temprecentposts = qq~$boardindex_txt{'791'} <select style="font-size: 7pt;"><option>&nbsp;</option><option>5</option></select> $boardindex_txt{'792'} $boardindex_txt{'793'}~;  
   my $tempguestson    = qq~<span class="small">$boardindex_txt{'141'}: <b>2</b></span>~;  
   my $tempbotson = qq~<span class="small">$boardindex_txt{'143'}: <b>3</b></span>~;  
   my $tempbotlist = qq~<span class="small">Googlebot (1), MSN Search (2)</span>~;  
   my $tempuserson = qq~<span class="small">$boardindex_txt{'142'}: <b>1</b></span>~;  
   my $tempusers = qq~<span class="small" style="color: $admcolor;"><b>${$uid.$username}{'realname'}</b></span><br />~;  
   my $tempmembercount = qq~<b>2</b>~;  
   my $tempboardpic = qq~ <img src="$imagesdir/boards.gif" alt="$tempcurboard" border="0" />~;  
   
   for ($i = 1; $i < 3; $i++) {  
       my $templateblock = $boardblock;  
       $templateblock =~ s/({|<)yabb new(}|>)/$tempnew/g;  
       $templateblock =~ s/({|<)yabb boardanchor(}|>)/$tempboardanchor/g;  
       $templateblock =~ s/({|<)yabb boardurl(}|>)/$tempcurboardurl/g;  
       $templateblock =~ s/({|<)yabb boardpic(}|>)/$tempboardpic/g;  
       $templateblock =~ s/({|<)yabb boardname(}|>)/$tempcurboard $i/g;  
       $templateblock =~ s/({|<)yabb boarddesc(}|>)/$tempbddescr/g;  
       $templateblock =~ s/({|<)yabb moderators(}|>)/$tempshowmods/g;  
       $templateblock =~ s/({|<)yabb threadcount(}|>)/$i/g;  
       $templateblock =~ s/({|<)yabb messagecount(}|>)/$i/g;  
       $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/g;  
       $templateblock =~ s/({|<)yabb lastposter(}|>)/$templastposter/g;  
       $templateblock =~ s/({|<)yabb lasttopiclink(}|>)/$tmplasttopiclink/g;  
       $tmptemplateblock .= $templateblock;  
   }  
   $tmptemplateblock .= $catfooter;  
   $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)//;  
   $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/g;  
   
   $collapselink = qq~$menusep$img{'collapse'}~;  
   $expandlink   = qq~$menusep$img{'expand'}~;  
   $markalllink  = qq~$menusep$img{'markallread'}~;  
   
   my $templasttopiclink = qq~$boardindex_txt{'236'} <a href="javascript:;"><b>$templ_txt{'80'}</b></a>~;  
   
   $boardhandellist     =~ s/({|<)yabb collapse(}|>)/$collapselink/g;  
   $boardhandellist     =~ s/({|<)yabb expand(}|>)//g;  
   $boardhandellist     =~ s/({|<)yabb markallread(}|>)/$markalllink/g;  
   $boardhandellist     =~ s/\Q$menusep//i;  
   $boardindex_template =~ s/({|<)yabb boardhandellist(}|>)/$boardhandellist/g;  
   $boardindex_template =~ s/({|<)yabb catimage(}|>)//g;  
   $boardindex_template =~ s~img src\=\"$tmpimagesdir\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   
   $boardindex_template =~ s/({|<)yabb newmsg start(}|>)//g;  
   $boardindex_template =~ s/({|<)yabb newmsg icon(}|>)//g;  
   $boardindex_template =~ s/({|<)yabb newmsg(}|>)//g;  
   $boardindex_template =~ s/({|<)yabb newmsg end(}|>)//g;  
   
   $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/3/g;  
   $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/3/g;  
   $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)/$templasttopiclink/g;  
   $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$templastpostdate/g;  
   $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$temprecentposts/g;  
   
   $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$themostuser/g;  
   $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$themostmemb/g;  
   $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$themostguest/g;  
   $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$themostbots/g;  
   $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/g;  
   $boardindex_template =~ s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/g;  
   $boardindex_template =~ s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/g;  
   $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/g;  
   $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/g;  
   
   $boardindex_template =~ s/({|<)yabb membercount(}|>)/$tempmembercount/g;  
   $boardindex_template =~ s/({|<)yabb latestmember(}|>)/$latestmemberlink/g;  
   $boardindex_template =~ s/({|<)yabb ims(}|>)/$tempims/g;  
   $boardindex_template =~ s/({|<)yabb users(}|>)/$tempuserson/g;  
   $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$tempusers/g;  
   $boardindex_template =~ s/({|<)yabb guests(}|>)/$tempguestson/g;  
   $boardindex_template =~ s/({|<)yabb onlineguests(}|>)//g;  
   $boardindex_template =~ s/({|<)yabb bots(}|>)/$tempbotson/g;  
   $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$tempbotlist/g;  
   $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)//g;  
   $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//g;  
   $boardindex_template =~ s~img src\=\"$_[1]\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $imagesdir = $tmpimagesdir;  
   $boardindex_template;  
}  
   
sub MessageTempl {  
   &LoadLanguage('MessageIndex');  
   my $tmpimagesdir = $imagesdir;  
   $imagesdir = "$_[1]";  
   require "$templatesdir/$_[0]/MessageIndex.template";  
   my $tempcatnm = $templ_txt{'72'};  
   my $tempboardnm = $templ_txt{'73'};  
   my $tempmodslink = qq~($messageindex_txt{'298'}: $templ_txt{'74'} - $messageindex_txt{'298a'}: $templ_txt{'74a'})~;  
   my $tempbdescrip = $templ_txt{'79'};  
   my $temppageindextgl = qq~<img src="$_[1]/xx.gif" style="vertical-align: middle;" alt="" border="0" />~;  
   my $temppageindex = qq~<span class="small" style="vertical-align: middle;"> <b>$messageindex_txt{'139'}:</b> 1</span>~;  
   my $tempthreadpic = qq~<img src="$_[1]/thread.gif" style="vertical-align: middle;" alt="" border="0" />~;  
   my $tempmicon = qq~<img src="$_[1]/xx.gif" style="vertical-align: middle;" alt="" border="0" />~;  
   my $tempnew = qq~<img src="$_[1]/new.gif" style="vertical-align: middle;" alt="" border="0" />~;  
   my $tempmsublink = $templ_txt{'83'};  
   my $tempmname = ${$uid.$username}{'realname'};  
   my $templastpostlink = qq~<img src="$_[1]/lastpost.gif" style="vertical-align: middle;" alt="" border="0" /> $templ_txt{'82'}~;  
   my $templastposter = $tempmname;  
   my $tempyabbicons = qq~  
   <img src="$_[1]/thread.gif" alt="" /> $messageindex_txt{'457'}<br />  
   <img src="$_[1]/hotthread.gif" alt="" /> $messageindex_txt{'454'} x $messageindex_txt{'454a'}<br />  
   <img src="$_[1]/veryhotthread.gif" alt="" /> $messageindex_txt{'455'} x $messageindex_txt{'454a'}<br />  
   <img src="$_[1]/locked.gif" alt="" /> $messageindex_txt{'456'}<br />  
   <img src="$_[1]/locked_moved.gif" alt="" /> $messageindex_txt{'845'}  
   ~;  
   my $tempyabbadminicons .= qq~  
   <img src="$_[1]/hide.gif" alt="" /> $messageindex_txt{'458'}<br />  
   <img src="$_[1]/hidesticky.gif" alt="" /> $messageindex_txt{'459'}<br />  
   <img src="$_[1]/hidelock.gif" alt="" /> $messageindex_txt{'460'}<br />  
   <img src="$_[1]/hidestickylock.gif" alt="" /> $messageindex_txt{'461'}<br />  
   <img src="$_[1]/announcement.gif" alt="" /> $messageindex_txt{'779a'}<br />  
   <img src="$_[1]/announcementlock.gif" alt="" /> $messageindex_txt{'779b'}<br />  
   <img src="$_[1]/sticky.gif" alt="" /> $messageindex_txt{'779'}<br />  
   <img src="$_[1]/stickylock.gif" alt="" /> $messageindex_txt{'780'}  
   ~;  
   
   $notify_board = qq~$menusep$img{'notify'}~;  
   $markalllink = qq~$menusep$img{'markboardread'}~;  
   $postlink = qq~$menusep$img{'newthread'}~;  
   $polllink = qq~$menusep$img{'createpoll'}~;  
   
   $bdpic = qq~ <img src="$_[1]/boards.gif" alt="$templ_txt{'72'}" border="0" align="middle" /> ~;  
   $message_permalink = $messageindex_txt{'10'};  
   $temp_attachment = qq~<img src="$_[1]/paperclip.gif" alt="$messageindex_txt{'5'}" />~;  
   
   $messageindex_template =~ s/({|<)yabb home(}|>)/$mbname/g;  
   $messageindex_template =~ s/({|<)yabb category(}|>)/$tempcatnm/g;  
   $messageindex_template =~ s/({|<)yabb board(}|>)/$tempboardnm/g;  
   $messageindex_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/g;  
   $messageindex_template =~ s/({|<)yabb bdpicture(}|>)/$bdpic/g;  
   $messageindex_template =~ s/({|<)yabb threadcount(}|>)/1/g;  
   $messageindex_template =~ s/({|<)yabb messagecount(}|>)/2/g;  
   $boarddescription =~ s/({|<)yabb boarddescription(}|>)/$tempbdescrip/g;  
   $messageindex_template =~ s/({|<)yabb description(}|>)/$boarddescription/g;  
   $messageindex_template =~ s/({|<)yabb colspan(}|>)/7/g;  
   
   $messageindex_template =~ s/({|<)yabb pageindex top(}|>)/$temppageindex1/g;  
   $messageindex_template =~ s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/g;  
   $topichandellist =~ s/({|<)yabb notify button(}|>)/$notify_board/g;  
   $topichandellist =~ s/({|<)yabb markall button(}|>)/$markalllink/g;  
   $topichandellist =~ s/({|<)yabb new post button(}|>)/$postlink/g;  
   $topichandellist =~ s/({|<)yabb new poll button(}|>)/$polllink/g;  
   $topichandellist =~ s/\Q$menusep//i;  
   $messageindex_template =~ s/({|<)yabb topichandellist(}|>)/$topichandellist/g;  
   
   $messageindex_template =~ s/({|<)yabb pageindex(}|>)/$temppageindex/g;  
   $messageindex_template =~ s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/g;  
   $messageindex_template =~ s/({|<)yabb admin column(}|>)//g;  
   
   my $tempbar = $threadbar;  
   $tempbar =~ s/({|<)yabb admin column(}|>)//g;  
   $tempbar =~ s/({|<)yabb threadpic(}|>)/$tempthreadpic/g;  
   $tempbar =~ s/({|<)yabb icon(}|>)/$tempmicon/g;  
   $tempbar =~ s/({|<)yabb new(}|>)/$tempnew/g;  
   $tempbar =~ s/({|<)yabb poll(}|>)//g;  
   $tempbar =~ s/({|<)yabb favorite(}|>)//g;  
   $tempbar =~ s/({|<)yabb subjectlink(}|>)/$tempmsublink/g;  
   $tempbar =~ s/({|<)yabb pages(}|>)//g;  
   $tempbar =~ s/({|<)yabb attachmenticon(}|>)/$temp_attachment/g;  
   $tempbar =~ s/({|<)yabb starter(}|>)/$tempmname/g;  
   $tempbar =~ s/({|<)yabb replies(}|>)/2/g;  
   $tempbar =~ s/({|<)yabb views(}|>)/12/g;  
   $tempbar =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/g;  
   $tempbar =~ s/({|<)yabb lastposter(}|>)/$templastposter/g;  
   
   if ($accept_permalink == 1) {  
       $tempbar =~ s/({|<)yabb permalink(}|>)/$message_permalink/g;  
   } else {  
       $tempbar =~ s/({|<)yabb permalink(}|>)//g;  
   }  
   
   $tmptempbar .= $tempbar;  
   
   $messageindex_template =~ s/({|<)yabb threadblock(}|>)/$tmptempbar/g;  
   $messageindex_template =~ s/({|<)yabb modupdate(}|>)//g;  
   $messageindex_template =~ s/({|<)yabb modupdateend(}|>)//g;  
   $messageindex_template =~ s/({|<)yabb stickyblock(}|>)//g;  
   $messageindex_template =~ s/({|<)yabb adminfooter(}|>)//g;  
   $messageindex_template =~ s/({|<)yabb icons(}|>)/$tempyabbicons/g;  
   $messageindex_template =~ s/({|<)yabb admin icons(}|>)/$tempyabbadminicons/g;  
   $messageindex_template =~ s/({|<)yabb access(}|>)//g;  
   $messageindex_template =~ s~img src\=\"$tmpimagesdir\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $messageindex_template =~ s~img src\=\"$_[1]\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $imagesdir = $tmpimagesdir;  
   $messageindex_template;  
}  
   
sub DisplayTempl {  
   &LoadLanguage('Display');  
   my $tmpimagesdir = $imagesdir;  
   $imagesdir = $_[1];  
   require "$templatesdir/$_[0]/Display.template";  
   ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms) = split(/\|/, $Group{"Administrator"});  
   if ($UseMenuType == 0) {  
       $yimimg = qq~$menusep<img src="$_[1]/yim.gif" alt="" border="0" />~;  
       $aimimg = qq~$menusep<img src="$_[1]/aim.gif" alt="" border="0" />~;  
       $msnimg = qq~$menusep<img src="$_[1]/msn.gif" alt="" border="0" />~;  
   } elsif ($UseMenuType == 1) {  
       $yimimg = qq~$menusep<span class="imgwindowbg">YIM</span>~;  
       $aimimg = qq~$menusep<span class="imgwindowbg">AIM</span>~;  
       $msnimg = qq~$menusep<span class="imgwindowbg">MSN</span>~;  
   } else {  
       $yimimg = qq~$menusep<img src="$yyhtml_root/Buttons/$language/yim.png" alt="" border="0" />~;  
       $aimimg = qq~$menusep<img src="$yyhtml_root/Buttons/$language/aim.png" alt="" border="0" />~;  
       $msnimg = qq~$menusep<img src="$yyhtml_root/Buttons/$language/msn.png" alt="" border="0" />~;  
   }  
   my $template_home = qq~<span class="nav">$mbname</span>~;  
   my $tempcatnm = $templ_txt{'72'};  
   my $tempboardnm = $templ_txt{'73'};  
   my $tempmodslink = qq~($display_txt{'298'}: $templ_txt{'74'} - $display_txt{'298a'}: $templ_txt{'74a'})~;  
   my $template_prev = $display_txt{'768'};  
   my $template_next = $display_txt{'767'};  
   my $temppageindextgl = qq~<img src="$_[1]/xx.gif" style="vertical-align: middle;" alt="" border="0" />~;  
   my $temppageindex1 = qq~<span class="small" style="vertical-align: middle;"> <b>$display_txt{'139'}:</b> 1</span>~;  
   my $replybutton = qq~$menusep$img{'reply'}~;  
   my $pollbutton = qq~$menusep$img{'addpoll'}~;  
   my $notify = qq~$menusep$img{'notify'}~;  
   my $template_sendtopic = qq~$menusep$img{'sendtopic'}~;  
   my $template_print = qq~$menusep$img{'print'}~;  
   my $template_threadimage = qq~<img src="$_[1]/thread.gif" align="middle" alt="" />~;  
   my $threadurl = $templ_txt{'75'};  
   my $template_alertmod = qq~$menusep$img{'alertmod'}~;  
   my $template_quote = qq~$menusep$img{'quote'}~;  
   my $template_modify = qq~$menusep$img{'modify'}~;  
   my $template_split = qq~$menusep$img{'admin_split'}~;  
   my $template_delete = qq~$menusep$img{'delete'}~;  
   my $memberinfo = qq~<span class="small"><b>$title</b></span>~;  
   my $usernamelink = qq~<span style="color: $color;"><b>${$uid.$username}{'realname'}</b></span><br />~;  
   
   for (1 .. 5) {  
       $star .= qq(<img src="$_[1]/$starpic" border="0" alt="*" />);  
   }  
   my $msub = $templ_txt{'76'};  
   my $msgimg = qq~<img src="$_[1]/xx.gif" align="middle" alt="" />~;  
   my $messdate = &timeformat($date);  
   my $template_postinfo = qq~$display_txt{'21'}: ${$uid.$username}{'postcount'}<br />~;  
   my $template_usertext = qq~${$uid.$username}{'usertext'}<br />~;  
   my $avatar = qq~<img src="$facesurl/elmerfudd.gif" name="avatar" alt="" border="0" align="middle" style="max-width: $userpic_width\px\; max-height: $userpic_height\px" />~;  
   my $message = qq~$templ_txt{'65'}<br /><a href="javascript:;">$templ_txt{'66'}</a>~;  
   my $template_email = qq~$menusep$img{'email_sm'}~;  
   my $template_pm = qq~$menusep$img{'message_sm'}~;  
   my $ipimg = qq~<img src="$imagesdir/ip.gif" alt="" border="0" align="middle" />~;  
   my $template_remove = qq~$menusep$img{'admin_rem'}~;  
   my $template_splice = qq~$menusep$img{'admin_move_split_splice'}~;  
   my $template_lock = qq~$menusep$img{'admin_lock'}~;  
   my $template_hide = qq~$menusep$img{'hide'}~;  
   my $template_sticky = qq~$menusep$img{'admin_sticky'}~;  
   
   $online = qq~<span class="useronline">$maintxt{'60'}</span>~;  
   
   for ($i = 0; $i < 2; $i++) {  
       my $outblock = $messageblock;  
       my $posthandelblock = $posthandellist;  
       my $contactblock = $contactlist;  
   
       if ($i == 0) {  
           $css = qq~windowbg~;  
           $counterwords = "";  
       } else {  
           $css = qq~windowbg2~;  
           $counterwords = "$display_txt{'146'} #$i";  
       }  
   
       $posthandelblock =~ s/({|<)yabb modalert(}|>)/$template_alertmod/g;  
       $posthandelblock =~ s/({|<)yabb quote(}|>)/$template_quote/g;  
       $posthandelblock =~ s/({|<)yabb modify(}|>)/$template_modify/g;  
       $posthandelblock =~ s/({|<)yabb split(}|>)/$template_split/g;  
       $posthandelblock =~ s/({|<)yabb delete(}|>)/$template_delete/g;  
       $posthandelblock =~ s/({|<)yabb admin(}|>)/$template_admin/g;  
       $posthandelblock =~ s/\Q$menusep//i;  
   
       $contactblock =~ s/({|<)yabb email(}|>)/$template_email/g;  
       $contactblock =~ s/({|<)yabb profile(}|>)//g;  
       $contactblock =~ s/({|<)yabb pm(}|>)/$template_pm/g;  
       $contactblock =~ s/({|<)yabb www(}|>)//g;  
       $contactblock =~ s/({|<)yabb aim(}|>)/$aimimg/g;  
       $contactblock =~ s/({|<)yabb yim(}|>)/$yimimg/g;  
       $contactblock =~ s/({|<)yabb icq(}|>)//g;  
       $contactblock =~ s/({|<)yabb msn(}|>)/$msnimg/g;  
       $contactblock =~ s/({|<)yabb gtalk(}|>)//g;  
       $contactblock =~ s/({|<)yabb skype(}|>)//g;  
       $contactblock =~ s/({|<)yabb myspace(}|>)/$myspacead/g;  
       $contactblock =~ s/({|<)yabb facebook(}|>)/$facebookad/g;  
       $contactblock =~ s/({|<)yabb addbuddy(}|>)//g;  
       $contactblock =~ s/\Q$menusep//i;  
   
       $outblock =~ s/({|<)yabb images(}|>)/$tmpimagesdir/g;  
       $outblock =~ s/({|<)yabb messageoptions(}|>)//g;  
       $outblock =~ s/({|<)yabb memberinfo(}|>)/$memberinfo/g;  
       $outblock =~ s/({|<)yabb userlink(}|>)/$usernamelink/g;  
       $outblock =~ s/({|<)yabb stars(}|>)/$star/g;  
       $outblock =~ s/({|<)yabb subject(}|>)/$msub/g;  
       $outblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/g;  
       $outblock =~ s/({|<)yabb msgdate(}|>)/$messdate/g;  
       $outblock =~ s/({|<)yabb replycount(}|>)/$counterwords/g;  
       $outblock =~ s/({|<)yabb count(}|>)//g;  
       $outblock =~ s/({|<)yabb att(}|>)//g;  
       $outblock =~ s/({|<)yabb css(}|>)/$css/g;  
       $outblock =~ s/({|<)yabb gender(}|>)//g;  
       $outblock =~ s/({|<)yabb ext_prof(}|>)/$template_ext_prof/g;  
       $outblock =~ s/({|<)yabb location(}|>)//g;  
       $outblock =~ s/({|<)yabb isbuddy(}|>)//g;  
       $outblock =~ s/({|<)yabb useronline(}|>)/$online/g;  
       $outblock =~ s/({|<)yabb postinfo(}|>)/$template_postinfo/g;  
       $outblock =~ s/({|<)yabb usertext(}|>)/$template_usertext/g;  
       $outblock =~ s/({|<)yabb userpic(}|>)/$avatar/g;  
       $outblock =~ s/({|<)yabb message(}|>)/$message/g;  
       $outblock =~ s/({|<)yabb showatt(}|>)//g;  
       $outblock =~ s/({|<)yabb showatthr(}|>)//g;  
       $outblock =~ s/({|<)yabb modified(}|>)//g;  
       $outblock =~ s/({|<)yabb signature(}|>)//g;  
       $outblock =~ s/({|<)yabb signaturehr(}|>)//g;  
       $outblock =~ s/({|<)yabb ipimg(}|>)/$ipimg/g;  
       $outblock =~ s/({|<)yabb ip(}|>)//g;  
       $outblock =~ s/({|<)yabb permalink(}|>)//g;  
       $outblock =~ s/({|<)yabb posthandellist(}|>)/$posthandelblock/g;  
       $outblock =~ s/({|<)yabb contactlist(}|>)/$contactblock/g;  
       $tempoutblock .= $outblock;  
   }  
   
   $threadhandellist =~ s/({|<)yabb reply(}|>)/$replybutton/g;  
   $threadhandellist =~ s/({|<)yabb poll(}|>)/$template_poll/g;  
   $threadhandellist =~ s/({|<)yabb notify(}|>)/$template_notify/g;  
   $threadhandellist =~ s/({|<)yabb favorite(}|>)/$template_favorite/g;  
   $threadhandellist =~ s/({|<)yabb sendtopic(}|>)/$template_sendtopic/g;  
   $threadhandellist =~ s/({|<)yabb print(}|>)/$template_print/g;  
   $threadhandellist =~ s/({|<)yabb markunread(}|>)//g;  
   $threadhandellist =~ s/\Q$menusep//i;  
   
   $adminhandellist =~ s/({|<)yabb remove(}|>)/$template_remove/g;  
   $adminhandellist =~ s/({|<)yabb splice(}|>)/$template_splice/g;  
   $adminhandellist =~ s/({|<)yabb lock(}|>)/$template_lock/g;  
   $adminhandellist =~ s/({|<)yabb hide(}|>)/$template_hide/g;  
   $adminhandellist =~ s/({|<)yabb sticky(}|>)/$template_sticky/g;  
   $adminhandellist =~ s/({|<)yabb multidelete(}|>)/$template_multidelete/g;  
   $adminhandellist =~ s/\Q$menusep//i;  
   
   $display_template =~ s/({|<)yabb pollmain(}|>)//g;  
   $display_template =~ s/({|<)yabb topicviewers(}|>)//g;  
   
   $display_template =~ s/({|<)yabb home(}|>)/$template_home/g;  
   $display_template =~ s/({|<)yabb category(}|>)/$tempcatnm/g;  
   $display_template =~ s/({|<)yabb board(}|>)/$tempboardnm/g;  
   $display_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/g;  
   $display_template =~ s/({|<)yabb prev(}|>)/$template_prev/g;  
   $display_template =~ s/({|<)yabb next(}|>)/$template_next/g;  
   $display_template =~ s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/g;  
   $display_template =~ s/({|<)yabb pageindex top(}|>)/$temppageindex1/g;  
   $display_template =~ s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/g;  
   $display_template =~ s/({|<)yabb threadhandellist(}|>)/$threadhandellist/g;  
   $display_template =~ s/({|<)yabb threadimage(}|>)/$template_threadimage/g;  
   $display_template =~ s/({|<)yabb threadurl(}|>)/$threadurl/g;  
   $display_template =~ s/({|<)yabb views(}|>)/12/g;  
   $display_template =~ s/({|<)yabb multistart(}|>)//g;  
   $display_template =~ s/({|<)yabb multiend(}|>)//g;  
   $display_template =~ s/({|<)yabb postsblock(}|>)/$tempoutblock/g;  
   $display_template =~ s/({|<)yabb adminhandellist(}|>)/$adminhandellist/g;  
   $display_template =~ s/({|<)yabb forumselect(}|>)//g;  
   $display_template =~ s~img src\=\"$tmpimagesdir\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $display_template =~ s~img src\=\"$_[1]\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $imagesdir = $tmpimagesdir;  
   $display_template;  
}  
   
sub MyCenterTempl {  
   &LoadLanguage('InstantMessage');  
   &LoadLanguage('MyCenter');  
   my $tmpimagesdir = $imagesdir;  
   $imagesdir = $_[1];  
   require "$templatesdir/$_[0]/MyCenter.template";  
   
   $tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="float: left; vertical-align: middle;" />~;  
   $tabfill = qq~<img src="$imagesdir/tabfill.gif" border="0" alt="" style="vertical-align: middle;" />~;  
   
   if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))   )    {  
       $yymcmenu .= qq~<span title="$mc_menus{'messages'}" class="selected">$tabsep$tabfill$mc_menus{'messages'}$tabfill</span>  
       ~;  
   }  
   
   $yymcmenu .= qq~$tabsep<span title="$mc_menus{'profile'}">$tabfill$mc_menus{'profile'}$tabfill</span>~;  
   $yymcmenu .= qq~$tabsep<span title="$mc_menus{'posts'}">$tabfill$mc_menus{'posts'}$tabfill</span>~;  
   $yymcmenu .= qq~$tabsep~;  
   
   $mycenter_template =~ s/{yabb mcviewmenu}/$MCViewMenu/g;  
   $mycenter_template =~ s/{yabb mcmenu}/$yymcmenu/g;  
   $mycenter_template =~ s/{yabb mcpmmenu}/$MCPmMenu/g;  
   $mycenter_template =~ s/{yabb mcprofmenu}/$MCProfMenu/g;  
   $mycenter_template =~ s/{yabb mcpostsmenu}/$MCPostsMenu/g;  
   $mycenter_template =~ s/{yabb mcglobformstart}/$MCGlobalFormStart/g;  
   $mycenter_template =~ s/{yabb mcglobformend}/ ($MCGlobalFormStart ? "<\/form>" : "") /e;  
   $mycenter_template =~ s/{yabb mcextrasmilies}/$MCExtraSmilies/g;  
   $mycenter_template =~ s/{yabb mccontent}/$MCContent/g;  
   $mycenter_template =~ s/{yabb mctitle}/$mctitle/g;  
   $mycenter_template =~ s/{yabb selecthtml}/$selecthtml/g;  
   
   $mycenter_template =~ s~img src\=\"$tmpimagesdir\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $mycenter_template =~ s~img src\=\"$_[1]\/(.+?)\"~&TmpImgLoc($1, $_[1], $_[2])~eisg;  
   $imagesdir = $tmpimagesdir;  
   $mycenter_template;  
}  
   
sub UpdateTemplates {  
   my ($tempelement, $tempjob) = @_;  
   if ($tempjob eq "new") { # update to new style from very old versions  
       require "$templatesdir/$tempelement/$tempelement.cfg";  
       if ($template_name !~ m^\A[0-9a-zA-Z_\\ \.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z^ || $template_name eq "") {  
           $template_name = "Invalid template_name in $tempelement.cfg";  
       }  
       my $testname = $template_name;  
       my $i        = 1;  
       while (my ($curtemplate, $value) = each(%templateset)) {  
           if (lc $curtemplate eq lc $testname) {  
               $testname = qq~$template_name ($i)~;  
               $i++;  
           }  
       }  
       if ($template_css) { $templateset{"$testname"} = "$tempelement"; }  
       else { $templateset{"$testname"} = "default"; }  
       if ($template_images) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_head) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_board) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_message) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_display) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_mycenter) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|default"; }  
       if ($template_menutype) { $templateset{"$testname"} .= "|$tempelement"; }  
       else { $templateset{"$testname"} .= "|"; }  
   
       unlink "$templatesdir/$tempelement/$tempelement.cfg";  
       return;  
   
   } elsif ($tempjob eq "save") {  
       $templateset{"$tempelement"} = "$template_css";  
       $templateset{"$tempelement"} .= "|$template_images";  
       $templateset{"$tempelement"} .= "|$template_head";  
       $templateset{"$tempelement"} .= "|$template_board";  
       $templateset{"$tempelement"} .= "|$template_message";  
       $templateset{"$tempelement"} .= "|$template_display";  
       $templateset{"$tempelement"} .= "|$template_mycenter";  
       $templateset{"$tempelement"} .= "|$template_menutype";  
   
   } elsif ($tempjob eq "delete") {  
       delete $templateset{$tempelement};  
   }  
   
   require "$admindir/NewSettings.pl";  
   &SaveSettingsTo('Settings.pl');  
} }
   
1; 1;