//
// file: functions.js
//
// Manfred Pfluegl
// All rights reserved.
// Copyright 2000-2001.
//
// Travel with Manfred
//

// ---------------------------------------------------------------------------------------------

//
// data segement: constants
//

// MYCONST="Manfred Pfluegl";

// ---------------------------------------------------------------------------------------------

//
// data segment: variables
//

var CopyrightYears=		"";
var CopyrightOwner=		"";
var CopyrightLink=		"";  /* used for link to web of copyright holder, e.g. for photos */
var DateTraveled=		"";
var Title=			"";
var SubTitle=			"";
var Author=			"";
var Keywords=			"";
var Description=		"";
var PhotoSrc=			"";

// for all pages
var DefaultCopyrightYears=	"1992-2003";
var DefaultCopyrightOwner=	"Manfred Pfluegl";

// ---------------------------------------------------------------------------------------------

//
// functions
//

// ---------------------------------------------------------------------------------------------

function writeTitleGeneric() {
	if((Title != "") && (SubTitle != ""))
		document.write('<TITLE>',Title,' - ',SubTitle,'</TITLE>');
	else if((Title != "") && (SubTitle == ""))
		document.write('<TITLE>',Title,'</TITLE>');
	else if((Title == "") && (SubTitle != ""))
		document.write('<TITLE>',SubTitle,'</TITLE>');
	else
		document.write('<TITLE>Travel with Manfred</TITLE>');
}

// ---------------------------------------------------------------------------------------------

