//
//	Perio.js
//
//	Content access Menus for Xeno Campanoli's web pages.
//
//	Objects:  Target, Menu
//
//	Copyright 2004 Xeno Campanoli
//

MonthName = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

DOWName = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

function MainMenuCfg(name,value)
{
	MainMenuCfg[name] = value;
}

MainMenuCfg('heading','allheadings');
MainMenuCfg('sizing','regular');
MainMenuCfg('layout','color');

function dictionary(name)
{
	switch(name)
	{
		case "aggregate":			return "Aggregate";
		case "allheadings":			return "All Headings";
		case "alltargets":			return "All Targets";
		case "alphabetical":		return "Alphabetical";
		case "ascending":			return "Ascending";
		case "big":					return "Big";
		case "biglabel":			return "Big Label";
		case "both":				return "Both Menus";
		case "bottom4":				return "Bottom 4 Targets";
		case "BUNCH":				return "Bunch";
		case "color":				return "Color";
		case "COLUMN":				return "Column";
		case "COLUMNb":				return "Bordered Column";
		case "descending":			return "Descending";
		case "explanation":			return "Explanation";
		case "favor":				return "Favorites";
		case "first":				return "First Target";
		case "iddefault":			return "Id Default";
		case "label":				return "Label";
		case "last":				return "Last";
		case "lingbat":				return "Dog Nose";
		case "main":				return "Main Menu";
		case "micro":				return "Micro Image Bullet"
		case "middle6":				return "Middle 6 Targets";
		case "new":					return "New Window";
		case "no":					return "No";
		case "nobrowserheadings":	return "No Browser Headings";
		case "nodocumentheadings":	return "No Document Headings";
		case "noheadings":			return "No Headings At All";
		case "nothing":				return "Nothing";
		case "OL":					return "Ordered List";
		case "OL1":					return "Ordered List (1)";
		case "OLa":					return "Ordered List (a)";
		case "OLA":					return "Ordered List (A)";
		case "OLi":					return "Ordered List (i)";
		case "OLI":					return "Ordered List (I)";
		case "picro":				return "Picro Image Bullet"
		case "regular":				return "Regular";
		case "repimg_uri":			return "Repimg URI";
		case "ROW":					return "Row";
		case "ROWb":				return "Bordered Row";
		case "same":				return "Same Window";
		case "smallexplanation":	return "Small Explanation";
		case "small":				return "Small";
		case "smalllabel":			return "Small Label";
		case "TABLE2":				return "2 Column Table";
		case "TABLE2b":				return "Bordered 2 Column Table";
		case "TABLE3":				return "3 Column Table";
		case "TABLE3b":				return "Bordered 3 Column Table";
		case "TABLE4":				return "4 Column Table";
		case "TABLE4b":				return "Bordered 4 Column Table";
		case "target_uri":			return "Target URI";
		case "top3":				return "Top 3 Targets";
		case "top5":				return "Top 5 Targets";
		case "topic":				return "Topic Menus";
		case "UL":					return "Unordered List";
		case "window_height":		return "Window Height";
		case "width_icon":			return "Width Icon";
		case "width_micro":			return "Width Micro";
		case "width_mini":			return "Width Mini";
		case "width_picro":			return "Width Picro";
		case "width_tenbyten":		return "Width Ten by Ten";
		case "width_tenht":			return "Width Ten Height";
		case "window_width":		return "Window Width";
		case "yes":					return "Yes";
		default:					return "Invalid name";
	}
}

function putPop(wino,uri,window_name,openfeatures)
{
	var newwin = wino.open(uri,window_name,openfeatures);
	newwin.focus(1);
	newwin.document.close();
}

function adjustSize(displayfield,basesize)
{
	function downSize(displayfield)
	{
		switch(displayfield) {
			case "biglabel":			return "label";
			case "label":				return "smalllabel";
			case "smalllabel":			return "smallsmalllabel";
			case "explanation":			return "smallexplanation";
			case "smallexplanation":	return "smallsmallexplanation";
			case "target_uri":			return "smalltarget_uri";
			case "smalltarget_uri":		return "smallsmalltarget_uri";
			case "repimg_uri":			return "width_mini";
			case "width_mini":			return "width_icon";
			case "width_icon":			return "width_micro";
			case "width_micro":			return "width_picro";
			case "width_picro":			return "width_tenht";
			default:					return displayfield;
		}
	}
	function upSize(displayfield)
	{
		switch(displayfield) {
			case "label":					return "biglabel";
			case "smalllabel":				return "label";
			case "smallsmalllabel":			return "smalllabel";
			case "smallexplanation":		return "explanation";
			case "smallsmallexplanation":	return "smallexplanation";
			case "smalltarget_uri":			return "target_uri";
			case "smallsmalltarget_uri":	return "smalltarget_uri";
			case "width_mini":				return "repimg_uri";
			case "width_icon":				return "width_mini";
			case "width_micro":				return "width_icon";
			case "width_picro":				return "width_micro";
			case "width_tenht":				return "width_picro";
			default:						return displayfield;
		}
	}

	if ( basesize == 'main' )				displayfield = downSize(displayfield);
	if ( MainMenuCfg.sizing == 'small' )	displayfield = downSize(displayfield);
	if ( MainMenuCfg.sizing == 'big' )		displayfield = upSize(displayfield);
	return displayfield;
}

function getMainCfgRadio(opname,name,namechecked)
{
	var scalar;
	
	scalar = '<table>';
	var index;
	var promptname;
	var checked;
	for(index = 0;  index < opname.length;  ++index)
	{
		if ( opname[index] == namechecked )	{	checked = ' checked'; }
		else									{	checked = ''; }
		promptname = dictionary(opname[index]);
		scalar += '<tr><td><input type=radio ' + checked + ' name=' + name + ' value="' + opname[index] + '" onClick=reConfigMain("' + name + '","' + opname[index] + '")>' + promptname + '</input></td></tr>\n';
	}
	scalar += '</table>';
	return scalar;
}

function getMainMenuCfgMenu()
{
	var formname = 'MainMenu_form';
	var scalar;
	scalar =	"<TABLE border center>\n" + "<TR>\n" +
				"<TH>\nRoom on Top\n</TH>\n" +
				"<TH>\nCategory Layout\n</TH>\n" +
				"<TH>\nSizing\n</TH>\n" +
				"</TR>\n";
	scalar += '<form id=' + formname + '>\n<TR>\n<TD>\n';
	var buffer;
	opname = new Array('allheadings','nodocumentheadings','nobrowserheadings','noheadings');
	buffer = getMainCfgRadio(opname,'heading',MainMenuCfg.heading);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('aggregate','alphabetical','color');
	buffer = getMainCfgRadio(opname,'layout',MainMenuCfg.layout);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('big','regular','small');
	buffer = getMainCfgRadio(opname,'sizing',MainMenuCfg.sizing);
	scalar += buffer + '</TD>\n</TR>\n</TABLE>\n</form>';
	return scalar;
}

