<?php
    function box_outside_top($title = '', $options = '', $width = '', $style_title = '', $style_options = '', $style_main = '', $id = '')
    {
        $default_title = '';
        $default_options = '';
        $default_main = '';
        if ($width == '')
        {
            if ($options)
            {
                $width = '50%';
            }
            else
            {
                $width = '30%';
            }
        }
        $title = str_replace('<a', '<a class="outside_title_link" onmouseover="this.className=\'outside_title_link_hover\'" onmouseout="this.className=\'outside_title_link\'"', $title);
        $options = str_replace('<a', '<a class="outside_options_link" onmouseover="this.className=\'outside_title_link_hover\'" onmouseout="this.className=\'outside_options_link\'"', $options);
        $return = '<div class="header">';
        $return .= '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>';
        $return .= '<td valign="top"><div' . ($id ? ' id="title_' . $id . '"' : '') . ' class="outside_title" style="' . overwrite_style($default_title, $style_title) . '">' . $title . '</div></td>';
        $return .= '<td width="' . $width . '" valign="top" align="right"><div' . ($id ? ' id="options_' . $id . '"' : '') . ' class="outside_options" style="' . overwrite_style($default_options, $style_options) . '">' . $options . '</div></td>';
        $return .= '</tr></table>';
        $return .= '</div>';
        $return .= '<div' . ($id ? ' id="main_' . $id . '"' : '') . ' class="outside_main" style="' . overwrite_style($default_main, $style_main) . '">';
        return $return;
    }
    
    function box_outside_bottom()
    {
        return '</div>' . "\r\n";
    }

    function box_inside_top($style = '', $id = '')
    {
        $default = '';
        return '<div' . ($id ? ' id="inside_' . $id . '"' : '') . ' class="inside" style="' . overwrite_style($default, $style) . '">' . "\r\n";
    }
    
    function box_inside_bottom()
    {
        return '</div>' . "\r\n";
    }
    
    function box_style($style = '')
    {
        $default = 'background: #' . $GLOBALS['color']['inside_background'] . '; border-color: #' . $GLOBALS['color']['inside_border'] . '; border-style: solid; border-width: 2px; color: #' . $GLOBALS['color']['inside_text'] . '; font-size: 10px; padding: 5px; -moz-border-radius: 0px 15px 15px 15px;';
        return overwrite_style($default, $style) . '" class="inside_main';
    }
    
    function box_image_top($style = '', $mouseover = 1, $id = '')
    {
        $default = '';
        return '<div' . ($id ? ' id="image_' . $id . '"' : '') . ' class="image" style="' . overwrite_style($default, $style) . '"' . ($mouseover ? ' onMouseOver="this.className=\'image_hover\';" onMouseOut="this.className=\'image\'"' : '') . '>' . "\r\n";
    }
    
    function box_image_bottom()
    {
        return '</div>' . "\r\n";
    }
    
    function make_pages($title, $width = '', $style = '')
    {
        $default = '';
        $title = str_replace('<a', '<a class="outside_title_link" onmouseover="this.className=\'outside_title_link_hover\'" onmouseout="this.className=\'outside_title_link\'"', $title);
        if ($width == '')
        {
            $width = '100%';
        }
        return '<table width="' . $width . '" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><div class="header" style="' . overwrite_style($default, $style) . '">' . $title . '</div></td></tr></table>' . "\r\n";
    }
    
    function overwrite_style($default, $overwrite)
    {
        if ($overwrite)
        {
            $explode = explode(';', $overwrite);
            foreach ($explode AS $value)
            {
                if ($value = trim($value))
                {
                    if (strpos($value, ':') !== false)
                    {
                        $pos1 = strpos($default, substr($value, 0, strpos($value, ':')));
                        $pos2 = strpos($default, ';', $pos1);
                        if ($pos1 !== false && $pos2 !== false)
                        {
                            $default = substr($default, 0, $pos1) . $value . substr($default, $pos2);
                        }
                        else
                        {
                            $default .= ' ' . $value . ';';
                        }
                    }
                }
            }
        }
        return $default;
    }
    
    function make_link($title = '', $href = '', $id = '', $onclick = '')
    {
        return '<a href="' . $href . '" class="' . $id . '"' . ($onclick ? ' onClick="' . $onclick . '"' : '') . ' onMouseOver="this.className=\'' . $id . '_hover\';" onMouseOut="this.className=\'' . $id . '\';">' . $title . '</a>';
    }
    
    function make_button($title = '', $href = '', $id = '', $div = '')
    {
        return '<div class="' . $id . '" style="border-width: 2px; border-style: solid; cursor: pointer; font-size: 14px; font-weight: bold; padding: 7px 15px 7px 15px; text-align: center; -moz-border-radius: 17px 17px 17px 17px;" onClick="document.location=\'' . $href . '\';" onMouseOver="this.className=\'' . $id . '_hover\';' . ($div ? ' if (undefined !== window.startme) { show_div(\'' . $div . '\') };' : '') . '" onMouseOut="this.className=\'' . $id . '\';">' . $title . '</div>';
    }
?>