#!/usr/bin/perl
require "/home/roger/lib/weblib.lib";
require "/home/todd/private/toddweb.env";
$PAGEHOMEDIR.="/private";
use Time::Local;
use POSIX strftime;
use DB_File;
$rss=$ENV{PATH_INFO} =~ /rss$/;
&getparams;
$domain="TRConnection.com";
$TR="Todd Rundgren";
$TODD="Todd";
#$april1=0;
$iPhone=$ENV{HTTP_USER_AGENT}=~/iPhone/;
if($april1){
	$TR="Ted Runger";
	$TODD="Ted";
	$UTOPIA="Tedtopia";
}
$paypal=<<EOF;
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float: right;">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="roger\@rocemabra.com">
<input type="hidden" name="item_name" value="The Todd Rundgren Connection">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="/img/icons/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
EOF
$calendar=<<EOF;
<iframe src="http://www.google.com/calendar/embed?src=1mkcgj208bsg30rraaa71nv9ik%40group.calendar.google.com&amp;mode=AGENDA&amp;height=400&amp;bgcolor=%23FFFF66&amp;epr=2"
 class="useshadow" style="margin-top: 10px; width: 520px; height: 400px; border: 1px solid black;"></iframe>
EOF
$banner=qq{<script language="javascript" src="http://trconnection.com/banners.php?b=r"></script><br />};
if($iPhone){
	$calendar=qq{<div style="text-align: center;">$calendar</div>};
	$banner=qq{<div style="text-align: center;">$banner</div>};
	}
