#!/usr/bin/tclsh

# Parse query string

set SCRIPT "/cgi-bin/rundumschau.pl"
set BILDER "/rundumschau"
set query $env(QUERY_STRING)

regexp {jahr=([0-9]*)} $query z year
regexp {monat=([0-9]*)} $query z month
regexp {blick=([0-9a-z]*)} $query z dir

set direction(1) "Ostnordost"
set direction(2) "Ost"
set direction(3) "Osts&uuml;dost"
set direction(4) "S&uuml;ds&uuml;dost"
set direction(5) "S&uuml;d"
set direction(6) "S&uuml;ds&uuml;dwest"
set direction(7) "Wests&uuml;dwest"
set direction(8) "West"
set direction(9) "Westnordwest"
set direction(a) "Nordnordwest"
set direction(b) "Nord"
set direction(c) "Nordnordost"

set right(1) 2
set right(2) 3
set right(3) 4
set right(4) 5
set right(5) 6
set right(6) 7
set right(7) 8
set right(8) 9
set right(9) a
set right(a) b
set right(b) c
set right(c) 1

set left(1) c
set left(2) 1
set left(3) 2
set left(4) 3
set left(5) 4
set left(6) 5
set left(7) 6
set left(8) 7
set left(9) 8
set left(a) 9
set left(b) a
set left(c) b

set yearback(89) "05"
set yearback(90) "89"
set yearback(91) "90"
set yearback(92) "91"
set yearback(93) "92"
set yearback(94) "93"
set yearback(95) "94"
set yearback(96) "95"
set yearback(97) "96"
set yearback(98) "97"
set yearback(99) "98"
set yearback(00) "99"
set yearback(01) "00"
set yearback(02) "01"
set yearback(03) "02"
set yearback(04) "03"
set yearback(05) "04"

set yearforward(89) "90"
set yearforward(90) "91"
set yearforward(91) "92"
set yearforward(92) "93"
set yearforward(93) "94"
set yearforward(94) "95"
set yearforward(95) "96"
set yearforward(96) "97"
set yearforward(97) "98"
set yearforward(98) "99"
set yearforward(99) "00"
set yearforward(00) "01"
set yearforward(01) "02"
set yearforward(02) "03"
set yearforward(03) "04"
set yearforward(04) "05"
set yearforward(05) "89"

set yearname(89) "1989"
set yearname(90) "1990"
set yearname(91) "1991"
set yearname(92) "1992"
set yearname(93) "1993"
set yearname(94) "1994"
set yearname(95) "1995"
set yearname(96) "1996"
set yearname(97) "1997"
set yearname(98) "1998"
set yearname(99) "1999"
set yearname(00) "2000"
set yearname(01) "2001"
set yearname(02) "2002"
set yearname(03) "2003"
set yearname(04) "2004"
set yearname(05) "2005"

set monthname(01) "Januar"
set monthname(02) "Februar"
set monthname(03) "M&auml;rz"
set monthname(04) "April"
set monthname(05) "Mai"
set monthname(06) "Juni"
set monthname(07) "Juli"
set monthname(08) "August"
set monthname(09) "September"
set monthname(10) "Oktober"
set monthname(11) "November"
set monthname(12) "Dezember"

set monthback(01) 12
set monthback(02) 01
set monthback(03) 02
set monthback(04) 03
set monthback(05) 04
set monthback(06) 05
set monthback(07) 06
set monthback(08) 07
set monthback(09) 08
set monthback(10) 09
set monthback(11) 10
set monthback(12) 11

set monthforward(01) 02
set monthforward(02) 03
set monthforward(03) 04
set monthforward(04) 05
set monthforward(05) 06
set monthforward(06) 07
set monthforward(07) 08
set monthforward(08) 09
set monthforward(09) 10
set monthforward(10) 11
set monthforward(11) 12
set monthforward(12) 01

set LINK "$SCRIPT?jahr=$year\_monat=$month\_blick="

set YEARBACK "jahr=$yearback($year)\_monat=$month\_blick=$dir"
set YEARFORWARD "jahr=$yearforward($year)\_monat=$month\_blick=$dir"

#if $month==01 { yearnew=$yearback($year) } else { yearnew=$year }
set yearnew $year
set MONTHBACK "jahr=$yearnew\_monat=$monthback($month)\_blick=$dir"
#if $month==12 { yearnew=$yearforward($year) } else { yearnew=$year }
set MONTHFORWARD "jahr=$yearnew\_monat=$monthforward($month)\_blick=$dir"

set TURNLEFT "jahr=$year\_monat=$month\_blick=$left($dir)"
set TURNRIGHT "jahr=$year\_monat=$month\_blick=$right($dir)"

if "($year>=0 && $year<=5)" {
	set BILD "/rundumschau/$year$month\_$dir.jpg"
} else {
	set BILD "/schlosscdneu/ru2/$year$month\_$dir.jpg"
}

