<? 

include("color.php");
include("include.php");

if (isset($_COOKIE[color_cookie])) {
    $colorArray = urldecode($_COOKIE[color_cookie]);
    list($bgcolor,$tr1color,$tr2color,$formcolor,$mypostcolor,$fontface,$fontsize) = split(",",$colorArray);
} else {
    $bgcolor        = BGCOLOR;
    $tr1color       = TR1COLOR;
    $tr2color       = TR2COLOR;
    $mypostcolor    = MYPOSTCOLOR;
    $formcolor      = FORMCOLOR;
    $fontface       = FONTFACE;
    $fontsize       = FONTSIZE;
}

    $body_fontsize = $fontsize . "px";
    if ($fontsize <= 10) {
        $lastpost_fontsize = $fontsize . "px";
    } else {
        $lastpost_fontsize = $fontsize - 2 . "px";
    }
    $text_main = contrast($bgcolor);
    $link_main = $text_main;
    $vlink_main = $text_main;
    $hlink_main = $text_main;

    $form_textColor = contrast($formcolor);

    $myposttextcolor = contrast($mypostcolor);

    $text_tr1 = contrast($tr1color);
    $link_tr1 = $text_tr1;
    $vlink_tr1 = adjust_value($link_tr1, get_mid_value($tr1color, $link_tr1));

    //$bg_tr2 = adjust_value($bg_tr1, $delta/4);
    $text_tr2 = contrast($tr2color);
    $link_tr2 = $text_tr2;
    $vlink_tr2 = adjust_value($link_tr2, get_mid_value($tr2color, $link_tr2));

    //$bg_private= adjust_saturation(adjust_hue(max($bg_tr2, $bg_tr1), 3), $delta/6);
    $my_text = contrast($mypostcolor);
    $my_link = $my_text;
    $my_vlink = adjust_hue(
                                adjust_value(
                                $link_private,
                                get_mid_value($mypostcolor, $my_link)),
                                get_mid_hue($mypostcolor, $my_link) + 1
                                );

/* Force the browser to accept this as a css file */
header("Content-type: text/css");
echo <<< END
body { background-color: #$bgcolor; background-image: none; color: #$text_main; font-family: $fontface, arial, helvetica, sans-serif; font-size: $body_fontsize; }
form { margin: 0px; }
.header { background-color: #000000; background-image: none; color: #FFFFFF; font-weight: bold; }
a:link { text-decoration: none; background-color: #$bgcolor; background-image; none; color: #$link_main; }
a:visited { text-decoration: none; background-color: #$bgcolor; background-image: none; color: #$vlink_main; }
a:hover { text-decoration: underline; background-color: #$bgcolor; background-image; none; color: #$hlink_main; }
.mypostthread { border-top: 1px solid #000000; border-bottom: 1px solid #000000; background-color: #$mypostcolor; background-image: none; color: #$myposttextcolor; }
a.tr1link { text-decoration: underline; background-color: #$tr1color; background-image: none; color: #$link_tr1; }
a.tr1link:visited { text-decoration: underline; background-color: #$tr1color; background-image: none; color: #$vlink_tr1; }
a.tr1link:hover { text-decoration: none; background-color: #$tr1color; background-image: none; color: #$link_tr1; }
.tr2thread { border-top: 1px solid #000000; border-bottom: 1px solid #000000; background-color: #$tr2color; background-image: none; color: #$text_tr2; }
.mypost { background-color: #$mypostcolor; background-image: none; color: #$myposttextcolor; }
a.mypost { background-color: #$mypostcolor; background-image: none; color: #$my_link; }
a.mypost:visited { background-color: #$mypostcolor; background-image: none; color: #$my_vlink; }
a.mypost:hover { background-color: #$mypostcolor; background-image: none; color: #$my_link; }
.button { font-family: $fontface, arial, helvetica, sans-serif; color: #$form_textColor; border: 1px solid #000000; background-color: #$formcolor; background-image: none; font-size: $body_fontsize;}
.textfield { font-family: $fontface, arial, helvetica, sans-serif; color: #$form_textColor; border: 1px solid #000000; background-color: #$formcolor; background-image: none; font-size: $body_fontsize;}
.tr1 { background-color: #$tr1color; background-image: none; color: #$text_tr1; }
a.tr1 { background-color: #$tr1color; background-image: none; color: #$link_tr1; }
a.tr1:visited { background-color: #$tr1color; background-image: none; color: #$vlink_tr1; }
a.tr1:hover { background-color: #$tr1color; background-image: none; color: #$link_tr1; }
.tr2 { background-color: #$tr2color; background-image: none; color: #$text_tr2; }
a.tr2 { background-color: #$tr2color; background-image: none; color: #$link_tr2; }
a.tr2:visited { background-color: #$tr2color; background-image: none; color: #$vlink_tr2; }
a.tr2:hover { background-color: #$tr2color; background-image: none; color: #$link_tr2; }
.bigtable { border: 1px solid #000000; }
.menu { font-weight: bold; }
a.menu:link { font-weight: bold; background-color: #$bgcolor; background-image: none; color: #$link_main; text-decoration: none; }
.menu:visited { font-weight: bold; background-color: #$bgcolor; background-image: none; color: #$vlink_main; text-decoration: none; }
a.menu:hover { font-weight: bold; background-color: #$bgcolor; background-image: none; color: #$link_main; text-decoration: none; }
.replytbl {border: none; }
.footer { background-color: #000000; background-image: none; color: #FFFFFF; font-weight: bold; }
a.footer { background-color: #000000; background-image: none; color: #FFFFFF; font-weight: bold; }
a.footer:visited { background-color: #000000; background-image: none; color: #FFFFFF; font-weight: bold; }
a.footer:hover { background-color: #000000; background-image: none; color: #FFFFFF; font-weight: bold; }
.lastpostby { font-size: $lastpost_fontsize; }
.newmessage { background-color: #$bgcolor; background-image: none; color: #$text_main; font-family: $fontface, arial, helvetica, sans-serif; }
.mono { font-family: monospace; font-size: $body_fontsize; }
END;

?>