$style=<<EOF;
body,th,td {background-color: #FFFF99; color: black; font: 8pt/10pt verdana,helvetica;}
h3 {font: 16pt/16pt verdana,helvetica;}
form	{display: inline;}
caption {font: 16pt/20pt verdana,helvetica;}
table, th, td {border-color: cyan}
a:link {color: #666633}
a:active {color: red}
a:visited {color: #999999}
.useshadow {-webkit-box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.5); -moz-box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.5); margin: 0px 10px 10px 0px;
 	filter: progid:DXImageTransform.Microsoft.DropShadow(offX=10, offY=10, color='Gray', Positive='true');}
h1.tourinfo {font-size: 12pt; line-height: 14pt; font-weight: bold;}
.past	{color: gray; white-space: nowrap;}
.future	{white-space: nowrap;}
EOF
if($ENV{PATH_INFO} eq ""){&displayMainPage;}
else{
	&displayTourPage;
	if($rss){print "</channel>\n</rss>\n";exit;}
}
print $PAGETAIL;
&htmlclose;
sub displayMainPage{
	local($title)="$TR On Tour+";
	&htmlopen($title,"style=$style","viewport=530");
$print=<<EOF;
$paypal
$banner
$calendar
<br>Reviews and photos are welcomed and may be sent to
<a href="mailto:TReviews&#64;TRConnection.com">TReviews&#64;TRConnection.com</a>.
<h2>Current and Upcoming Tours</h2>
<ul>
<li>$TODD <a href="/tour/t2026">Tours for 2026</a></li>
</ul>
<h2>2025 Tours</h2>
<ul>
<li>$TODD <a href="/tour/t2025">Tours for 2025</a></li>
</ul>
<h2>Previous Tours</h2>
Reviews and pictures.
<ul>
<li><a href="http://trconnection.com/robfarrish.html">1966-2000</a> (Maintained by Rob Farrish)</li>
<li><a href="/todd/tour/t1975">1975 Shows</a></li>
<li><a href="/todd/tour/t1976">1976 Shows</a></li>
<li><a href="/todd/tour/t1977">1977 Shows</a></li>
<li><a href="/todd/tour/t1989">1989 Shows</a></li>
<li><a href="/todd/tour/wat">With A Twist - Leg One</a> - Oct/Nov 1997</li>
<li><a href="/todd/tour/wat2">With A Twist - Leg Two</a> - Feb/Mar 1998</li>
<li><a href="/gallery/set=saus1998">Sausalito Art Festival</a>, September 5, 1998 (pictures)</li>
<li><a href="/todd/tour/cstr">Channel Surfing with $TR</a> - November 1998</li>
<li><a href="/todd/tour/ringo">Ringo's "All-Starr" Band</a> - Feb/Mar 1999
<li><a href="/todd/tour/ht">Half Twisted - $TR & Band</a> - June 1999</li>
<li>$TODD & band toured as a <a href="/todd/tour/t2000">Power Trio</a> for US summer 2000</li>
<li><a href="/todd/tour/abbey">"A Walk Down Abbey Road: A Tribute To The Beatles"</a> Tour 2001.</li>
<li><a href="/todd/tour/t2001">Miscellaneous Solo Dates - 2001</a></li>
<li><a href="/todd/tour/t2002">Miscellaneous Dates - 2002</a> (includes Abbey Road and Hall and Oates)</li>
<li><a href="/todd/tour/t2003">Miscellaneous Dates - 2003</a></li>
<li><a href="/todd/tour/t2004">"$TR and the Liars" - 2004</a></li>
<li><a href="/todd/tour/t2005ho">Hall and Oates w/ $TR - 2005</a></li>
<li><a href="/todd/tour/t2005eur">$TR, Joe Jackson and Ethel - European Leg 2005</a></li>
<li><a href="/todd/tour/t2005">$TR, Joe Jackson and Ethel - US Leg 2005</a></li>
<li><a href="/tour/t2006">$TR with Tony Levin, Jesse Gress, Jerry Marotta - 2006</a></li>
<li><a href="/tour/t2006tnc">The New Cars Road Rage tour - 2006</a> (Photos and reviews)</li>
<li><a href="/tour/t2007tnc">The New Cars - 2007</a></li>
<li>$TODD <a href="/tour/t2007">Solo Tours for 2007</a></li>
<li>$TODD <a href="/tour/t2008">Solo Tours for 2008</a></li>
<li>$TODD <a href="/tour/t2009">Solo Tours for 2009</a></li>
<li>$TODD <a href="/tour/t2010">Solo Tours for 2010</a></li>
<li>$TODD <a href="/tour/t2011">Solo Tours for 2011</a></li>
<li><a href="/tour/t2011#UtopiaII">TR's Utopia Tours for November 2011</a></li>
<li>$TODD <a href="/tour/t2012">Tours for 2012</a> (Includes solo and Ringo's All-Starrs)</li>
<li>$TODD <a href="/tour/t2013">Tours for 2013</a> (Includes solo and Ringo's All-Starrs)</li>
<li>$TODD <a href="/tour/t2014">Tours for 2014</a></li>
<li>$TODD <a href="/tour/t2015">Tours for 2015</a></li>
<li>$TODD <a href="/tour/t2016">Tours for 2016</a></li>
<li>$TODD <a href="/tour/t2017">Tours for 2017</a></li>
<li>$TODD <a href="/tour/t2018">Tours for 2018</a></li>
<li>$TODD <a href="/tour/t2019">Tours for 2019</a></li>
<li>$TODD <a href="/tour/t2020">Tours for 2020</a></li>
<li>$TODD <a href="/tour/t2021">Tours for 2021</a></li>
<li>$TODD <a href="/tour/t2022">Tours for 2022</a></li>
<li>$TODD <a href="/tour/t2023">Tours for 2023</a></li>
<li>$TODD <a href="/tour/t2024">Tours for 2024</a></li>
</ul>
EOF
	if($april1){
		$print=~s/Todd/Ted/g;
		$print=~s/Rundgren/Runger/g;
		$print=~s/Utopia/Tedtopia/g;
	}
print $print;
}
sub displayTourPage{
	local($tourid,$venue,$tourlist,$tourimage,$tourtitle,$tourmap,$header);
	($tourid,$venue)=split(m#/#,substr($ENV{PATH_INFO},1));
	$rssurl="http://TRConnection.com/tour/$tourid/rss";
	$xmllink=qq{<a href="$rssurl"><img src="/icons/xml.gif" width="36" height="14" border="0" /></a>};
	$sublink=<<EOF;
<a href="http://purl.org/net/syndication/subscribe/?rss=$rssurl">
  <img src="/icons/syn-sub.png" width="32" height="12" alt="[Subscribe]" border="0" />
</a>
EOF
	$tourlist="$PAGEHOMEDIR/tours/$tourid.info";
	dbmopen(%TOUR,"$PAGEHOMEDIR/tours/$tourid",0644) if -f "$PAGEHOMEDIR/tours/$tourid.db";
	dbmopen(%CLUB,"$PAGEHOMEDIR/tours/clubs",0644) if -f "$PAGEHOMEDIR/tours/clubs.db";
	$tourimage=$TOUR{"tour.image"};
	$tourimage=qq{<img src="$tourimage" style="max-width: 300px; margin: 10px; padding: 10px; float: left;"><br>} if $tourimage;
	$tourinfo=$TOUR{"tour.info"};
	$tourmap=$TOUR{"tour.map"};
	if($april1){
		$tourinfo=~s/Todd/Ted/g;
		$tourinfo=~s/Rundgren/Runger/g;
		$tourinfo=~s/Utopia/Tedtopia/g;
	}
	&getServices;
	open(TOUR,$tourlist);
	chop($tourtitle=<TOUR>);
	if($TOUR{"tour.title"}){$tourtitle=$TOUR{"tour.title"};}
	if($april1){
		$tourtitle=~s/Todd/Ted/g;
		$tourtitle=~s/Rundgren/Runger/g;
		$tourtitle=~s/Utopia/Tedtopia/g;
	}
	if($venue){&displayVenueInfo;}
	if($rss){&xmlopen;}
	else{
		local($title)="$TR Tour Info|";
		&htmlopen($title,"rss=$rssurl","style=$style");
	}
	&getstates;
	chop($header=<TOUR>);
	if($april1){
		$header=~s/Todd/Ted/g;
		$header=~s/Rundgren/Runger/g;
		$header=~s/Utopia/Tedtopia/g;
	}
	unless($rss){
		if($tourmap){
			$tourmap=~s/&/&amp;/g;
			$mapwidth=640;
			$mapheight=400;
			if($ENV{HTTP_USER_AGENT}=~/iPhone/){
				$tourmap=~s/5,65/5,130/;
				$mapwidth=320;
				$mapheight=200;
			}
			$mapurl="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;$tourmap";
			$tourmap= <<EOF;
<br><iframe class="useshadow" style="width: ${mapwidth}px; height: ${mapheight}px; border: 0px; margin-top: 10px; margin-bottom: 10px;" src="$mapurl&amp;output=embed"></iframe><br>
<small>View <a href="$mapurl&amp;source=embed" style="color:#0000FF;text-align:left">$tourtitle</a> in a larger map</small>
EOF
		}
		print "<table>\n";
		print qq{<tr><td valign="top">};
		print qq{<table border="1"><caption>$paypal$tourtitle$tourmap</caption>\n};
		if(-f "/home/todd/www/reviews/$tourid/general"){
			print qq{<tr><td colspan="5" style="font-size: 12pt;">},
			qq{<a href="http://TRConnection.com/todd/review/$tourid/general">General commentary on the reviews</a>\n},
			"</td></tr>\n";
		}
		print "<tr>";
		@headers=split(/\t/,$header);
		foreach $header(@headers){print "<th>$header</th>\n";}
		if($param{compact}){print qq{<th>Reviews/Photos<br /><a href="$weblib::URL/$tourid">Full format</a></th></tr>\n};}
		else{print qq{<th>Reviews/Photos<br /><a href="$weblib::URL/$tourid/compact">Compact format</a></th></tr>\n};}
	}
	&displayTourItinerary;
	unless($rss){
		print "</table>\n";
		print qq{</td><td valign="top">};
		print "$xmllink$sublink<br />\n";
		if(@recent){
			print "<b>Jump to Recent dates: </b>";
			@recent=sort {$date{$a} <=> $date{$b}} @recent;
			foreach $recent(@recent){$recent=qq{<a href="#$date{$recent}">$recent</a>};}
			print join(", ",@recent),"<br>\n";
		}
		if(@upcoming){
			print "<b>Jump to Upcoming dates: </b>";
			@upcoming=sort {$date{$a} <=> $date{$b}} @upcoming;
			foreach $upcoming(@upcoming){$upcoming=qq{<a href="#$date{$upcoming}">$upcoming</a>};}
			print join(", ",@upcoming),"<br>\n";
		}
		&displayTourInfo;
		$print=<<EOF;
$calendar
</td></tr></table>
<div>
Visit <a href="$weblib::URL">$TR on Tour</a> for reviews and pictures from other tours
</div>
EOF
	if($april1){
		$print=~s/Todd/Ted/g;
		$print=~s/Rundgren/Runger/g;
		$print=~s/Utopia/Tedtopia/g;
	}
	print $print;
	}
}
sub getServices{
	@servicenames=(
	"TicketMaster:http://www.ticketmaster.com/artist/736021/",
	"TicketWeb:http://www.ticketweb.com",
	"Pollstar:https://www.pollstar.com/artists/todd-rundgren-4936",
	"tickets.com:https://www.tickets.com/search?searchTerm=Todd%20Rundgren");
	$index=0;
	foreach $service(@servicenames){
		($servicename,$serviceurl)=split(/:/,$service,2);
		$servicename[$index]=$servicename;
		$service[$index]=$TOUR{$servicename};
		$service[$index]=$serviceurl unless $service[$index];
		$serviceimage[$index]=$TOUR{"$servicename.image"};
		$serviceimage[$index]=qq{<img src="$serviceimage[$index]" />}
			if $serviceimage[$index];
		$index++;
	}
}
sub displayTourInfo{
	local($info);
	local($commentary)=-f "/home/todd/www/reviews/$tourid/general"?
		qq{<a href="http://TRConnection.com/todd/review/$tourid/general">General commentary on the reviews</a>\n}:
		"General commentary on the reviews\n";
	$info= <<EOF;
$tourimage$tourinfo<br clear="all" />
<hr />
Reviews and photos are welcomed and may be sent to
<a href="mailto:TReviews&#64;TRConnection.com">TReviews&#64;TRConnection.com</a>.
For photos, please follow these guidelines before sending (it really helps):<br>
<ol>
<li>To increase the probability of getting through the spam filter, address submissions to TReviews&#64;TRConnection.com, with that exact capitialization.
<li>If possible, reduce photos to 72dpi, 800x600 (or 600x800 if vertical) before sending.
<li>Send photos in batches that are less than 10MB. If a message with attachments exceeds 10MB, send multiple messages.
<li>Do not embed spaces in file names. Keep to letters, numbers and dashes/underscores. Add .jpg as appropriate
<li>Rotate vertically oriented photos to proper view
<li>Please convert other formats to .jpg (.gif is OK, but .jpg preferred)
<li>Include your name for the credits
<li>Include the date the photo was taken
<li>Multiple photos may be zipped or stuffed. Should be if sending more than five at a time.
<li>All contributions are acknowledged automatically when received. If your photos aren't yet posted and you haven't received an acknowledgment, check via e-mail before you resend the photos. It may take a couple of days before they get posted.
</ol>
None of these are binding, but your cooperation is much appreciated.<p>
<p>$commentary (including dissenting opinions) may be sent to the same address. Please refrain from commentary on the commentary.
The forums are an ideal place for discussion and debate</p>
<p>Discussion of reviews may also be made in the TR Connection Forums under the
<a href="http://forum.TRConnection.com/forumdisplay.php?fid=11">Tours Forum</a>
<p>Reviews are presented unedited (except for formatting) and uncensored and reflect the personal opinion
of the reviewer.</p>
<hr />
<p>The following links do not necessary imply an endorsement of these services.
They are provided for the reader's convenience.</p>
EOF
	for($i=0;$i<=$#service;$i++){
		$info.= " - <a href=\"$service[$i]\">$serviceimage[$i]$servicename[$i]</a> - \n";
	}
	$info.="<br />\n";
	if($rss){print &xmlize($info);}
	else{print $info;}
}
sub displayVenueInfo{
	$venue=~s/_/ /g;
	$venueinfo=$CLUB{"$venue.html"};
	$venueinfo.=qq{<p>$TOUR{"$venue.html"}</p>} if $TOUR{"$venue.html"};
	$tickets=$TOUR{"$venue.ticket"};
	if($tickets){
		$ticketinfo="<h2>Ticket Information</h2>";
		@tickets=split(/;/,$tickets);
		foreach $ticket(@tickets){
			$ticket=~/\[([^]]*)\](.*)/;
			if($2){$ticketinfo.=qq{<a href="$2">$1</a><br />\n};}
			else{$ticketinfo.="$1<br />\n";}
		}
	}
	if($venueinfo){
		$map=$TOUR{"$venue.map"};
		$map=$CLUB{"$venue.map"} unless $map;
		$map="<a href=$map>Map to $venue</a><br>\n" if $map;
		$hotel=$TOUR{"$venue.hotel"};
		$hotel=$CLUB{"$venue.hotel"} unless $hotel;
		$hotel="<a href=$hotel>Nearby hotels</a><br>\n" if $hotel;
		$restaurant=$TOUR{"$venue.restaurant"};
		$restaurant=$CLUB{"$venue.restaurant"} unless $restaurant;
		$restaurant=qq{<a href="$restaurant">Nearby restaurants</a><br />\n} if $restaurant;
		$fastfood=$TOUR{"$venue.fastfood"};
		$fastfood=$CLUB{"$venue.fastfood"} unless $fastfood;
		$fastfood=qq{<a href=$fastfood>Nearby fast food</a><br>\n} if $fastfood;
		$supplement="$map$hotel$restaurant$fastfood";
		$supplement=qq{<hr />$supplement} if $supplement;
		&htmlopen("$venue Information+","style=$style");
		if(($moreinfo=$TOUR{$venue})||($moreinfo=$CLUB{$venue})){
			print qq{<a href="$moreinfo">Web Site</a><br />\n};
		}
		print <<EOF;
$venueinfo
$ticketinfo
$supplement<hr />Return to $tourtitle <a href="$weblib::URL/$tourid">info page</a>
$PAGETAIL
EOF
		&htmlclose;
		exit;
	}
}
sub displayTourItinerary{
	local($url,@info,@location,$city,$state,$date,$class,@date,$time);
	#local(@upcomimg,@recent);
	local($URL="http://TRConnection.com/tour/");
	if($rss){
		print <<EOF;
<item><title>General Information</title>
<link>$URL$tourid</link>
<description>
EOF
		&displayTourInfo;
		print "</description></item>\n";
	}
	while(<TOUR>){
		chop;
		if($april1){
			s/Todd/Ted/g;
			s/Rundgren/Runger/g;
			s/Utopia/Tedtopia/g;
		}
		next if /^##/;
		if(s/^#(.*)// && !$rss){
			$jumptag=$sectiontitle=$1;
			if($sectiontitle=~/(.*)%%(.*)/){$jumptag=$1;$sectiontitle=$2;}
			print qq{<tr><th colspan="5" style="font-size: larger; padding: 5px;" id="$jumptag">$sectiontitle</th></tr>\n};next;
		}
		next if /^$/ && $rss;
		@info=split(/\t/);
		if($headers[3] eq "Note" && $info[3] eq ""){$info[3]="<br>";}
		@location=split(/;/,$info[1]);
		($location[0],$url)=split(/:/,$location[0],2);
		($city,$state)=split(/, /,$location[0]);
		$city=~s/ /_/g;
		$state=$states{$state};
		$state=~s/ /_/g;
		$date=$info[0];
		
		@date=split(/\s/,$date);
		@date=split(m#/#,$date[1]);
		$time=timelocal(0,0,0,$date[1]+0,$date[0]-1,$date[2]);
		$class=$time+86400<time?"past":"future";
		push(@recent,$date) if $time>time-86400*14 && $class ne "future";
		push(@upcoming,$date) if $class eq "future";
		$date{$date}=$time;
		$info[0]=qq{<span class="$class" id="$time">$info[0]</span>} unless $rss;
		$info[0].=" -- $location[0] -- $info[2]" if $rss;
#		$url="http://dir.yahoo.com/category/U.S._States/$state/Cities/$city/" if $state && !$url;
		$location[0]="<a href=\"$url\">$location[0]</a>" if $url && $location[0] ne "TBA";
		$location[0]=qq{<span style="white-space: nowrap;">$location[0]</span>} unless $rss;
		$info[1]=join("<br />",@location);
		foreach $info(@info){
			$venueinfo=$TOUR{"$info.html"};
			$venueinfo=$CLUB{"$info.html"} unless $venueinfo;
			if(0&&$venueinfo){
				($infotag=$info)=~s/ /_/g;
				$info="<a href=\"$URL$tourid/$infotag\">$info</a>";
			}
			elsif($TOUR{$info}){$info="<a href=\"$TOUR{$info}\">$info</a>";}
		}
		$info="";
		if(($url=$TOUR{"$date.setlist"}) && !$param{noreviews}){
			($desc,$url)=split(/:/,$url,2);
			$url="http://TRConnection.com$url" if $url =~ m#^/#;
			$info.="<a href=\"$url\">Set List</a><br />\n";
		}
		if($TOUR{"$date.photo"} && !$param{noreviews}){
			if($param{compact}){
				$info.=qq{<form action="http://TRConnection.com/cgi-bin/switch"" method="POST">\n};
				$info.=qq{<select name="switch" onChange="submit();return true;"><option value="">Photos</option>\n};
			}
			else{$info.="<center><b>Photos</b></center><br />\n";}
			foreach $url(split(/;/,$TOUR{"$date.photo"})){
				($desc,$url)=split(/:/,$url,2);
				$url="http://TRConnection.com$url" if $url =~ m#^/#;
				$url="http://TRConnection.com/gallery/set=$url" if $url !~ m#/#;
				if($param{compact}){$info.=qq{<option value="$url">$desc</option>\n};}
				else{$info.="<a href=\"$url\">$desc</a><br />\n";}
			}
			$info.="</select></form><br>\n" if $param{compact};
		}
		if($TOUR{"$date.review"} && !$param{noreviews}){
			if($param{compact}){
				$info.=qq{<form action="http://TRConnection.com/cgi-bin/switch"" method="POST">\n};
				$info.=qq{<select name="switch" onChange="submit();return true;"><option value="">Reviews</option>\n};
			}
			else{$info.="<center><b>Reviews</b></center><br>\n";}
			foreach $url(split(/;/,$TOUR{"$date.review"})){
				($desc,$url)=split(/:/,$url,2);
				$url="http://TRConnection.com$url" if $url =~ m#^/#;
				$desc=~s/ /&nbsp;/g;
				if($param{compact}){$info.=qq{<option value="$url">$desc</option>\n};}
				else{$info.="<a href=\"$url\">$desc</a><br />\n";}
			}
			$info.="</select></form><br>\n" if $param{compact};
		}
		if($TOUR{"$date.commentary"} && !$param{noreviews}){
			if($param{compact}){
			$info.=qq{<form action="http://TRConnection.com/cgi-bin/switch"" method="POST">\n};
			$info.=qq{<select name="switch" onChange="submit();return true;"><option value="">Commentary on Reviews</option>\n};
			}
			else{$info.="<center><b>Commentary on Reviews</b></center><br>\n";}
			foreach $url(split(/;/,$TOUR{"$date.commentary"})){
				($desc,$url)=split(/:/,$url,2);
				$url="http://TRConnection.com$url" if $url =~ m#^/#;
				$desc=~s/ /&nbsp;/g;
				if($param{compact}){$info.=qq{<option value="$url">$desc</option>\n};}
				else{$info.="<a href=\"$url\">$desc</a><br />\n";}
			}
			$info.="</select></form><br>\n" if $param{compact};
		}
		if($TOUR{"$date.bitching"} && !$param{noreviews}){
			$info.="<center><b>Bitching in General</b></center><br>\n";
			foreach $url(split(/;/,$TOUR{"$date.bitching"})){
				($desc,$url)=split(/:/,$url,2);
				$url="http://TRConnection.com$url" if $url =~ m#^/#;
				$desc=~s/ /&nbsp;/g;
				$info.="<a href=\"$url\">$desc</a><br />\n";
			}
		}
		$info="<br>" unless $info;
		push(@info,$info);
		if($rss){
			$info=shift(@info);
			print "<item>\n<title>$info</title>\n";
			print "<link>$URL$tourid</link>\n";
			print "<description>\n";
			print &xmlize(join("<br>",@info));
			print "</description>\n</item>\n";
		}
		else{
			print "<tr>\n";
			for($index=0;$index<=$#headers+1;$index++){
				$info=$info[$index];
				$info="<br>" unless $info;
				print qq{<td valign="top">$info</td>\n};
			}
			print "</tr>\n";
		}
	}
}
sub getstates{
%states=(AK,Alaska,AL,Alabama,AR,Arkansas,AZ,Arizona,CA,California,CO,Colorado,
	CT,Connecticut,DC,"District of Columbia",DE,Delaware,FL,Florida,GA,Georgia,
	HI,Hawaii,IA,Iowa,ID,Idaho,IL,Illinois,IN,Indiana,KS,Kansas,KY,Kentucky,
	LA,Louisiana,MA,Massachusetts,MD,Maryland,ME,Maine,MI,Michigan,MN,Minnesota,
	MO,Missouri,MS,Mississippi,MT,Montana,NC,"North Carolina",ND,"North Dakota",
	"NE",Nebraska,NH,"New Hampshire",NJ,"New Jersey",NM,"New Mexico",NV,Nevada,
	NY,"New York",OH,Ohio,OK,Oklahoma,OR,Oregon,PA,Pennsylvania,RI,"Rhode Island",
	SC,"South Carolina",SD,"South Dakota",TN,Tennessee,TX,Texas,UT,Utah,
	VA,Virginia,VT,Vermont,WA,Washington,WI,Wisconsin,WV,"West Virginia",
	WY,Wyoming);
}
sub xmlopen{
	local($date)=strftime("%a, %d %b %Y %H:%M:%S %z",localtime(time));
	local($title)="$TR On Tour";
	$print=<<EOF;
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>$title - $tourid</title>
<link>http://TRConnection.com/tour/$tourid</link>
<description>The latest $TR Tour information.</description>
<managingEditor>webmaster\@$domain (TR Connection)</managingEditor>
<webMaster>webmaster\@$domain (TR Connection)</webMaster>
<lastBuildDate>$date</lastBuildDate>
<language>en-us</language>
EOF
	if($april1){
		$print=~s/Todd/Ted/g;
		$print=~s/Rundgren/Runger/g;
		$print=~s/Utopia/Tedtopia/g;
	}
	print $print;
}
sub xmlize{
	local($item)=shift;
	$item=~s/&nbsp;/ /g;
	$item=~s/&/&amp;/g;
	$item=~s/</&lt;/g;
	$item=~s#href=/#href=$urlhead/#g;
	$item=~s#href="/#href="$urlhead/#g;
	$item=~s#src=/#src=$urlhead/#g;
	$item=~s#src="/#src="$urlhead/#g;
	$item=~s/>/&gt;/g;
	return($item);
}
