// Global functions and variables
/*******************************************************/

var rootPath;

/*******************************************************/

function padZero(value) 
/*
Function by RoBorg
RoBorg@geniusbug.com
http://javascript.geniusbug.com
*/
{ 
     if(value < 10) return '0' + value; 
     return value; 
}
/*******************************************************/

function setRootPath(parm) 
// Set rootPath variable to be path back to root directory.
// Default is forward slash.
{ 
    if (parm == null)
    {
		rootPath = "/";
    }
	else
    {
		rootPath = parm;
    }
}
/*******************************************************/

function homeLink() 
{ 
// Link back to home page.

	document.write("<br>");
	document.write("<center>");
	document.write("<a href=\""+rootPath+"index.htm\" target=\"_top\"title=\"My home page\">Click here to go to my Home Page.</a>");
	document.write("</center>");
}

/*******************************************************/

function email_me() 
{ 
// Insert "mail to".

	document.write("<a href=\"mail");
	document.write("to:www");
	document.write("@");
	document.write("corder");
	document.write("y.org.uk\" title=\"Send me an e-mail\">E-Mail Me</a>");
}

/*******************************************************/

function showHead1(pRootPath) 
{ 
// Standard Header 1 

	var cDatNow = new Date();
	var cStrNow = Date(cDatNow).toString(); // convert to string
	var cDOWNum = cDatNow.getDay(); // day of the week (0=Sun)
	var cDOWStr = "SunMonTueWedThuFriSat".substring(3*cDOWNum,3*cDOWNum+3);
	var cDWM = cDatNow.getDate(); // date within month
	var cMon = cStrNow.substring(4,7); // month
	var cYYYY = cDatNow.getFullYear(); // year
	var cFirstJan = new Date(cYYYY, 0, 1, 0, 0, 0); // first day of year
	var cJulAdj = cDatNow.getTimezoneOffset() / (24 * 60); // Adjust for time zone
	var cJul = 1 + Math.floor((cDatNow - cFirstJan) / (24 * 60 * 60 * 1000) - cJulAdj); // Julian
	var cHHMMSS = padZero(cDatNow.getHours()) +
		":"	+ padZero(cDatNow.getMinutes()) + 
		":" + padZero(cDatNow.getSeconds());
	var cHHMMUTC = padZero(cDatNow.getUTCHours()) +
		":"	+ padZero(cDatNow.getUTCMinutes());

	document.write("<table width=\"100%\">");

	document.write("<tr>");

	document.write("<td width=\"33%\" align=\"left\"><font size=-1 color=\"#FF0000\">");

	document.write("<b>"+cDOWStr+" "+cDWM+" "+cMon+" "+cYYYY+" (day "+cJul+")</b>");
	document.write("</font>");

	document.write("<td width=\"34%\" align=\"center\"><font size=-1 color=\"#0000FF\">");
	document.write("<b>Steve Cordery\'s Web Pages</b>");
	document.write("</font>");

	document.write("<td width=\"33%\" align=\"right\">");
	document.write("<font size=-2 color=\"#000000\"><b>(UTC "+cHHMMUTC+")</b> ");
	document.write("<b><font size=-1 color=\"#FF0000\">"+cHHMMSS+"</b>");
	document.write("</font>");

	document.write("</table>");

	document.write("<table width=\"100%\" border=3 bgcolor=\"#FEDAC2\">");

	document.write("<tr>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"navigate.htm\" title=\"Navigation page\" target=\"navigate\">Navigate</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"index.htm\" title=\"My home page\">Home</a></td>");
/*
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"mailto:steve.cordery@bcs.org.uk\" title=\"Send me an e-mail\">E-Mail Me</a></td>");
*/
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/index.htm\" title=\"My favourite web links\">WebLinks</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"genealogy/index.htm\" title=\"My family history pages\">Genealogy</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"admin/summary.htm\" title=\"Summary of the pages on my site\">Summary</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"http:\//www.google.co.uk/\" title=\"Google web search\" target=\"_blank\">Google</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"http:\//www.hotmail.com/\" title=\"Access HotMail\" target=\"_blank\">Hotmail</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"http:\//www.oneandone.co.uk\" title=\"1 & 1 - My web site host\" target=\"_blank\">1 & 1</a></td>");

	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"http:\//www.bbc.co.uk\" title=\"BBC site\" target=\"_blank\">BBC</a></td>");

	document.write("</tr>");

	document.write("</font>");
	document.write("</table>");
}

/*******************************************************/

