#!/usr/bin/perl

use CGI qw(:standard);
&decode_vars;

$title=$fields{'title'};
$affiliatenum=$fields{'affiliatenum'};
$titleurl=$fields{'titleurl'};
$navigation=$fields{'navigation'};
if($navigation == 'nav') {
  $navigation = "$navigation.html";
} else {
  $navigation = "bg01/$navigation.html";
}
$open=$fields{'open'};

# handle custom left nav settings
$custom = '';
if($fields{'a'} ne '') {
  $custom .= "&a=" . $fields{'a'};
}
if($fields{'b'} ne '') {
  $custom .= "&b=" . $fields{'b'};
}
if($fields{'c'} ne '') {
  $custom .= "&c=" . $fields{'c'};
}
if($fields{'h'} ne '') {
  $custom .= "&h=" . $fields{'h'};
}

print "Content-type: text/html\n\n";
print <<"END";
<html>
<head>
  <title>$title</title>
</head>

<frameset cols="112,*" frameborder="0" border="0">
  <frame name="category" src="http://www.mallcom.com/superstore-cgi/hazel.cgi?rn=$affiliatenum&action=serve&item=$navigation&theme=bg01$custom" border="0" noresize="noresize">
  <frameset rows="75,*" cols="620" border="0">
    <frame name="title" src="http://$titleurl" scrolling="no" border="0" marginheight="0" marginwidth="0" noresize="noresize">
    <frame name="products" src="http://www.mallcom.com/superstore-cgi/hazel.cgi?rn=$affiliatenum&action=detail&item=$open" border="0">
  </frameset>
</frameset>
<noframes><body>
<script language="JavaScript">
<!--
alert("Your Browser Does Not Support Frames.\nInstall A More Recent Version.");
</script>
</body></noframes>
</html>
END



##################################################################
sub decode_vars {
  $i=0;
  @pairs=split(/&/,$ENV{'QUERY_STRING'});
  foreach $item(@pairs) {
    ($key,$content)=split(/=/,$item,2);
    $content=~tr/+/ /;
    $content=~s/%(..)/pack("c",hex($1))/ge;
    $content=~s/\t/ /g;
    $fields{$key}=$content;
  }
}