function writeTitleTravelogue() {
	writeTitleGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeTitlePoem() {
	writeTitleGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeTitlePhoto() {
	writeTitleGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeTitleLife() {
	writeTitleGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeDescriptionGeneric() {
	if(Keywords != "")
		document.write('<META name="description" content="A travelogue by Manfred Pfluegl covering ',Keywords,'">');
	if(Description != "")
		document.write('<META name="description" content="',Description,'">');
}

// ---------------------------------------------------------------------------------------------

function writeDescriptionTravelogue() {
	writeDescriptionGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeDescriptionPoem() {
	writeDescriptionGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeDescriptionPhoto() {
	writeDescriptionGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeDescriptionLife() {
	if(Keywords != "")
		document.write('<META name="keywords" content="',Keywords,'">');
	else
		document.write('<META name="keywords" content="A description of Manfred Pfluegl\'s life. An electronic diary.">');
	if(Description != "")
		document.write('<META name="description" content="',Description,'">');
	else
		document.write('<META name="description" content="A description of Manfred Pfluegl\'s life. An electronic diary.">');
}

// ---------------------------------------------------------------------------------------------

function writeHeaderGeneric() {
	writeHeaderGenericParam(CopyrightYears, CopyrightOwner, DateTraveled, Title, SubTitle, Author, Keywords, Description);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderTravelogue() {
	writeHeaderTravelogueParam(CopyrightYears, CopyrightOwner, DateTraveled, Title, SubTitle, Author, Keywords, Description);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderPoem() {
	writeHeaderPoemParam(CopyrightYears, CopyrightOwner, DateTraveled, Title, SubTitle, Author, Keywords, Description);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderPhoto() {
	writeHeaderPhotoParam(CopyrightYears, CopyrightOwner, CopyrightLink, DateTraveled, Title, SubTitle, Author, Keywords, Description, PhotoSrc);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderLife() {
	writeHeaderLifeParam(CopyrightYears, CopyrightOwner, CopyrightLink, DateTraveled, Title, SubTitle, Author, Keywords, Description, PhotoSrc);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderGenericParam(_CopyrightYears, _CopyrightOwner, _DateTraveled, _Title, _SubTitle, _Author, _Keywords, _Description) {
	writeTitle(_Title);
	writeSubTitle(_SubTitle);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderTravelogueParam(_CopyrightYears, _CopyrightOwner, _DateTraveled, _Title, _SubTitle, _Author, _Keywords, _Description) {
	writeTranslation();
	document.write('<DIV id=travel>');
	writeTerms();
	writeCopyright(_CopyrightYears, _CopyrightOwner);
	writeDate(_DateTraveled);
	writeTitle(_Title);
	writeSubTitle(_SubTitle);
	writeAuthor(_Author);
	writeKeywords(_Keywords);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderPoemParam(_CopyrightYears, _CopyrightOwner, _DateTraveled, _Title, _SubTitle, _Author, _Keywords, _Description) {
	writeCopyright(_CopyrightYears, _CopyrightOwner);
	writeTitle(_Title);
	writeSubTitle(_SubTitle);
	writeAuthor(_Author);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderPhotoParam(_CopyrightYears, _CopyrightOwner, _CopyrightLink, _DateTraveled, _Title, _SubTitle, _Author, _Keywords, _Description, _PhotoSrc) {
	writeTitle(_Title);
	writeSubTitle(_SubTitle);
	writePhoto(_CopyrightYears, _CopyrightOwner, _CopyrightLink,  _PhotoSrc);
}

// ---------------------------------------------------------------------------------------------

function writeHeaderLifeParam(_CopyrightYears, _CopyrightOwner, _CopyrightLink, _DateTraveled, _Title, _SubTitle, _Author, _Keywords, _Description, _PhotoSrc) {
	writeCopyright(_CopyrightYears, _CopyrightOwner);
	writeTitle(_Title);
	writeSubTitle(_SubTitle);
	writeAuthor(_Author);
}

// ---------------------------------------------------------------------------------------------

function writePhoto(_CopyrightYears, _CopyrightOwner, _CopyrightLink,  _PhotoSrc) {
	status.write=_PhotoSrc;
	if(_CopyrightOwner == "")
		_CopyrightOwner = _CopyrightLink;
	if(_CopyrightYears == "") _CopyrightYears = DefaultCopyrightYears;
	if(_CopyrightOwner == "") _CopyrightOwner = DefaultCopyrightOwner;

	document.write('\
<center><table class="photo"><tr><td class="photo">\
<a href=javaScript:history.back()><img class="photo" src="',_PhotoSrc,'" alt="Photo of Manfred"></a>\
</td></tr><tr><td class="copyright">');
	if(_CopyrightLink != "")
		document.write('<a HREF="',_CopyrightLink,'"><P class="xsmall">Photo &copy; ',_CopyrightYears,' by ',_CopyrightOwner,'</P></a>');
	else if(_CopyrightOwner != "")
		document.write('<P class="xsmall">Photo &copy; ',_CopyrightYears,' by ',_CopyrightOwner,'</P>');
	else
		; /* noop */; /* nothing to do, both owner and link are empty */
	document.write('</td></tr></table></center>');
}

// ---------------------------------------------------------------------------------------------

function writeFooterGeneric() {
	document.write('\
<center>\
<hr>\
<input name="Back One Screen"  onClick="history.back()" type="button" value="Back One Screen"> &nbsp;&nbsp;&nbsp;&nbsp;\
<input name="Back to Homepage" onClick="goHome()" type="button" value="Back to Homepage">  \
<hr>\
<P class="xsmall">\
These <a HREF="disclaimer.html">copyright notice and legal disclaimers</a> \
apply to all pages of this Web site.\
<hr>\
</center>\
');
}

// ---------------------------------------------------------------------------------------------

function writeFooterTravelogue() {
	writeFooterGeneric();
	document.write('</DIV>');
}

// ---------------------------------------------------------------------------------------------

function writeFooterPoem() {
	writeFooterGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeFooterPhoto() {
	writeFooterGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeFooterLife() {
	writeFooterGeneric();
}

// ---------------------------------------------------------------------------------------------

function writeTerms() {
	document.write('\
<H1  class="xsmall">TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</H5>\
<P class="xsmall">\
Everyone is permitted to copy and distribute verbatim copies of this \
document without a fee, provided that the person conspicuously and \
appropriately publishes on each copy the appropriate copyright notice \
and these terms and conditions for copying, distribution, and \
modifications. Changing this document or charging a fee for \
distribution or using this document for a financial profit is not \
allowed. Including this document in a publication that is for sale is \
not permitted. \
\
<P class="xsmall">\
This document solely expresses the author\'s current opinions. It in no \
way expresses the opinion of any other legal entity. This document does \
not claim to be correct, complete, or factual. Reading it is at your own \
risk.\
');
}

// ---------------------------------------------------------------------------------------------

function writeCopyright(_CopyrightYears, _CopyrightOwner) {
	if(_CopyrightYears == "") _CopyrightYears = DefaultCopyrightYears;
	if(_CopyrightOwner == "") _CopyrightOwner = DefaultCopyrightOwner;

	document.write('\
<P class="xsmall">Copyright &copy; ',_CopyrightYears,' by ',_CopyrightOwner,'. All rights reserved.</P>\
<hr>\
');
}

// ---------------------------------------------------------------------------------------------

function writeTranslation() {
	document.write('<table width=1000px><tr><td align=right>X<script language="JavaScript1.2" src="http://www.altavista.com/r?entr"></script>Y</td></tr></table><br><hr>');
}

// ---------------------------------------------------------------------------------------------

function writeDate(_DateTraveled) {
	if(_DateTraveled != "")
		document.write('<P class="date">',_DateTraveled,'</P>');
}

// ---------------------------------------------------------------------------------------------

function writeTitle(_Title) {
	if(_Title != "")
		document.write('<H1>',_Title,'</H1>');
}

// ---------------------------------------------------------------------------------------------

function writeSubTitle(_SubTitle) {
	if(_SubTitle != "")
		document.write('<H2>',_SubTitle,'</H2>');
}

// ---------------------------------------------------------------------------------------------

function writeAuthor(_Author) {
	if(_Author != "")
		document.write('<P class="by">by</P><P class="author">',_Author,'</P><P>');
}

// ---------------------------------------------------------------------------------------------

function writeKeywords(_Keywords) {
	if(_Keywords != "")
		document.write('<cite>Keywords: ',_Keywords,', tourist, travel trip report, travel log, travelogue.</cite><P>');
}

// ---------------------------------------------------------------------------------------------

function goHome() { 		
	window.location.href = "main.php"; 
}

// ---------------------------------------------------------------------------------------------

function writePhotoPage(strImgSrc, descr) {
  document.writeln('<html><head><LINK rel=stylesheet href=html/default.css type=text/css>');
  document.writeln('</HEAD><BODY>');
  if(descr.length < 30) { // assume it is a header
    document.writeln('<H1>'+descr+'</H1>');
  } else {
    document.writeln('<center><table><tr><td>'+descr+'</td></tr></table></center>');
  }
  document.writeln('<P><center><a href=javaScript:history.back()><img SRC='+strImgSrc+'></a></center></BODY></HTML>');
}

// ---------------------------------------------------------------------------------------------


function writePhotoWithLink(strClass, strImgSrc, descr) {
  document.writeln('<a href="javascript:writePhotoPage(\'',strImgSrc,'\',\'',descr,'\');"><img class=',strClass,' src="',strImgSrc,'"></a>');
}

// ---------------------------------------------------------------------------------------------

// end of file

