#!/usr/bin/perl

	$mappath = '/var/www/alv/pages/imgmap.alv';
	$filepath = '/var/www/alv/pages/';

use CGI;

my $req = new CGI; 
$pagevar = $req->param("page");

if (length($pagevar) > 12) {
	$pg='contact';
} else {
	$pg = $pagevar;
}


if (index($pg,"\.") > 0) {
	$pg='contact';
}

open CONTENT, "<$filepath$pg.alv";
@lines = <CONTENT>;
close (CONTENT);

foreach $line (@lines) {
	($txtStart, $page, $txtEnd) = split(/:!/,$line);
	if ($req->param("target") ne "") {
		my $tg = $req->param("target");
		$target = " target=\"$tg\"";
	} else {
		$target = "";
	}
	if ($page ne "") {
		my $tp = $req->param("type");
		$page = "HREF=\"buildpage.cgi?page=$page\&type=$tp\"$target";
		$line = $txtStart . $page . $txtEnd;
	}
}
if ($req->param('type') ne "noframes") {
	print "Content-type: text/html\nPragma: no-cache\n\n";
	print << "EOF";

<HTML>
<HEAD>
<TITLE>Andrew Lewis Volunteers</TITLE>
<link REL=STYLESHEET HREF="../styles.css" TYPE="text/css">
</HEAD>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080"
onLoad="self.status='Andrew Lewis Volunteers Fifes & Drums'">
@lines
</body>
</HTML>
EOF
} else {
	open MAP, "<$mappath";
	@maplines = <MAP>;
	close (MAP);

	foreach $mapline (@maplines) {
		($txtStart, $page, $txtEnd) = split(/:!/,$mapline);
		if ($page ne "") {
			$page = "HREF=\"buildpage.cgi?page=$page\&type=noframes\"";
			$mapline = $txtStart . $page . $txtEnd;
		}
	}
	print "Content-type: text/html\nPragma: no-cache\n\n";
	print << "EOF";

<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="keywords"
content="Fife, Drum, fife and drum, Lewisburg, West Virginia, Andrew, Lewis, Volunteers, Andrew Lewis Volunteers, ALV">
<title>Andrew Lewis Volunteers</title>
<link REL=STYLESHEET HREF="../styles.css" TYPE="text/css">
</head>

<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080"
onLoad="self.status='Andrew Lewis Volunteers Fifes & Drums'">

<p align="center"><img src="../images/logo.gif"
alt=" Andrew Lewis Volunteers" width="624" height="101"></p>

<p>&nbsp;</p>

@lines
<hr width="80%">
<p align="center"><font face="Verdana,Arial,Helvetica" size=2>Click below to find out more
about the corps. </font></p>
<br>
@maplines
</body>
</HTML>
EOF
}
exit;
