var FOOTER_REGULAR = 0x0000;	// Paint footer for a regular page.
var FOOTER_HOME    = 0x0001;	// Gray out the "Home" option on the footer.
var FOOTER_CONTACT = 0x0002;	// Gray out the "Contact Us" option on the footer.
var FOOTER_SEARCH  = 0x0004;	// Gray out the "Search option on footer.

function dup(s,n) // Duplicate string s n times
{var r="";while(n>0){r+=s;n--}return r;}

function footer(	// Function to paint the footer on a page
	type)		    // _HOME, _CONTACT, _SEARCH, or _REGULAR
{	footer(type,0);	}

function footer(	// Function to paint the footer on a page
	type, 		    // _HOME, _CONTACT, _SEARCH, or _REGULAR
	depth)			// subdirectory depth of the source page
{
	document.writeln( '<HR><CENTER><SPAN CLASS=DontPrint>');
	// Website Home
	if (type & FOOTER_HOME)	    // If this is the Home page, grey out option in footer
	    document.writeln( '<FONT color=gray>Website Home</FONT>&nbsp;|');
	else
	    document.writeln( '<A href="'+dup('../',depth)+'index.html">Website Home</A>&nbsp;|');
	// Contact Us
	if (type & FOOTER_CONTACT)  // If this is the "Contact Us" page, grey out option in footer
	    document.writeln( '<FONT color=gray>Contact Us</FONT> | ');
	else    
	    document.writeln( '<A href="'+dup('../',depth)+'ContactUs.html">Contact Us</A> | ');
	// Gedcom
	if (String(window.location).substring(0,4) == "file" )	// If we are running from a file
	    document.writeln( '<FONT color=gray>Gedcom</FONT> | ');
	else
	    document.writeln( '<A href="http://worldconnect.rootsweb.com/cgi-bin/igm.cgi?op=PED&amp;db=robertraymond&amp;id=I1">Gedcom</A> | ');
	// Search Website
	if ((type & FOOTER_SEARCH)||  								// If this is the "Search" page, grey out option in footer
		(String(window.location).substring(0,4) == "file" ))	// If we are running from a file
	{
	    document.write( '<FONT color=gray>Search Website</FONT>');
	}
	else
	{
	    document.write( '<img src="http://sitelevel.whatuseek.com/htmlbox.go?crid=4deb493f7bbd0550" width=1 height=1>' );
	    document.write( '<A href="Search.html">Search Website</A>');
	}

	document.writeln( '<BR></SPAN>' );
	document.writeln( '<FONT size=1>&copy; Copyright 2000-2007, Robert Raymond. Copying for private, non-commercial use is allowed. All other rights reserved.<BR>');
	document.writeln( '</P>' );
	// if (!(type & FOOTER_HOME))    // If this is NOT the Home page, put ad divider here
	//    document.writeln( '<HR class=bottom_ad_divider>');
}

// Header Code - This code is executed as part of the header of each file.
// {
//     if ( String(window.location).substring(0,4) == "file" )
//     {   // We are running from a local file.
//         // Override the style definitions that should be changed when running locally
//          document.writeln(" <STYLE TYPE=\"text/css\"> ");
//         document.writeln(" <!-- ");
//         document.writeln(" .top_advertisement{display:none}   ");
//         document.writeln(" .top_ad_divider{}                  ");
//         document.writeln(" .bottom_ad_divider{display:none}   ");
//         document.writeln(" .bottom_advertisement{display:none}");
//         document.writeln(" --> </STYLE> ");
//     }
// }


function PreDisplayHandler()
{
	firstCenter = document.getElementsByTagName('CENTER')[0]; // Get first <CENTER> element
	if (firstCenter != null) // If one was found
	{
	    firstCenterHTML = firstCenter.innerHTML; // Save a copy of the HTML
	    //if ((firstCenterHTML.indexOf("rootsweb.com") > 0) || // If it is an ad
       	//   (firstCenterHTML.indexOf("OAS_AD") > 0) )
	    //{
        //   firstCenter.innerHTML = '<SPAN CLASS=top_advertisement>Advertisement:<BR>' + 
     	//			firstCenterHTML + 		// Add Ad label above the advertisement
     	//			'</SPAN>';
	    //}
	}
	var tables = document.getElementsByTagName('TABLE');	// Get collection of <TABLE> elements
	for(var i=0;i<tables.length;i++)
	{
		var table = tables[i];
		if(typeof(table.background)=='string' && table.background.indexOf("images.rootsweb")>0)	// If rootsweb element
			table.className='DontPrint';
	}
}
