<!--
/*   GENERAL DISCUSSION OF THIS JAVASCRIPT
This script file, cfscript.js, contains three different functions that are called by most every page.  They perform actions that generate portions of each page by using the document.write commands to generate dynamic HTML content as each page is loaded.  This allows the basic "skeleton" of the websites to be modifed and controlled in these three scripts. Changing something in any of these scripts changes every page on the site.  It also provides a way to automatically hilite the left-hand menu entry for the page currently being viewed so that the user can see exactly where he/She is in the menu.

The three javascript functions are 

-  topgen: which generates the outer containing HTML Table structure.  Yes, this basic design was done long before the use of CSS for page structure, so the antiquated "Table" structure for layouts is still present here. The topgen call also any of three graphics at the top of the left column.

-  menugen: this generates the left hand menu entries that correspond to the site pages and it hilights the entry for the page that is currently being displayed.

-  bottomgen:  this closes out the Table structure opened by topgen, and lists the copyright line at the bottom of each page.

Essentially every page at the site contains and does the following:
 1) Calls topgen to create the overall page  structure using HTML "Table" formatting (the old way, but effective for our purposes).
 2) Calls menugen which builds the menu along the left side of the page.
 3) Adds its own unique content (the right side main content of the page) as normal HTML statements located in the calling file itself.
 4) Calls bottomgen to close out the Tables  and complete the HTML page for display by the browser.


See the detailed comments in the code below to gain an understanding of each of the three javascript functions and also see representative samples of the code that they will cause to be generated.

*/
// SPECIFIC FUNCTION DESCRIPTIONS
//
//////////////////////  topgen FUNCTION DESCRIPTION
// topgen generates the overall table structure and inserts the images at the top of the left-hand column.
// TABLE1 is essentially just a Table inside of TABLE0, but is needed to overcome the peculiarities of some browser versions.
// Inside TABLE1 are two columns- the left column is for the menu and will be generated by a call on menugen in each page. The right-hand column will contain the actual unique page HTML content of whatever page is doing the calling.
//
function topgen(logo,dir){
//  the logo argument is a flag to control whether the large femtransa.jpg logo of the abstract "shield"  is to be displayed in the left menu, in between the two smaller all-text graphics. Currently the shield is only shown on a few of the pages, including the home page.
//  dir is an optional directory location, and given if the  images are stored in some alternate location and are not in the same directory as the calling file.
if(!dir)dir=''; //if there is no dir argument to an alternate image directory, default to the same directory as this file is in
document.write('<TABLE 0 width="760" bordercolor="#000000" border="0" cellpadding="0" cellspacing="0"><TBODY><TR 1><TH valign="top">');
document.write('<TABLE 1 width="100%" bordercolor="#000000" border="0" cellpadding="10" cellspacing="0"><TBODY><TR 1><TH valign="top" width="168">');
document.write('<div class="bb"><IMG SRC="'+dir+'clubfem.jpg" width="163" height="126"> ');
if(logo=='logo'){document.write('<IMG SRC="'+dir+'femtransa.jpg" width="163" height="195"> ')}
document.write('<IMG SRC="'+dir+'fem.jpg" width="163" height="71"></div>');
} // end of topgen function
//
/* Here is a sample of typical generated code that a call to topgen('logo') will create.  Note that this includes the overall table-inside-a-table container for the webpage, plust the top of the lefthand column containing the three images.  A call to "menugen" will be used next to remainder of the left-column- the actual clickable menu links to the various site content.

<table 0 border="0" bordercolor="#000000" cellpadding="0" cellspacing="0" width="760"><tr 1><th valign="top">
<table 1 border="0" bordercolor="#000000" cellpadding="10" cellspacing="0" width="100%"><tr 1><th valign="top" width="168">
<div class="bb"><img src="clubfem.jpg" height="126" width="163">
<img src="femtransa.jpg" height="195" width="163">
<img src="fem.jpg" height="71" width="163"></div>

*/
//////////////////////  menugen FUNCTION DESCRIPTION
// menugen generates the remainder of the left-hand column menu: the actual clickable links for the various site pages.
/*
Menugen uses two arrays that drive the menu generation, one contains the file names (e.g home.htm) and the other the visible link name (e.g 'Home') that will be used to build the clickable menu in the left hand column.

The entries are built by processing each array entry pair and writing the corresponding menu entry.  The ability exists to insert separators and spaces in between menu items and also to highlight the current pages entry by using a different CSS class for the entry of the file/page  currently being displayed.

If you want to modify the menu just add/remove/change a pair of entries in the menuurl and menuname arrays. 

The ability to add special "submenu entries" also exists.  This feature will add an additional specific entry under one of the main entries.  Currently this is used only in user profile pages and the "reading Room" selections so that a hilighted entry will appear in the left-hand menu that matches the user name of the profile of the person being generated/viewed or the title of the article in the Reading Room.  This capability is produced by the page that calls menugen calling with an argument of the form:  menugen('Main Entry:Sub Entry')  which will add a hilighted "Sub Entry" immediately under the Main Entry in the menu list.  

For example, in the file d_subbyjoe.htm which is subby joe's personal profile, there will be a call to menugen('Member Profiles:subby joe') which will generate a non-hilited "Member Profiles" entry and a hilited "subby joe" entry immediately below it.
*/