function showFoot1() 
{ 
	// Standard Footer 1

	var cDatNow = new Date();
	var cYYYY = cDatNow.getFullYear(); // year

	// Get time and date modified
	var cDatMod = new Date(document.lastModified);
	var cStrMod = cDatMod.toString(); // convert to string
	var cDOWModNum = cDatMod.getDay(); // day of the week (0=Sun)
	var cDOWModStr = "SunMonTueWedThuFriSat".substring(3*cDOWModNum,3*cDOWModNum+3);
	var cDWMMod = cDatMod.getDate(); // date within month
	var cMonMod = cStrMod.substring(4,7); // month
	var cYYYYMod = cDatMod.getFullYear(); // year

	var cHHMMSSMod = padZero(cDatMod.getHours()) +
		":"	+ padZero(cDatMod.getMinutes()) + 
		":" + padZero(cDatMod.getSeconds());

	document.write("<br>");
	document.write("<table width=\"100%\">");
	document.write("<tr>");

	document.write("<td><font size=-1 color=\"#FF0000\">");

	document.write("<b>(c) Copyright 2001-"+cYYYY+" Stephen John Cordery</b>");
	document.write("</font>");

	document.write("<td align=\"right\"><font size=-1 color=\"#0000FF\">");
	document.write("<b>Page modified on "+cDOWModStr+" "+cDWMMod+" "+cMonMod+" "+cYYYYMod);
	document.write(" at "+cHHMMSSMod+"</b>");
	document.write("</font>");

	document.write("</table>");
}

/*******************************************************/

function showOtherLinks() 
{ 
	// Ribbon layout for link page navigation
	document.write("<table width=\"100%\" border=3 bgcolor=\"#87FAD8\">");
	document.write("<tr>");
	document.write("<td height=15><b><font size=-1><center>");
	document.write("<b>WEB LINK CATEGORIES ...</b></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/search.htm\" title=\"Internet search sites\">Search</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/computing.htm\" title=\"Internet and Computer profession including programming\">Computing</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/reference.htm\" title=\"Sites to look up information\">Reference</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/travel.htm\" title=\"Sites connected with travelling\">Travel</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/finance.htm\" title=\"Sites connected with personal finance\">Finance</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/leisure.htm\" title=\"Sites connected with leisure activities\">Leisure</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/sport.htm\" title=\"Sports news and reference sites\">Sport</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/genealogy.htm\" title=\"Family history\">Genealogy</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/nostalgia.htm\" title=\"The &quot;Good Old Days&quot;\">Nostalgia</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/miscellany.htm\" title=\"Other uncategorised sites\">Miscellaneous</a></td>");
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/@test.htm\" title=\"Test\">Test</a></td>");
	document.write("</tr>");

	document.write("</font>");
	document.write("</table>");
}

/*******************************************************/

function showWebLinks() 
{ 
	// Ribbon layout web links

	document.write("<table width=\"100%\" border=3 bgcolor=\"#87FAD8\">");

	document.write("<tr valign=middle>");

	document.write("<td height=15><b><font size=-1><center>");
	document.write("<b>WEB LINKS ...</b></td>");
	
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\"http://www.cordery.org.uk/@php/weblinks.php4?type=cat&parm=all\" title=\"All links\">All Links</a></td>");
	
	document.write("<td height=15><b><font size=2><center>");
	document.write("<a href=\""+rootPath+"links/\" title=\"Find a link by category\">All Categories</a></td>");
	
	document.write("<td height=15><b><font size=2><center>");
	document.write("Favourites</td>");
	
	document.write("<td height=15><b><font size=2><center>");
	document.write("Main Categories</td>");
	
	document.write("<td height=15><b><font size=2><center>");
	document.write("<form name=\"keyword\" id=\"keyword\" onsubmit=\"do_LinkKeyword(document.keyword.keytext.value)\">");
	document.write("Keyword ...");
	document.write("<input type=\"text\" name=\"keytext\" id=\"keytext\" size=30 value=\"Enter keyword here and click Go\"");
	document.write("onclick=\"clearKeyword()\">");
	document.write("<input type=\"button\" value=\"Go\" onclick=do_LinkKeyword(document.keyword.keytext.value)>");
	document.write("</form>");
	document.write("</td>");

	document.write("</font>");
	document.write("</table>");
}

/*******************************************************/

function do_LinkKeyword(argtext)
{
	var newurl = 'http://www.cordery.org.uk/@php/weblinks.php4?type=kwd&parm='+argtext;
	var newwin = window.open(newurl, "SCLinks", 'resizable=yes,location=yes,menubar=yes,toolbar=yes,scrollbars=yes', true);
	newwin.focus();
}

/*******************************************************/

function clearKeyword()
{
if (document.keyword.keytext.value == document.keyword.keytext.defaultValue)
	{document.keyword.keytext.value = ''}
}
