#!/usr/bin/perl
#
use LWP::Simple;
use CGI ;
use Switch;

my $cgiq = new CGI;
print $cgiq->header;

if ($cgiq->param()) {
	my $plugin = $cgiq->param("plug") ;
print <<EOF;
<HTML>
<HEAD>
<TITLE>William's Home</TITLE>
<META NAME="HandheldFriendly" CONTENT="True">
EOF

switch( $plugin ) {

	case "tvlistings" {
print <<EOF;
<META http-equiv='refresh' content='300;'>
<META HTTP-EQUIV='Expires' CONTENT='Mon, 06 Jan 1990 00:00:01 GMT'>
EOF
}  
	case 'news' {
print <<EOF;
<base target="_blank">
<META http-equiv='refresh' content='6000;'>
<META HTTP-EQUIV='Expires' CONTENT='Mon, 06 Jan 1990 00:00:01 GMT'>
EOF
}
	case 'rss' {
print <<EOF;
<META http-equiv='refresh' content='6000;'>
<META HTTP-EQUIV='Expires' CONTENT='Mon, 06 Jan 1990 00:00:01 GMT'>
EOF
}
	else {
print '<base target="_blank">';
print <<EOF;
<META http-equiv='refresh' content='6000;'>
<META HTTP-EQUIV='Expires' CONTENT='Mon, 06 Jan 1990 00:00:01 GMT'>
EOF
}
} # end switch

print <<EOF;
<STYLE>
BODY {
	background: transparent ;
	font-family:Verdana, sans-serif;
	font-size: 8pt;
}
TD {
	font-family:Verdana, sans-serif;
	font-size: 8pt;
}
TH {
	font-family:Verdana, sans-serif;
	font-size: 8pt;
}
A {
	text-decoration: none;
	color: black
}

A:hover {
	color: '#820082';
}

/* styles for the tree */
SPAN.TreeviewSpanArea A {
       	font-size: 8pt; 
       	font-family: verdana,helvetica; 
	text-decoration: none;
	color: black
}
SPAN.TreeviewSpanArea A:hover {
	color: '#820082';
}

</STYLE>
</HEAD>
<BODY>
EOF

switch( $plugin ) {

	case "cal" {
		require "myhomeplugins/mycal";
		PrintCalendar();
	}

	case "clock" {
		require "myhomeplugins/myclock";
		PrintClock();
	}

	case "weather" {
		require "myhomeplugins/myweather" ;
		print "<table><tr><td valign=top>";
		PrintSideWeather();
		print "</td><td valign=top>";
		PrintWeatherImage();
		print "</td></tr></table>";
		PrintLongWeather();
	}

	case "weatherpalm" {
		require "myhomeplugins/myweather" ;
		print "<table><tr><td valign=top>";
		PrintWeatherImage();
		print "</td></tr></table>";
		PrintLongWeather();
	}

	case "weatherforcast" {
		require "myhomeplugins/myweather" ;
		PrintLongWeather();
	}

	case "weatherimage" {
		require "myhomeplugins/myweather" ;
		PrintWeatherImage();
	}

	case "weathercurrent" {
		require "myhomeplugins/myweather" ;
		PrintSideWeather();
	}

	case "tvlistings" {
		require "myhomeplugins/mytvlistings";
		PrintMyTVListings( $cgiq );
	}

	case "tvlistingsdetails" {
		require "myhomeplugins/mytvlistingsdetails";
		PrintMyTVListingsDetails( $cgiq );
	}

	case "favorites" {
		require "myhomeplugins/myfavorites";
		PrintFavoritesTree();
	}

	case "news" {
		require "myhomeplugins/myrss";
		PrintRSSFlat();
	}

	case "rss" {
		require "myhomeplugins/myrss";
		PrintRSSTree();
	}

	case "search" {
		require "myhomeplugins/mysearch";
		PrintMySearchForm();
	}

	case "fortune" {
		require "myhomeplugins/myfortune";
		PrintFortune();
	}

	case "empty" {
		print "&nbsp;";
	}

	else {
		printf "<SCRIPT> self.location.href='%s'; </SCRIPT>", $plugin ;
#		print "Unknown plugin: $plugin\n" ;
	}
}
} else {
	print "No plugin specified!\n"
}

print <<EOF;
</BODY>
</HTML>
EOF