function menugen(menume,dir){
if(!dir)dir='';
submenu=null;
if(!menume)menume=document.title;
if(menume.indexOf(':')>=0){  // this is seeing if this was a special subentry call.
s=menume.indexOf(':');  
submenu=menume.slice(s+1); // split the argument into its main and subentry portions for use below
menume=menume.slice(0,s);
}
document.write('&nbsp;'); // force a blank line
notmea='<div class="menut"><A HREF="'+dir;  // notmea, b and c are used to surround all the non-hilited CSS  menu items of other files than the caller
notmeb='"> ';
notmec=' </a></div>';
mea='<div class="menume">'; // mea,b,and c are the CSS class to surroend the entry to be hilited (the calling page itself)
meb='';
mec=' </div>';
var menuname= new Array(); // the array of visible, clickable text in each link.
var menuurl= new Array(); // the matching file name to be loaded if the entry is clicked.
menuurl[1]="main.htm";menuname[1]='Home';
menuurl[2]="history.htm";menuname[2]='ClubFEM<sup>&#0153</sup> History';   // #0153 is the TM symbol
menuurl[3]="faq.htm";menuname[3]='About Us';   
menuurl[4]="international.htm";menuname[4]='ClubFEM<sup>&#0153</sup> US and International Chapters';   
menuurl[5]="profiles.htm";menuname[5]='Member Profiles';   
menuurl[6]="reading.htm";menuname[6]='Reading Room';   
menuurl[7]="memrules.htm";menuname[7]='Member Rules';   
menuurl[8]="mcd1.htm";menuname[8]='Male Chastity Device';     
menuurl[9]="links.htm";menuname[9]='Our Favorite Links';
menuurl[10]="contactus.htm";menuname[10]='Contact Us';
menun=menuurl.length-1;
// start the generation loop
for(i=1;i<=menun;i++){;
// test to see if a separator or any other special exception needs to be inserted at this time (yes for item entry 4 and 5)
if(i==4)document.write('&nbsp;<div class=separatorbar></div>');
if(i==5)document.write('<div class=separatorbar style="margin:4px 0px 12px 0px;"></div><div>Houston<br>Chapter</div>');
if(menuname[i] == menume){ // if we are writing the entry for the current page's lik, see if it has a submenu entry to be shown.
if(!submenu){document.write(mea,menume,mec)} // no submenu, just hilite the main entry itself.
else{ //  yes, there is a sub-entry-- hilite the sub-menu entry instead of the main Page entry. (currently just for member profile pages and Reading Room articles)
document.write(notmea,menuurl[i],notmeb,menuname[i],notmec)
document.write(mea,submenu,mec)
}
}
else{document.write(notmea,menuurl[i],notmeb,menuname[i],notmec)}; // not the entry for the caller page- produce a normal clickable unhilited link.
} // end of the loop
//
// add a final separator and close the menu column in the table and open the next column that will contain the rest of the HTML in the caller page file.
document.write('&nbsp;<div class=separatorbar></div>');
document.write('&nbsp;</TH><TD align=left valign=top class=mainpanel>');
} // closing bracket (end) of menugen function
//
/*  SAMPLE HTML GENERATED BY MENUGEN 
here is  some typical code that a call to menugen will create- this is from a menugen('Home') call used to generate the main page:

&nbsp;
<div class="menume">Home </div><div class="menut"><a href="history.htm"> ClubFEM<sup>™</sup> History </a></div>
<div class="menut"><a href="faq.htm"> About Us </a></div>
&nbsp;
<div class="separatorbar"></div>
<div class="menut"><a href="international.htm"> ClubFEM<sup>™</sup> US and International Chapters </a></div>
<div class="separatorbar" style="margin: 4px 0px 12px;"></div>
<div>Houston<br>Chapter</div><div class="menut"><a href="profiles.htm"> Member Profiles </a></div>
<div class="menut"><a href="reading.htm"> Reading Room </a></div>
<div class="menut"><a href="memrules.htm"> Member Rules </a></div>
<div class="menut"><a href="mcd1.htm"> Male Chastity Device </a></div>
<div class="menut"><a href="links.htm"> Our Favorite Links </a></div>
<div class="menut"><a href="contactus.htm"> Contact Us </a></div>
&nbsp;
<div class="separatorbar"></div>
&nbsp;
</th><td class="mainpanel" align="left" valign="top">

*/
////////////////////// bottomgen FUNCTION DESCRIPTION
// bottomgen closes the Tables and displays the copyright line.
// bottomgen automatically displays the correct copyright date- no need to change this each year.
function bottomgen(){
var tmp=new Date();thisyr=tmp.getFullYear();
copyr="2001";if(thisyr > copyr)copyr=copyr+'-'+thisyr;
document.write('</TD></TR></TBODY></TABLE 1></TH></TR></TBODY></TABLE 0>');
document.write('<p><div class=separatorbar></div>Copyright © '+copyr+' ClubFEM<sup>&#0153</sup> All rights reserved.</p>');
document.write('</div>');
} // end of bottomgen function code
//
/*  SAMPLE HTML GENERATED BY BOTTOMGEN
here is a sample of the code that will generated by bottomgen:

</td></tr></tbody></table></th></tr></tbody></table><p></p><div class="separatorbar"></div>Copyright © 2001-2010 ClubFEM<sup>™</sup> All rights reserved.<p></p></div>

*/

//-->
