# Authority: anyone
my $html;

my $param;
my %param;

my $theme;
my @themes;
my $print_preview;


$theme = ($config_parms{html_theme}?$config_parms{html_theme}:'default');
$theme = $Cookies{'theme'} if ($Cookies{'theme'});
$print_preview = $Cookies{'printpreview'} if ($Cookies{'printpreview'});

@ARGV = split('&&', $ENV{HTTP_QUERY_STRING}) if ($#ARGV <= 0);

#***Should get print_preview and theme from parameter (then cookies)

$html = qq|
<script language="JavaScript" type="text/javascript">
<!--
function hideKeyboard() {
	showElementEx(getElement('keyboard'), 'slidedown', 200, false)
}
function showKeyboard(f,t) {
	setTarget(document.forms[f],document.forms[f].elements[t]);
	showElementEx(getElement('keyboard'), 'slidedown', 500, true)
}
//-->
</script>
|;

if ($Socket_Ports{http}{client_ip_address} eq '127.0.0.1' or $Socket_Ports{http}{client_ip_address} eq 'localhost') {
	$html .= qq|<base href="http://$Socket_Ports{http}{client_ip_address}:8080/mhx/">|
}
elsif (&is_local_address()) {
	if (!$config_parms{http_server} or $config_parms{http_server} eq 'localhost') {
		my $local_host = &get_ip_address();
		$html .= qq|<base href="http://$local_host:$config_parms{http_port}/mhx/">|		
	}
	else {
		$html .= qq|<base href="http://$config_parms{http_server}:$config_parms{http_port}/mhx/">|		
	}
}
else {
	if ($config_parms{http_server_path_external}) {
		$html .= qq|<base href="http://$config_parms{http_server_external}:$config_parms{http_port_external}/mhx/">| if $config_parms{http_server_external} and $config_parms{http_server_port_external};
	}
	else {
		$html .= qq|<base href="http://$config_parms{http_server_external}:$config_parms{http_port_external}/$config_parms{http_server_path_external}/mhx/">| if $config_parms{http_server_external} and $config_parms{http_server_port_external};
	}
}

$html .= '<link rel="stylesheet" href="' . $theme . '.css" type="text/css" media="all" title="Site theme">';
$html .= '<link rel="alternatestylesheet" href="curious.css" type="text/css" media="all" title="Curious site theme"><link rel="alternatestylesheet" href="curiouser.css" type="text/css" media="all" title="Curiouser site theme"><link rel="stylesheet" href="print.css" type="text/css" media="' . (($print_preview)?'all':'print') . '" title="Print style">';
$html .= "<style type=\"text/css\">body,html {background-image:URL('images/night.gif');background-position:top left;background-repeat:no-repeat}</style>" unless (time_greater_than $Time_Sunrise_Twilight and time_less_than ($Time_Sunset_Twilight));
$html .= qq[<style type="text/css" media="screen">div.printPreviewOff {text-align:center;font-size:larger}</style>];
$html .= qq[<style type="text/css" media="print">div.printPreviewOff {display:none}</style>];
$html .= qq[<!--[if gte IE 4]><style type="text/css" media="screen">html {scrollbar-arrow-color:#3791BF; scrollbar-track-color:#E3EEF9; scrollbar-3dlight-color:#D1D7DC; scrollbar-darkshadow-color:#98AAB1; scrollbar-base-color:#000000; scrollbar-highlight-color:#8AB5DA; scrollbar-face-color:#C5E6F5; scrollbar-shadow-color:#8AB5DA }
table.alarms th img.headerIcon {filter:gray()}
img.jukeboxControl {filter:alpha(opacity=50)}
a img.jukeboxControl {filter:none}
div.itemmenu {filter:alpha(opacity=100)}
table.report th img {filter:gray()}
img.toggleStateHidden {filter:alpha(opacity=25)}
img.toggleState {filter:alpha(opacity=50)}
img.command {filter:alpha(opacity=50)}
a img.toggleState {filter:none}
img.toolbarButton {filter:alpha(opacity=50)}
a img.toolbarButton {filter:none}
img.menuIconLarge {height:70px;width:70px}
img.tocicon {filter:none}
a img.tocicon {filter:gray()}
a:hover img.tocicon {filter:none}
img.dvdCover {filter:alpha(opacity=100)}
</style><![endif]-->];
$html .= qq[<meta http-equiv="Content-Type" content="text/html; charset=utf-8">];
return $html;