function reConfigMain(fieldname,setting)
{
	MainMenuCfg(fieldname,setting);

	putMainPage(window);
}

function getTopicCfgRadio(opname,name,namechecked,window_name)
{
	var scalar;
	
	scalar = '<table>';
	var index;
	var promptname;
	var checked;
	for(index = 0;  index < opname.length;  ++index)
	{
		if ( opname[index] == namechecked )	{	checked = ' checked'; }
		else									{	checked = ''; }
		promptname = dictionary(opname[index]);
		scalar += '<tr><td><input type=radio ' + checked + ' name=' + name + ' value="' + opname[index] + '" onClick=reConfigTopic(' + window_name + ',"' + name + '","' + opname[index] + '")>' + promptname + '</input></td></tr>\n';
	}
	scalar += '</table>';
	return scalar;
}

function getTargetSetCfgMenu()
{
	var formname = this.symbolic_name + '_form';
	var scalar;
	scalar =	"<TABLE border center>\n" + "<TR>\n" +
				"<TH>\nConfiguration Target\n</TH>\n" +
				"<TH>\nGoTo Type\n</TH>\n" +
				"<TH>\nDisplay Field, Primary\n</TH>\n" +
				"<TH>\nDisplay Field, Secondary\n</TH>\n" +
				"<TH>\nList Type\n</TH>\n" +
				"<TH>\nList Subset\n</TH>\n" +
				"<TH>\nSort Field, Primary\n</TH>\n" +
				"<TH>\nSort Order\n</TH>\n" +
				"</TR>\n";
	scalar += '<form id=' + formname + '>\n<TR>\n<TD>\n';
	var buffer;
	opname = new Array('main','topic','both');
	buffer = getTopicCfgRadio(opname,'cfgtarget',this.cfgtarget,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('new','same');
	buffer = getTopicCfgRadio(opname,'gototype',this.gototype,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n';
	var opname = new Array('biglabel','explanation','iddefault','label','repimg_uri','smallexplanation','smalllabel','target_uri','width_icon','width_micro','width_mini','width_picro','width_tenbyten','width_tenht');

	buffer = getTopicCfgRadio(opname,'displayfield_1',this.displayfield_1,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n\n';
	opname = new Array('biglabel','explanation','iddefault','label','nothing','repimg_uri','smallexplanation','smalllabel','target_uri','width_icon','width_micro','width_mini','width_picro','width_tenbyten','width_tenht');
	buffer = getTopicCfgRadio(opname,'displayfield_2',this.displayfield_2,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('UL','OL','OLa','OLA','OLi','OLI','lingbat','micro','picro','ROW','ROWb','COLUMN','COLUMNb','TABLE2','TABLE2b','TABLE3','TABLE3b','TABLE4','TABLE4b','BUNCH');
	buffer = getTopicCfgRadio(opname,'listtype',this.listtype,this.symbolic_name);
	scalar += buffer + '\n</TD>\n<TD>\n\n';
	opname = new Array('alltargets','first','top3','top5','middle6','bottom4');
	buffer = getTopicCfgRadio(opname,'listsubset',this.listsubset,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('explanation','favor','iddefault','label','repimg_uri','target_uri','width_icon','width_micro','width_mini','window_height','window_width');
	buffer = getTopicCfgRadio(opname,'sortfield',this.sortfield,this.symbolic_name);
	scalar += buffer + '</TD>\n<TD>\n';
	opname = new Array('ascending','descending');
	buffer = getTopicCfgRadio(opname,'sortorder',this.sortorder,this.symbolic_name);
	scalar += buffer + '</TD>\n</TR>\n</TABLE>\n</form>';
	return scalar;
}

function reConfigTopic(tso,fieldname,setting)
{
	tso[fieldname] = setting;

	if ( fieldname == 'cfgtarget' ) return;
	if ( fieldname == 'sortorder' ) tso.sortorder = setting;

	if ( tso.symbolic_name == 'Aggregate' )
		putPopMenu(window,'Aggregate',tso.openfeatures);
	else
	{
		if ( tso.cfgtarget == 'main'  || tso.cfgtarget == 'both' )	putMainPage(window);
		if ( tso.cfgtarget == 'topic' || tso.cfgtarget == 'both' )	putPopMenu(window,tso.symbolic_name,tso.openfeatures);
	}

	// For now I'm assuming I cannot successfully keep a database of existing windows
	// with Javascript alone unless I use cookies, which I've decided would be too messy,
	// and probably a security problem.  Last paragraph on P227 Rhino esp.  I am open
	// to any well-thought-out suggestions on this.
}

function setOpenFeatures(width,height,resizeable,scrollbars,location,menubar,toolbar)
{
	this.width_window							= width;
	this.height_window							= height;
	if ( resizeable == undefined ) resizeable	= "yes";
	if ( scrollbars == undefined ) scrollbars	= "yes";
	if ( location == undefined ) location		= "yes";
	if ( menubar == undefined ) menubar			= "yes";
	if ( toolbar == undefined ) toolbar			= "yes";
	this.resizeable								= resizeable;
	this.scrollbars								= scrollbars;

	this.openfeatures = "width=" + width + ",height=" + height + ",resizeable=" + resizeable + ",scrollbars=" + scrollbars + ",location=" + location + ",menubar=" + menubar + ",toolbar=" + toolbar;
}

function labelCmp(taro1,taro2)
{
	if		( taro1.label > taro2.label )
		return TargetSet.biggersign;
	else if ( taro1.label == taro2.label )
	{
		if (  taro1.explanation > taro2.explanation )
			return TargetSet.biggersign;
		else if (  taro1.explanation == taro2.explanation )
			return 0;
		else
			return TargetSet.smallersign;
	}
	else
		return TargetSet.smallersign;
}

function explanationCmp(taro1,taro2)
{
	if		( taro1.explanation > taro2.explanation )
		return TargetSet.biggersign;
	else if ( taro1.explanation == taro2.explanation )
	{
		if (  taro1.label > taro2.label )
			return TargetSet.biggersign;
		else if (  taro1.label == taro2.label )
			return 0;
		else
			return TargetSet.smallersign;
	}
	else
		return TargetSet.smallersign;
}

function SetSortDirection()
{
	if		(this.sortorder == 'ascending')
	{
		TargetSet.biggersign = 1;
		TargetSet.smallersign = -1;
	}
	else if	(this.sortorder == 'descending')
	{
		TargetSet.biggersign = -1;
		TargetSet.smallersign = 1;
	}
}

function target_uriCmp(taro1,taro2)
{
	if		( taro1.target_uri > taro2.target_uri )
		return TargetSet.biggersign;
	else if ( taro1.target_uri == taro2.target_uri )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function repimg_uriCmp(taro1,taro2)
{
	if		( taro1.repimg_uri > taro2.repimg_uri )
		return TargetSet.biggersign;
	else if ( taro1.repimg_uri == taro2.repimg_uri )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function width_miniCmp(taro1,taro2)
{
	if		( taro1.width_mini > taro2.width_mini )
		return TargetSet.biggersign;
	else if ( taro1.width_mini == taro2.width_mini )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function width_iconCmp(taro1,taro2)
{
	if		( taro1.width_icon > taro2.width_icon )
		return TargetSet.biggersign;
	else if ( taro1.width_icon == taro2.width_icon )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function width_microCmp(taro1,taro2)
{
	if		( taro1.width_micro > taro2.width_micro )
		return TargetSet.biggersign;
	else if ( taro1.width_micro == taro2.width_micro )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function width_windowCmp(taro1,taro2)
{
	if		( taro1.width_window > taro2.width_window )
		return TargetSet.biggersign;
	else if ( taro1.width_window == taro2.width_window )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function height_windowCmp(taro1,taro2)
{
	if		( taro1.height_window > taro2.height_window )
		return TargetSet.biggersign;
	else if ( taro1.height_window == taro2.height_window )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function favorCmp(taro1,taro2)
{
	if		( taro1.favor > taro2.favor )
		return TargetSet.biggersign;
	else if ( taro1.favor == taro2.favor )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function iddefaultCmp(taro1,taro2)
{
	if		( taro1.iddefault > taro2.iddefault )
		return TargetSet.biggersign;
	else if ( taro1.iddefault == taro2.iddefault )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function lightdefaultCmp(taro1,taro2)
{
	if		( taro1.lightdefault > taro2.lightdefault )
		return TargetSet.biggersign;
	else if ( taro1.lightdefault == taro2.lightdefault )
	{
		var cmpno = this.labelCmp(taro1,taro2);
		return cmpno;
	}
	else
		return TargetSet.smallersign;
}

function z2pad(number)
{
	if ( number < 10 ) return "0" + number;
	if ( number < 100 ) return number;
	return "Error in z2pad:  " + number + "!!!  ";
}

function getFeature(gototype,sizing)
{
	var displayfield;
	var itemstr;

	if			( sizing == 'small' )		displayfield = 'width_icon';
	else 									displayfield = 'width_mini';

	if ( gototype == "new" )
		itemstr = this.getPopupAnchor(displayfield);
	else 
		itemstr = this.getAnchor(displayfield);

	return itemstr;
}

function getItemStr(gototype,displayfield)
{
	var itemstr;

	if ( displayfield == null )
		displayfield = this.iddefault;

	if ( gototype == "new" )
		itemstr = this.getPopupAnchor(displayfield);
	else 
		itemstr = this.getAnchor(displayfield);

	return itemstr;
}

function Target(label,explanation,target_uri,repimg_uri,width_mini,width_icon,width_micro,width_window,height_window,favor,iddefault)
{ // begin Menu constructor

	// argument specific properties and methods

	this.label									= label
	this.biglabel								= "<big>" + label + "</big>";
	this.smalllabel							= "<small>" + label + "</small>";
	this.smallsmalllabel				= "<small><small>" + label + "</small></small>";
	this.symbolic_name					= label.replace(/\s+/g,"_");
	this.explanation						= "<small>" + explanation + "</small>";
	this.smallexplanation				= "<small><small>" + explanation + "</small></small>";
	this.smallsmallexplanation	= "<small><small><small>" + explanation + "</small></small></small>";
	this.target_uri							= target_uri;
	this.smalltarget_uri				= "<small>" + target_uri + "</small>";
	this.smallsmalltarget_uri		= "<small><small>" + target_uri + "</small></small>";
	this.repimg_uri							= "<img src='" + repimg_uri + "'>";
	this.width_mini							= "<img src='" + repimg_uri + "' width=" + width_mini + ">";
	this.width_icon							= "<img src='" + repimg_uri + "' width=" + width_icon + ">";
	this.width_micro						= "<img src='" + repimg_uri + "' width=" + width_micro + ">";
	this.width_picro						= "<img src='" + repimg_uri + "' width=" + (width_micro / 2) + ">";
	this.width_tenht						= "<img src='" + repimg_uri + "' height=10>";
	this.width_tenbyten					= "<img src='" + repimg_uri + "' width=10 height=10>";
	this.width_window						= width_window;
	this.height_window					= height_window;
	this.favor									= favor;
	this.iddefault							= iddefault;
	this.lightdefault						= 'label';

	this.setOpenFeatures	= setOpenFeatures;
	this.setOpenFeatures(this.width_window,this.height_window);

	this.getAnchor = function(displayfield) { return "<A href='" + this.target_uri + "'>" + this[displayfield] + "</A>"; }
	this.getResizeAnchor = function(displayfield) { return "<A HREF='" + this.target_uri + "' onClick=resizeTo(" + this.width_window + "," + this.height_window + ")>" + this[displayfield] + "</A>"; }
	this.getPopupAnchor = function(displayfield)	{ return '<A onClick=putPop(window,"' + this.target_uri + '","' + this.symbolic_name + '","' + this.openfeatures + '") onMouseOver="window.status=\'' + this.label + ' link\'; return true;" onMouseOut="window.status=\'\'")>' + this[displayfield] + '</a>'; }

	this.getFeature			= getFeature;
	this.getItemStr			= getItemStr;

}	// end Target constructor

////////////////////////////////////////////////////////////////////////////

function listUL()
{
	this.beginList = function(n) { return "<UL>"; }
	this.paintitem = function(item) { return "<LI>" + item + "</LI>"; }
	this.endList = function() { return "</UL>"; }
}

function listOL(digitype)
{
	this.beginList = function(n) { return "<OL align=left type=" + '"' + digitype + '"' + ">"; }
	this.paintitem = function(item) { return "<LI>" + item + "</LI>"; }
	this.endList = function() { return "</OL>"; }
}

function listlingbat()
{
	var dingbat = "<img src='http://www.eskimo.com/~xeno/Nose06.png' width=32>";
	this.beginList = function(n) { return "<DL>"; }
	this.paintitem = function(item) { return "<DT>" + dingbat + "</DT><DD>" + item + "</DD>"; }
	this.endList = function() { return "</DL>"; }
}

function listbunch()
{
	this.beginList = function(n) { return "&nbsp;"; }
	this.paintitem = function(item) { return "&nbsp;" + item + "&nbsp;"; }
	this.endList = function() { return "&nbsp;"; }
}

function list_micro()
{
	this.beginList = function(n) { return "<DL>"; }
	this.paintitem = function(item,micro_dingbat) { return "<DT>" + micro_dingbat + "</DT><DD>" + item + "</DD>"; }
	this.endList = function() { return "</DL>"; }
}

function list_picro()
{
	this.beginList = function(n) { return "<DL>"; }
	this.paintitem = function(item,picro_dingbat) { return "<DT>" + picro_dingbat + "</DT><DD>" + item + "</DD>"; }
	this.endList = function() { return "</DL>"; }
}

function listCOLUMN(border)
{
	this.beginList = function(n) { if (border ) return "<TABLE border>"; else return "<TABLE>";  }
	this.paintitem = function(item) { return "<TR><TD>" + item + "</TD></TR>"; }
	this.endList = function() { return "</TABLE>"; }
}

function listROW(border)
{
	this.beginList = function(n) { if (border ) return "<TABLE border><TR>"; else return "<TABLE><TR>";  }
	this.paintitem = function(item) { return "<TD>" + item + "</TD>"; }
	this.endList = function() { return "</TR></TABLE>"; }
}

function listTABLE(border,columns)
{
	this.beginList =
		function(n)
		{
			this.CLength = Math.ceil( n / columns );
			this.RCount = 0;
			if (border)	return "<TABLE border><TR>";
			else		return "<TABLE><TR>";
		}

	this.beginColumn = function() { if (border) return "<TD><TABLE border><TR>"; else return "<TD><TABLE>";  }
	this.paintitemcell = function(item) {  this.RCount++;  return "<TR><TD>" + item + "</TD></TR>";  }
	this.endColumn = function() {  this.RCount = 0;  return "</TABLE></TD>"; }

	this.paintitem =
		function(item)
		{
			var buffer;
			var code;
			if ( this.RCount == 0 )
				code = this.beginColumn();
			else
				code = "";
			buffer = this.paintitemcell(item);
			code += buffer;
			if ( this.RCount >= this.CLength )
			{
				buffer = this.endColumn();
				code += buffer;
			}
			return code;
		}

	this.endList =
		function()
		{
			var code;
			if ( this.RCount != 0 )	code = this.endColumn();
			else				code = "";
			return code + "</TR></TABLE>";
		}
}

function displayDefault(item)
{
	this.beginList = function(n) { return "<P>"; }
	this.paintitem = function(item) { return item; }
	this.endList = function() { return "</P>"; }
}

function Push(object)
{
	this.ItemList.push(object);
}

function paintItem(index,displayfield)
{
	var itemstr = this.ItemList[index].getItemStr(this.gototype,displayfield);
	document.writeln(itemstr + "<br>");
}

function getCfgAnchor()
{
	var window_name = "Cfg_" + this.symbolic_name;
	var openfeatures = "width=919,height=545,resizeable=no,scrollbars=no,location=no,menubar=no,toolbar=no";
	var acode = '<A onClick=putPopCfg("' + window_name +  '","' + openfeatures + '") onMouseOver="window.status=\'' + this.label_text +
				' Configuration link\'; return true;" onMOuseOut="window.status=\'\'")>' + this.cfg_dingbat + "</A>";
	return acode;
}

function getHeadingAnchor(heading_text)
{
	var acode = '<A onClick=putPopMenu(window,"' + this.symbolic_name +  '","' +
				this.openfeatures + '") onMouseOver="window.status=\'' + this.label_text +
				' Menu link\'; return true;" onMOuseOut="window.status=\'\'")>' + heading_text + "</A>";
	return acode;
}

function getHelpAnchor()
{
	var window_name = "Help_" + this.symbolic_name;
	var openfeatures = "width=777,height=707,resizeable=no,scrollbars=no,location=no,menubar=no,toolbar=no";
	var acode = '<A onClick=putPopHelp(window,"' + window_name +  '","' +
				openfeatures + '") onMouseOver="window.status=\'' + this.label_text +
				' Help link\'; return true;" onMOuseOut="window.status=\'\'")>' + this.help_dingbat + "</A>";
	return acode;
}

function parseDisplay(classdisplayfield,index,basesize)
//	needs explanation
{
	var displayfield;

	if			( classdisplayfield == "iddefault" )
		displayfield = this.ItemList[index].iddefault // fix this POS
	else if		( classdisplayfield == "lightdefault" )
		displayfield = this.ItemList[index].lightdefault // fix this POS
	else
		displayfield = classdisplayfield;

	displayfield = adjustSize(displayfield,basesize);

	var itemstr;
	itemstr = this.ItemList[index].getItemStr(this.gototype,displayfield);

	return itemstr;
}

function middlestartcalculation(middlen,listlength)
{
	var n;
	n = floor( ( listlength - middlen ) / 2 );
	return n;
}

function loopstart()
{
	var n;
	switch(this.listsubset)
	{
		case 'middle6':
							n = middlestartcalculation(6,this.ItemList.length);
							return n;
		case 'bottom4':		return ( this.ItemList.length - ( 4 + 1 ) );
		default:			return 0;
	}
}

function loopstop()
{
	switch(this.listsubset)
	{
		case 'first':		return 1;
		case 'top3':		return 3;
		case 'top5':		return 5;
		case 'middle6':		
							n = middlestartcalculation(6,this.ItemList.length);
							return n + 6;
		default:			return this.ItemList.length;
	}
}

function getMenuItems(doco,basesize)
{
	var code;
	code = this[this.listtype].beginList(this.ItemList.length);

	this.SetSortDirection();
	this.ItemList.sort(this[this.sortfield]);

	var buffer;
	var itemstr_1;
	var itemstr_2;
	var itemstr;

	var begloop = this.loopstart();
	var endloop = this.loopstop();
	for( var index = begloop; index < endloop;  index++ )
	{
		itemstr_1 = this.parseDisplay(this.displayfield_1,index,basesize);
		
		if ( this.displayfield_2 == 'nothing' )
			itemstr = itemstr_1;
		else
		{
			itemstr_2 = this.parseDisplay(this.displayfield_2,index,basesize);
			itemstr = itemstr_1 + "<br>" + itemstr_2;
		}
		if		( this.listtype == 'micro' )
		{
			buffer = this[this.listtype].paintitem(itemstr,this.ItemList[index].width_micro);
		}
		else if ( this.listtype == 'picro' )
			buffer = this[this.listtype].paintitem(itemstr,this.ItemList[index].width_picro);
		else
			buffer = this[this.listtype].paintitem(itemstr);

		code = code + buffer;
	}
	buffer = this[this.listtype].endList();
	code = code + buffer;
	return code;
}

function paintHeadingAnchor(doco,heading)
{
	var menuHdr = this.getHeadingAnchor(heading);
	doco.writeln(menuHdr);
}

function paintMenu(doco)
{
	var menuCfg = this.getCfgAnchor();
	var menuHdr = this.getHeadingAnchor(this.label_text);
	var menuHelp = this.getHelpAnchor();
	if ( MainMenuCfg.sizing == 'big' )		heading_index = 2;
	if ( MainMenuCfg.sizing == 'regular' )	heading_index = 3;
	if ( MainMenuCfg.sizing == 'small' )	heading_index = 4;
	
	doco.writeln("<H" + heading_index + " align=center>" + menuHelp + "&nbsp;" + menuHdr + "&nbsp;" + menuCfg + "</H" + heading_index + ">");

	var menucode;
	menucode = this.getMenuItems(doco,"main");
	doco.writeln(menucode);
}

function putPopCfg(window_name,openfeatures)
{
	var newwin = window.open("", window_name, openfeatures);
	newwin.focus(1);
	var doco = newwin.document;
	var heading = window_name.replace(/_/g," ");
	heading = heading.replace(/Cfg/g,"Configuration for");
	var cfg_parent_name = window_name.replace(/Cfg_/g,"");
	doco.writeln("<html><head>\n<title>\n" + heading + "\n</title>");
	doco.writeln('<STYLE src="Menus.css"> </STYLE>');
	doco.writeln('<STYLE> table { font-size: 80% } </STYLE>');
	doco.writeln('<SCRIPT src="Perio.js"> </SCRIPT>');
	doco.writeln('<SCRIPT>var error_count = 0;  self.onerror = Menus_show_error; </SCRIPT>');
	doco.writeln('<SCRIPT src="menuobjects.js"> </SCRIPT>');
	doco.writeln("</head>\n");
	doco.writeln("<html>\n<body class=" + cfg_parent_name + ">\n");

	doco.writeln("<H2>" + heading + " Target Set Menus</H2>");

	var cfgmenucode;
	if ( window_name == 'Cfg_MainMenu' )	cfgmenucode = getMainMenuCfgMenu();
	else									cfgmenucode = self[cfg_parent_name].getTargetSetCfgMenu();
	doco.writeln(cfgmenucode);
	
	doco.writeln("</body>\n</html>");
	doco.close();
}

function putPopMenu(wino,window_name,openfeatures)
{
	var newwin = wino.open("", window_name, openfeatures);
	newwin.focus(1);
	var doco = newwin.document;
	doco.writeln("<html><head>\n<title>\n" + self[window_name].label_text + "\n</title>");
	doco.writeln('<STYLE src="Menus.css"> </STYLE>');
	doco.writeln('<SCRIPT src="Perio.js"> </SCRIPT>');
	doco.writeln('<SCRIPT>var error_count = 0;  self.onerror = Menus_show_error; </SCRIPT>');
	doco.writeln('<SCRIPT src="menuobjects.js"> </SCRIPT>');
	doco.writeln("</head>\n");
	doco.writeln("<html>\n<body class=" + window_name + ">\n");

	var menuCfg = self[window_name].getCfgAnchor();
	var menuHelp = self[window_name].getHelpAnchor();
	doco.writeln("<IMG src='" + self[window_name].menu_repimg_uri + "' width=" + self[window_name].menu_repimg_width + ">");
	doco.writeln("<H1>" + self[window_name].label_text + menuHelp + "&nbsp;" + menuCfg + "</H1>");
	doco.writeln("<H3>" + self[window_name].explanation_text + "&nbsp" + "</H3>");

	var menucode;
	menucode = self[window_name].getMenuItems(doco,"popup");
	doco.writeln(menucode);
	
	doco.writeln("</body>\n</html>");
	doco.close();
}

function putPopHelp(wino,window_name,openfeatures)
{
	var newwin = wino.open("", window_name, openfeatures);
	var doco = newwin.document;
	var heading = window_name.replace(/_/g," ");
	doco.writeln("<html><head>\n<title>\n" + heading + "\n</title>");
	doco.writeln('<STYLE src="Menus.css"> </STYLE>');
	doco.writeln('<SCRIPT src="Perio.js"> </SCRIPT>');
	doco.writeln('<SCRIPT>var error_count = 0;  self.onerror = Menus_show_error; </SCRIPT>');
	doco.writeln('<SCRIPT src="menuobjects.js"> </SCRIPT>');
	doco.writeln('<SCRIPT src="' + window_name + '_help.js"> </SCRIPT>');
	doco.writeln("</head>\n");
	var parent = window_name.replace(/Cfg_/g,"");
	doco.writeln("<html>\n<body class=" + parent + ">\n");

	doco.writeln("<H1>" + heading + "</H1>");

	var helptext;
//	helptext = self[window_name].getHelp(doco,"big");
	helptext = "Prototype blank";
	doco.writeln(helptext);
	
	doco.writeln("</body>\n</html>");
	doco.close();
}

function getRandomIndex()
{
	var rpct = Math.random();
	var length =this.ItemList.length;
	var index = Math.round( ( length - 1 ) * rpct );
	return index;
}

function getLabelIndex(label)
{
	var index;

	for(index = 0;  index < this.ItemList.length;  ++index)
	{
		if ( this.ItemList[index].label == label ) return index;
	}
	return -1;
}

function getTimeSequenceIndex(stype)
{
	var base = 0;
	var lNow = new Date();
	switch(stype)
	{
		case 'monthly':			base = lNow.getMonth();		break;
		case 'monthdaily':	base = lNow.getDate();		break;
		case 'weekdaily':		base = lNow.getDay();			break;
		case 'hourly':			base = lNow.getHours();		break;
		case 'minutely':		base = lNow.getMinutes();	break;
		case 'secondly':		base = lNow.getSeconds();	break;
	}
	var index = base % this.ItemList.length;
	return index;
}

function dateTimeHeading(selectiontype,category,sizing)
{
	var mhdr_size = 4;
	if ( sizing == 'big' ) mhdr_size--
	if ( sizing == 'small' ) mhdr_size++;
	var tophdr_prefix = "<H" + mhdr_size + " ALIGN='CENTER'>" + category + " of ";
	var subt = "\n<H6 align='center'>(by your workstation clock)</H6>\n";

	lNow = new Date();
	lMM = lNow.getMonth();
	lMCDY = lNow.getFullYear();

	switch(selectiontype)
	{
		case 'index':
		case 'label':
		case 'random':
			tophdr_prefix = "<H" + mhdr_size + " ALIGN='CENTER'>" + category + ", ";
			return tophdr_prefix + DOWName[lDOW] + " " + MonthName[lMM] + " " + lDOM + ", " + lMCDY + "</H" + mhdr_size + ">" + subt;
		case 'monthly':
			return tophdr_prefix + MonthName[lMM] + " " + lMCDY + "</H" + mhdr_size + ">" + subt;
		case 'monthdaily':
		case 'weekdaily':
			lDOM = lNow.getDate();
			lDOW = lNow.getDay();
			return tophdr_prefix + DOWName[lDOW] + " " + MonthName[lMM] + " " + lDOM + ", " + lMCDY + "</H" + mhdr_size + ">" + subt;
		case 'hourly':
			lDOM = lNow.getDate();
			lDOW = lNow.getDay();
			lHOD = lNow.getHours();
			loHOD = lHOD + 1;
			if		( loHOD == 1 || loHOD == 21 )	ordsuffix = "st";
			else if ( loHOD == 2 || loHOD == 22 )	ordsuffix = "nd";
			else if ( loHOD == 3 || loHOD == 23 )	ordsuffix = "rd";
			else									ordsuffix = "th";
			tophdr_prefix = "<H" + mhdr_size + " ALIGN='CENTER'>" + category + " for the ";
			return tophdr_prefix + loHOD + ordsuffix + " hour of " + DOWName[lDOW] + " " + MonthName[lMM] + " " + lDOM + ", " + lMCDY + "</H" + mhdr_size + ">" + subt;
		case 'minutely':
			lDOM = lNow.getDate();
			lDOW = lNow.getDay();
			lHOD = lNow.getHours();
			lhh = z2pad(lHOD);
			lMOH = lNow.getMinutes();
			lmm = z2pad(lMOH);
			return tophdr_prefix + lhh + ":" + lmm + " " + DOWName[lDOW] + " " + MonthName[lMM] + " " + lDOM + ", " + lMCDY + "</H" + mhdr_size + ">" + subt;
		case 'secondly':
			lDOM = lNow.getDate();
			lDOW = lNow.getDay();
			lHOD = lNow.getHours();
			lhh = z2pad(lHOD);
			lMOH = lNow.getMinutes();
			lmm = z2pad(lMOH);
			lSOM = lNow.getSeconds();
			lss = z2pad(lSOM);
			return tophdr_prefix + lhh + ":" + lmm + ":" + lss + " " + DOWName[lDOW] + " " + MonthName[lMM] + " " + lDOM + ", " + lMCDY + "</H" + mhdr_size + ">" + subt;
	} 
}

//
// selection:  index, random, dailysequence, hourlysequence, minutelysequence
//
function featureTarget(selectiontype,category,sizing,indexdata)
{
	var index;
	var code = dateTimeHeading(selectiontype,category,sizing);

	switch(selectiontype)
	{
		case 'index':			index = indexdata;									break;
		case 'label':			index = this.getLabelIndex(indexdata);				break;
		case 'random':		index = this.getRandomIndex();						break;
		default:					index = this.getTimeSequenceIndex(selectiontype);	break;
	}
	self.some_global =	index;
	this.SetSortDirection();
	this.ItemList.sort(this.label);
	code += this.ItemList[index].getFeature(this.gototype,sizing);
	return code;
}

function paintSelectPulldown(doco,selectname,selected_index)
{
	var menuCfg = this.getCfgAnchor();
	var menuHdr = this.getHeadingAnchor(this.label_text);
	var menuHelp = this.getHelpAnchor();
	if ( MainMenuCfg.sizing == 'big' )		heading_index = 2;
	if ( MainMenuCfg.sizing == 'regular' )	heading_index = 3;
	if ( MainMenuCfg.sizing == 'small' )	heading_index = 4;
	
	doco.writeln("<H" + heading_index + " align=center>" + menuHelp + "&nbsp;" + menuHdr + "&nbsp;" + menuCfg + "</H" + heading_index + ">");

	var menucode;

	this.ItemList.sort(this.label);

	var buffer;

	doco.writeln('<SELECT>');

	for( var index = 0; index < this.ItemList.length;  index++ )
	{
		if ( index == selected_index )
			doco.writeln('<OPTION onClick=putPop(window,"' + this.ItemList[index].target_uri + '","' + this.ItemList[index].symbolic_name + '","' + this.ItemList[index].openfeatures + '") SELECTED>' + this.ItemList[index].label + '</OPTION>');
		else
			doco.writeln('<OPTION onClick=putPop(window,"' + this.ItemList[index].target_uri + '","' + this.ItemList[index].symbolic_name + '","' + this.ItemList[index].openfeatures + '")>' + this.ItemList[index].label + '</OPTION>');
	}
	doco.writeln("</SELECT>");
}

function TargetSet(label_text,explanation_text,menu_repimg_uri,menu_repimg_width,window_width,window_height,listtype,displayfield,sortfield,sortorder)
{
	// begin TargetSet argument assignments:

	this.label_text			= label_text;
	this.symbolic_name		= label_text.replace(/\s+/g,"_");
	this.explanation_text	= explanation_text;
	this.menu_repimg_uri	= menu_repimg_uri;
	this.menu_repimg_width	= menu_repimg_width;
	this.window_width		= window_width;
	this.window_height		= window_height;
	this.listtype			= listtype;		// Includes:
											// UL, OL with various numerations, lingbat, micron, picron
											// rows, columns, tables, freebunches
	this.displayfield_1		= displayfield; // default, label, biglabel, smalllabel, explanation, smallexplanation, repimg_full, repimg_mini,
											// repimg_icon, repimg_micro, repimg_picro, blank
											// listtype, displayfield, sortfield, sortorder
	this.displayfield_2		= 'nothing';	// Usually "nothing", but this may be configured to display any of the things in the primary
											// displayfield.
	this.sortfield			= sortfield;	// label, explanation, target_uri, repimg_uri,
											// width_mini, width_icon, width_micro, width_window,
											// height_window, favor, iddefault
	this.sortorder			= sortorder;	// ascending, descending

	this.gototype			= 'new';		// "new" is to popup a new window.  "same" is for
											// special browser needs or preferences.
	this.cfgtarget			= 'both';		// "both" windows are popped up and changed with most of the configuration changes.
											//
	this.listsubset			= 'alltargets';	// 'alltargets','first','top3','top5','middle6','bottom4'
											//
	this.cfg_dingbat		= "<small><small>&deg;</small></small>"
	this.help_dingbat		= "<small><small>&cent;</small></small>"

	// end TargetSet argument assignments:

	this.ItemList			= new Array();

	// begin TargetSet methods assignments:

	this.getCfgAnchor			= getCfgAnchor;
	this.getHeadingAnchor		= getHeadingAnchor;
	this.getHelpAnchor			= getHelpAnchor;
	this.getMenuItems			= getMenuItems;
	this.getTargetSetCfgMenu	= getTargetSetCfgMenu;
	this.loopstart				= loopstart;
	this.loopstop				= loopstop;
	this.paintHeadingAnchor		= paintHeadingAnchor;
	this.paintItem				= paintItem;
	this.paintMenu				= paintMenu;
	this.putPopMenu				= putPopMenu;

	this.UL			= new listUL;
	this.OL			= new listOL("1");
	this.OLa		= new listOL("a");
	this.OLA		= new listOL("A");
	this.OLi		= new listOL("i");
	this.OLI		= new listOL("I");
	this.lingbat	= new listlingbat();
	this.micro		= new list_micro();
	this.picro		= new list_picro();
	this.ROW		= new listROW(false);
	this.ROWb		= new listROW(true);
	this.COLUMN		= new listCOLUMN(false);
	this.COLUMNb	= new listCOLUMN(true);
	this.TABLE2		= new listTABLE(false,2);
	this.TABLE2b	= new listTABLE(true,2);
	this.TABLE3		= new listTABLE(false,3);
	this.TABLE3b	= new listTABLE(true,3);
	this.TABLE4		= new listTABLE(false,4);
	this.TABLE4b	= new listTABLE(true,4);
	this.bunch		= new listbunch;

	this.label								= labelCmp;
	this.explanation						= explanationCmp;
	this.target_uri							= target_uriCmp;
	this.repimg_uri							= repimg_uriCmp;
	this.width_mini							= width_miniCmp;
	this.width_icon							= width_iconCmp;
	this.width_micro						= width_microCmp;
	this.width_window						= width_windowCmp;
	this.height_window						= height_windowCmp;
	this.favor								= favorCmp;
	this.iddefault							= iddefaultCmp;
	this.lightdefault						= lightdefaultCmp;

	this.parseDisplay						= parseDisplay;
	this.featureTarget						= featureTarget;
	this.paintSelectPulldown				= paintSelectPulldown;

	this.getLabelIndex						= getLabelIndex;
	this.getRandomIndex						= getRandomIndex;
	this.getTimeSequenceIndex				= getTimeSequenceIndex;

	this.Push								= Push;

	this.SetSortDirection					= SetSortDirection;
	this.setOpenFeatures					= setOpenFeatures;
	this.setOpenFeatures(this.window_width,this.window_height);
	// end TargetSet methods assignments:
}

////////////////////////////////////////////////////////////////////////////

function putMainPageBody(doco,alfacolumns)
{
	function putMenuCell(doco,tso)
	{
		doco.writeln('<TR><TD class=' + tso.symbolic_name + '>');
		tso.paintMenu(doco);
		doco.writeln('</TD></TR>');
	}

	function putFeatureCell(doco,tso,selectiontype,category,indexdata)
	{
		doco.writeln('<TR><TD class=' + tso.symbolic_name + '>');
		var sizing = MainMenuCfg.sizing;
		var code = tso.featureTarget(selectiontype,category,sizing,indexdata);
		doco.writeln(code);
		doco.writeln('</TD></TR>');
	}

	function putSelectCell(doco,tso)
	{
		doco.writeln('<TR><TD valign=center align=center class=' + tso.symbolic_name + '>');
		tso.paintSelectPulldown(doco,0)
		doco.writeln('</TD></TR>');
	}

	function putTimeNote(doco)
	{
		var lNow;
		doco.writeln("<TD align=center colspan=3>");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("<small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("<small><small>");
		doco.writeln("<small>Page was loaded at workstation time and date:");
		lNow = Date();
		doco.write(lNow);
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("</small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("</small></small>");
		doco.writeln("</small>\n</TD>");
	}

	function putSiteHeading(doco)
	{
		var lftImgWidth = 96;
		var rtImgWidth = 128;
		if ( MainMenuCfg.sizing == 'big' ) { heading_index = 2;  lftImgWidth = lftImgWidth * 2;  rtImgWidth = rtImgWidth * 2; }
		if ( MainMenuCfg.sizing == 'regular' ) heading_index = 3;
		if ( MainMenuCfg.sizing == 'small' ) { heading_index = 4;  lftImgWidth = lftImgWidth / 2;  rtImgWidth = rtImgWidth / 2; }
		doco.writeln("<TD><A HREF='KerryVsIdiot.html'>\n<IMG src='http://truthout.org/imgs.art_01/3.kerry.bush.D1.jpg' width=" + lftImgWidth + ">\n</A></TD>\n");
		doco.writeln("<TD align=left>\n");
		//Aggregate.paintHeadingAnchor(doco,"<H" + heading_index + " align=center>Health Before Growth, Community Before Trade!</H" + heading_index + ">");
		//Aggregate.paintHeadingAnchor(doco,
//"<H" + heading_index + " style=line-height: 0pt; align=left>Pride before Justice equals Destabilization</H" + heading_index + ">" +
//"<H" + heading_index + " style=line-height: 200pt; align=left>Power before Truth equals Destruction</H" + heading_index + ">" +
//"<H" + heading_index + " style=line-height: 0pt; align=left>Profit before Environment equals Death</H" + heading_index + ">"
//			);
		Aggregate.paintHeadingAnchor(doco,
"<H" + heading_index + " align=left>Pride before Justice equals Destabilization<BR>" +
"Power before Truth equals Destruction<BR>" +
"Profit before Environment equals Death</H" + heading_index + ">"
			);
		doco.writeln("</font>\n</TD>");
		doco.writeln("<TD><A HREF='http://www.eskimo.com/~xeno/dogsnmap.html'><IMG src='dogsnmap.jpg' width=" + rtImgWidth + "></A></TD>\n");
	}

	function putSiteSubHeading(doco)
	{
		doco.writeln("<TD>\n");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("<small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("<small><small>");
		doco.writeln("<small><A href=http://www.eskimo.com/~xeno/indexHelp.html target='_new'>&cent; Help</A></small>");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("</small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("</small></small>");
		doco.writeln("</TD>\n<TD align=center>");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("<small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("<small><small>");
		doco.writeln("<small>Xeno Campanoli's");
		doco.writeln('<a href="http://www.eskimo.com/~xeno/cgi-bin/accessreport.cgi" name="popupaccessreport" onMouseOver="window.status=\'Pop Up Access Report\'; return true;" onMouseOut="window.status=\'\'; return false;">Web Site</a>,');
		doco.writeln("Hosted under EskimoNorth (<a href='http://www.eskimo.com' name='eskimo' target='_new'>http://www.eskimo.com</a>),");
		doco.writeln(" a Linux friendly ISP.");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("</small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("</small></small>");
		doco.writeln("</small>\n</TD>");
		var openfeatures = "width=404,height=202,resizeable=no,scrollbars=no,location=no,menubar=no,toolbar=no";
		doco.writeln("<TD align=right>");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("<small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("<small><small>");
		doco.writeln("<small><A onClick=putPopCfg('Cfg_MainMenu','" + openfeatures + "')>Configurations &deg;</A></small>");
		if ( MainMenuCfg.sizing == 'regular' ) doco.write("</small>");
		if ( MainMenuCfg.sizing == 'small' ) doco.write("</small></small>");
		doco.writeln("</TD>");
	}

	function putRedMenuSet(doco)
	{
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,New_Today);
		putMenuCell(doco,Blogs_I_Like);
		putMenuCell(doco,Politics);
		Daily_Image.listsubset = 'top3';
		putMenuCell(doco,Daily_Image);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
	}

	function putBlackMenuSet(doco)
	{
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putFeatureCell(doco,Sponsor,'monthdaily','Sponsor');
		putMenuCell(doco,Software);
		putFeatureCell(doco,Sponsor,'secondly','Sponsor');
		putMenuCell(doco,Trucking);
		putFeatureCell(doco,Sponsor,'hourly','Sponsor');
		putMenuCell(doco,Inspirations);
		putSelectCell(doco,Sponsor);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
	}

	function putBlueMenuSet(doco)
	{
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,Houses);
		putMenuCell(doco,MySoft);
		putMenuCell(doco,Writings);
		putMenuCell(doco,My_Info);
		putMenuCell(doco,Travels);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
	}

	function putGreenMenuSet(doco)
	{
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,General_References);
		putMenuCell(doco,Worldwide_References);
		putMenuCell(doco,Local_References);
		putMenuCell(doco,General_Publishing);
		putMenuCell(doco,Local_Publishing);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
	}

	function putAlfaSortMenuSet(doco)
	{
		doco.writeln("<TD bgcolor=yellow valign=top>");
		var tmp_listtype = Aggregate.listtype;
		Aggregate.listtype = 'COLUMN';
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,Aggregate);
		Aggregate.listtype = tmp_listtype;
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,Blogs_I_Like);
		putMenuCell(doco,Daily_Image);
		putMenuCell(doco,Inspirations);
		putMenuCell(doco,General_Publishing);
		putMenuCell(doco,General_References);
		putMenuCell(doco,Houses);
		putMenuCell(doco,Local_Publishing);
		putMenuCell(doco,Local_References);
		putMenuCell(doco,MySoft);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putMenuCell(doco,New_Today);
		putMenuCell(doco,Politics);
		putMenuCell(doco,Software);
		putSelectCell(doco,Sponsor);
		putFeatureCell(doco,Sponsor,'hourly','Sponsor');
		putFeatureCell(doco,Sponsor,'monthdaily','Sponsor');
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
		doco.writeln("<TD bgcolor=yellow valign=top>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
		putFeatureCell(doco,Sponsor,'secondly','Sponsor');
		putMenuCell(doco,Travels);
		putMenuCell(doco,Trucking);
		putMenuCell(doco,My_Info);
		putMenuCell(doco,Worldwide_References);
		putMenuCell(doco,Writings);
		doco.writeln("</TABLE>");
		doco.writeln("</TD>");
	}

	doco.writeln("<CENTER>");
	if ( MainMenuCfg.heading == 'allheadings' || MainMenuCfg.heading == 'nobrowserheadings' )
	{
		if ( MainMenuCfg.sizing == 'big' )		doco.writeln("<TABLE cellpadding=8 cellspacing=8>\n<TR>");
		if ( MainMenuCfg.sizing == 'regular' )	doco.writeln("<TABLE cellpadding=4 cellspacing=4>\n<TR>");
		if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
		putTimeNote(doco);
		doco.writeln("</TR>\n<TR>");
		putSiteHeading(doco);
		doco.writeln("</TR>\n<TR>");
		putSiteSubHeading(doco);
		doco.writeln("</TR>\n</TABLE>");
	}
	if ( MainMenuCfg.sizing == 'small' )	doco.writeln("<TABLE cellpadding=0 cellspacing=0>\n<TR>");
	else									doco.writeln("<TABLE cellpadding=1 cellspacing=1>\n<TR>");
	switch( MainMenuCfg.layout )
	{
		case 'aggregate':
			var tmp_listtype = Aggregate.listtype;
			Aggregate.listtype = 'TABLE4b';
			putMenuCell(doco,Aggregate);
			Aggregate.listtype = tmp_listtype;
			break;
		case 'alphabetical':
			putAlfaSortMenuSet(doco);
			break;
		case 'color':
			putRedMenuSet(doco);
			putBlackMenuSet(doco);
			putBlueMenuSet(doco);
			putGreenMenuSet(doco);
			break;
	}
	doco.writeln("</TR>\n</TABLE>");
	doco.writeln("</CENTER>");
}

function putMainPage(wino)
{
	var height;
	var width;
	switch( MainMenuCfg.sizing )
	{
		case 'big':
			width=1221;	height=717;
			break;
		case 'regular':
			width=909;	height=717;
			break;
		case 'small':
			width=595;	height=767;
			break;
	}
	var headingsettings;
	if ( MainMenuCfg.heading == 'noheadings' || MainMenuCfg.heading == 'nobrowserheadings' )	headingsettings = "location=no,menubar=no,toolbar=no";
	else																						headingsettings = "location=yes,menubar=yes,toolbar=yes";
	var openfeatures = "width=" + width + ",height=" + height + ",resizeable=yes,scrollbars=yes," + headingsettings;
	var newwin = wino.open("", 'MainMenu', openfeatures);
	newwin.focus(1);
	newwin.resizeTo(width,height);
	var doco = newwin.document;
	doco.writeln("<html>\n<head>\n<title>MainMenu</title>");
	doco.writeln('<STYLE src="Menus.css"> </STYLE>');
	doco.writeln('<SCRIPT src="Handlers.js"> </SCRIPT>');
	doco.writeln('<SCRIPT>var error_count = 0; self.onerror = std_show_error; </SCRIPT>');
	doco.writeln('<SCRIPT src="Perio.js"> </SCRIPT>');
	doco.writeln('<SCRIPT src="menuobjects.js"> </SCRIPT>');
	doco.writeln("</head>\n");
	doco.writeln("<BODY bgcolor=yellow link=navy vlink=purple alink=darkbrown text=black>\n");

	putMainPageBody(doco,false);

	doco.writeln("</body>\n</html>");
	doco.close();
}

//
//	End of Perio.js
