<?

  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  if (!($result_proper = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $proper = mysql_fetch_array ($result_proper);
  include '../lang/' . $proper['admin_language'];
  echo '
<HTML><BODY STYLE="color: Navy;"><LINK HREF="../style.css" REL="stylesheet" TYPE="text/css"><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=1><TR><TD style="background-color:#505090;"><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR="#EFEFF8">
<TR><TD VALIGN=top BGCOLOR="#BFBFDF" STYLE="border-bottom: 1px solid #505090;"><FONT COLOR="navy"><B>';
  echo $admin_Category_Menu_Settings;
  echo '</B></FONT></TD></TR><TR><TD VALIGN=top>

';
  echo '<s';
  echo 'cript language="javascript">
var win= null;

function NewWindow(fieldName)
{
	document.form1.fieldName.value=fieldName
	win2=window.open(\'../colorchart.html\',\'colorPop\',\'height=130,width=274,top=150,left=100,scrollbars=no,resizable=no\');
}

function doIt(color)
{
	eval(\'document.form1.\' + document.form1.fieldName.value + \'.value=\\\'\' + color + \'\\\'\');
	//eval(\'document.form1.\' + document';
  echo '.form1.fieldName.value + \'.style.background=\\\'\' + color + \'\\\'\');
}
</script>

';
  if ($_POST['save'])
  {
    if (!(mysql_query ('' . 'delete from cat_styles WHERE skin=\'' . $_POST['tpl'] . '\'')))
    {
      exit ('Invalid query1');
      ;
    }

    $SQL = '' . 'INSERT INTO cat_styles VALUES(
	\'' . $_POST['color'] . '\',
	\'' . $_POST['font'] . '\',
	\'' . $_POST['font_size'] . '\',
	\'' . $_POST['font_weight'] . '\',
	\'' . $_POST['decoration'] . '\',
	\'' . $_POST['bg_color'] . '\',
	\'' . $_POST['border'] . '\',
	\'' . $_POST['border_color'] . '\',
	\'' . $_POST['tpl'] . '\'
	)';
    if (!(mysql_query ($SQL)))
    {
      exit ('Invalid query2');
      ;
    }

    echo '<B><FONT COLOR="white" STYLE="background-color:red;">&nbsp;Last Changes Saved!&nbsp;</FONT></B>';
  }

  if ($_POST['tpl'])
  {
    if (!($result = mysql_query ('' . 'SELECT * FROM cat_styles WHERE skin=\'' . $_POST['tpl'] . '\'')))
    {
      exit ('Invalid query1');
      ;
    }
  }
  else
  {
    if (!($result1 = mysql_query ('SELECT * FROM tpl')))
    {
      exit ('Invalid query3');
      ;
    }

    $row1 = mysql_fetch_array ($result1);
    if (!($result = mysql_query ('' . 'SELECT * FROM cat_styles WHERE skin=\'' . $row1['name'] . '\'')))
    {
      exit ('Invalid query1');
      ;
    }
  }

  $row = mysql_fetch_array ($result);
  if ((!$row AND !$_POST['tpl']))
  {
    $row['skin'] = $row1['name'];
  }

  if (!$row)
  {
    $row['skin'] = $_POST['tpl'];
  }

  echo '

<FORM name="form1" ACTION="';
  echo $php_self;
  echo '" METHOD=post><input type="hidden" name="fieldName" value="">


';
  echo $admin_Templates;
  echo '	';
  echo '<S';
  echo 'ELECT NAME="tpl" onChange="submit()">
	';
  if ($dir = @opendir ($documentroot . '/upload/templates'))
  {
    while ($file = readdir ($dir) !== false)
    {
      if (($file != '.' AND $file != '..'))
      {
        echo '					<OPTION VALUE="';
        echo $file;
        echo '" ';
        if ($row['skin'] == $file)
        {
          echo 'selected';
        }

        echo '>';
        echo $file;
        echo '</OPTION>
			';
        continue;
      }
    }
  }

  closedir ($dir);
  echo '	</SELECT>

<br><br>


<table width="400" border="1" cellspacing="0" cellpadding="5">
<tr><td>

';
  echo $admin_color;
  echo '<input type="text" name="color" value="';
  echo $row['color'];
  echo '" size="7">
<input type="button" value="Color" onclick="NewWindow(\'color\');return false">
<BR><br>

';
  echo $admin_font;
  echo '<S';
  echo 'ELECT NAME="font">
';
  for ($j = 0; $j < sizeof ($font); ++$j)
  {
    echo '<OPTION VALUE="';
    echo $font[$j];
    echo '" ';
    if ($row['font'] == $font[$j])
    {
      echo 'SELECTED';
    }

    echo ' STYLE="color:';
    echo $font[$j];
    echo ' ;">';
    echo $font[$j];
    echo '</OPTION>';
  }

  echo '</SELECT>
<BR><br>

';
  echo $admin_font_size;
  echo '<S';
  echo 'ELECT NAME="font_size">
';
  for ($j = 8; $j < 24; ++$j)
  {
    echo '<OPTION VALUE="';
    echo $j;
    echo '" ';
    if ($row['font_size'] == $j)
    {
      echo 'SELECTED';
    }

    echo ' STYLE="color:';
    echo $j;
    echo ' ;">';
    echo $j;
    echo '</OPTION>
';
  }

  ++$i;
  echo '</SELECT> px
<br><br>

';
  echo $admin_font_weight;
  echo '<INPUT TYPE=radio NAME="font_weight" VALUE="bold" ';
  if ($row['font_weight'] == 'bold')
  {
    echo 'checked';
  }

  echo '>';
  echo $admin_bold;
  echo '<INPUT TYPE=radio NAME="font_weight" VALUE="normal" ';
  if ($row['font_weight'] == 'normal')
  {
    echo 'checked';
  }

  echo '>';
  echo $admin_normal;
  echo '<br><br>

';
  echo $admin_text_decoration;
  echo '<INPUT TYPE=radio NAME="decoration" VALUE="underline" ';
  if ($row['decoration'] == 'underline')
  {
    echo 'checked';
  }

  echo '>';
  echo $admin_yes;
  echo '<INPUT TYPE=radio NAME="decoration" VALUE="none" ';
  if ($row['decoration'] == 'none')
  {
    echo 'checked';
  }

  echo '>';
  echo $admin_no;
  echo '<br><br>

';
  echo $admin_background_color;
  echo '<input type="text" name="bg_color" value="';
  echo $row['bg_color'];
  echo '" size="7">
<input type="button" value="Color" onclick="NewWindow(\'bg_color\');return false">
<BR><br>

';
  echo $admin_border;
  echo '<INPUT TYPE=radio NAME="border" VALUE="1" ';
  if ($row['border'] == '1')
  {
    echo 'checked';
  }

  echo '><img src="../images/b1.gif" border="0">
<INPUT TYPE=radio NAME="border" VALUE="2" ';
  if ($row['border'] == '2')
  {
    echo 'checked';
  }

  echo '><img src="../images/b2.gif" border="0">
<INPUT TYPE=radio NAME="border" VALUE="3" ';
  if ($row['border'] == '3')
  {
    echo 'checked';
  }

  echo '><img src="../images/b3.gif" border="0">
<br><br>

';
  echo $admin_border_color;
  echo '<input type="text" name="border_color" value="';
  echo $row['border_color'];
  echo '" size="7">
<input type="button" value="Color" onclick="NewWindow(\'border_color\');return false">
<BR>


</td><td>
<DIV ALIGN="center"><B><FONT COLOR="#000080">';
  echo $admin_Preview;
  echo '</FONT></B></DIV><BR>


<table width="100%" border="0" cellspacing="0" cellpadding="3" ';
  if ($row['border'] == '1')
  {
    echo 'style="border: 1px solid ';
    echo $row['border_color'];
    echo ';"';
  }

  if ($row['border'] == '2')
  {
    echo 'style="border-top-width:1px; border-top-style:solid; border-top-color:';
    echo $row['border_color'];
    echo '; border-left-width:1px; border-left-style:solid; border-left-color:';
    echo $row['border_color'];
    echo '; border-right-width:1px; border-right-style:solid; border-right-color:';
    echo $row['border_color'];
    echo ';"';
  }

  echo '>
';
  if (!($result1 = mysql_query ('SELECT * FROM categories')))
  {
    exit ('Invalid query1');
    ;
  }

  while ($row1 = mysql_fetch_array ($result1))
  {
    echo '
<tr><td ';
    if ($row['bg_color'])
    {
      echo '' . 'bgcolor=' . $row['bg_color'] . ' ';
    }

    if ($row['border'] == '2')
    {
      echo 'style="border-bottom-width:1px; border-bottom-style: solid; border-bottom-color:';
      echo $row['border_color'];
      echo ';"';
    }

    echo '>
<a href="javascript:" style="text-decoration:';
    echo $row['decoration'];
    echo ';color:';
    echo $row['color'];
    echo '; font-family:';
    echo $row['font'];
    echo '; font-size:';
    echo $row['font_size'];
    echo '; font-weight:';
    echo $row['font_weight'];
    echo ';">';
    echo $row1['name'];
    echo '</a>
</td></tr>

';
  }

  echo '
</table>





</td></tr></table>


<br><input type="submit" name="save" value="';
  echo $admin_save_settings;
  echo '">

</FORM>
</TD></TR></TABLE></TD></TR></TABLE></BODY></HTML>';
?>