puts "Content-type: text/html\n\n"
puts {<html><style type="text/css">
<!--                                                                            
a:link {color: #FF8800; text-decoration: none; }                                
a:active {color: #FF0000; text-decoration: none; }                              
a:visited {color: #FF8800; text-decoration: none; }                             
a:hover {color: #000000; text-decoration: none; }                               
-->
</style><head><title>Zeitfotos: Landschaftsbildwandel im Klimawandel (1989-2005)</title></head>}
puts {</body>}

puts {<center><table><tr>}
puts "<td>"

puts "<table><tr><td style=\"width:100px\;text-align:center\"><a href=\"$SCRIPT?$YEARBACK\"><img src=\"$BILDER/hoch.png\"></a></td></tr>"
puts "<tr><td style=\"width:100px\;text-align:center\"><b>$yearname($year)</b></td></tr>"
puts "<tr><td style=\"width:100px\;text-align:center\"><a href=\"$SCRIPT?$YEARFORWARD\"><img src=\"$BILDER/runter.png\"></a></td></tr></table>"

puts "</td><td>"

puts "<table>"
puts "<tr><td style=\"width:100px\;text-align:center\"><a href=\"$SCRIPT?$MONTHBACK\"><img src=\"$BILDER/hoch.png\"></a></td></tr>"
puts "<tr><td style=\"width:100px\;text-align:center\"><b>$monthname($month)</b></td></tr>"
puts "<tr><td style=\"width:100px\;text-align:center\"><a href=\"$SCRIPT?$MONTHFORWARD\"><img src=\"$BILDER/runter.png\"></a></td></tr>"

puts "</table></td>"

puts "<td><a href=\"$SCRIPT?$TURNLEFT\"><img src=\"$BILDER/links.png\"></a></td><td><a href=\"$SCRIPT?$TURNRIGHT\"><img src=\"$BILDER/rechts.png\"></a></td>"

puts "<td>"

puts "<img src=\"$BILDER/kompass.png\" usemap=\"#Map\" />"
puts {<map name="Map" id="Map">}
puts "<area href=\"${LINK}2\" shape=\"poly\" coords=\"98,67,152,63,151,84,97,80\" />"
puts "<area href=\"${LINK}3\" shape=\"poly\" coords=\"97,82,94,88,129,112,141,85\" />"
puts "<area href=\"${LINK}4\" shape=\"poly\" coords=\"90,88,84,92,105,128,126,114\" />"
puts "<area href=\"${LINK}5\" shape=\"poly\" coords=\"76,90,69,147,99,144,82,93\" />"
puts "<area href=\"${LINK}6\" shape=\"poly\" coords=\"69,88,37,125,62,141,74,89\" />"
puts "<area href=\"${LINK}7\" shape=\"poly\" coords=\"65,80,22,91,35,115,67,86\" />"
puts "<area href=\"${LINK}8\" shape=\"poly\" coords=\"6,94,67,78,67,73,4,57\" />"
puts "<area href=\"${LINK}9\" shape=\"poly\" coords=\"64,69,14,56,27,38,67,64\" />"
puts "<area href=\"${LINK}a\" shape=\"poly\" coords=\"68,60,31,33,60,18,74,61\" />"
puts "<area href=\"${LINK}b\" shape=\"poly\" coords=\"77,60,58,2,96,2,84,62\" />"
puts "<area href=\"${LINK}c\" shape=\"poly\" coords=\"87,59,97,11,121,26,90,65\" />"
puts "<area href=\"${LINK}1\" shape=\"poly\" coords=\"95,63,125,33,139,61,103,65\" />"
puts {</map>}

puts "</td>"
puts "</tr></table></center>"


set y [string trimleft $year 0]
if [string match $year 00] { set y 0 }
set m [string trimleft $month 0]

if "($y<50 && $y>5) || ($y==5 && $m>3)" { 
	puts "<center>Die Umschaubilder enden im M&auml;rz 2005</center>" } else {
		if "($y>49 && $y<89) || ($y==89 && $m<7)" { 
			puts "<center>Die Umschaubilder beginnen im Juli 1989</center>" } else { 
			puts "<center><img src=\"$BILD\"></center>"
		}
	}

puts "<center>Blickrichtung: $direction($dir)</center>\n\n"

puts "<center><table width=70%><tr><td>"
puts {
<br>
<font color=#FFAA55>
<h2>Landschaftsbildwandel im Klimawandel - Die stille Kraft der Zeit</h2>
</font>

<font color=#777777>
Das Projekt entstand im Institut f&uuml;r Wirtschafts&ouml;kologie (IW&Ouml;) unter Leitung von Dr. Dr. Marquardt in zwei Bearbeitungsschritten. Der erste Schritt - eine Fotodokumentation einer Landschaft mit ca. 1900 Bildern - erfolgte &uuml;ber die Jahre 1988 bis 2000 zum 400-j&auml;hrigen Bestehen des in Nordschwaben gelegenen Jagdschlosses Hirschbrunn mit der Erstellung einer CD unter dem Titel: "Die Stille Kraft der Zeit". In den Jahren 2000 bis 2005 wurde die Fotodokumentation in gleicher Systematik weitergef&uuml;hrt und enth&auml;lt jetzt &uuml;ber 2500 Einzelbilder.<br>
</font>
<center><a href="/rundumschau/Vorwort.html"><i>Weiterlesen</i></a></center>
}

puts "</td></tr></table></center>"

puts {</body> </html>}
