/*
======================================================================================================================
	INSTANTIATION CODE:  This code runs automatically when a page is loaged due to a call in the dogument header.
	
	This code inserts default elements into a standard page
	(1) Stat Counter code
	(2) Top Panel with Search Bar
	(3) Navigation Panel on the left side of the page
======================================================================================================================
*/

// Install global (static) variables used in various javascript functions.
//
// Search engine selector.  Change this value to switch search engines.
var googleSearch = true ;
// Add panel selector.  If true, AdSense block are shown, otherwise they are not an optinal other context ad source
// may be shown.
var googleAds = true ;
// Navigation help selector.  Change to false to prevent display of navigationHelp.
var showNav  = true ;

// Global variables used in jsfunctions.js/dragStart()
// ===================================================
// Reference to the draged object
var goDragObj = new Object() ;
// Global reference to a mouse event.
var goEvent  = new Object() ;
// If true, the browser is IE DOM (IE Opera )
var browserIE = false ;
// If true, the browser is W3C DOM (Mozilla, Navigator, Firefox)
var browserGecko = false ;

// ====================================================
// Global variables used to keep track of globally used values
var thisYear = getThisYear();

// Global variables used in jsfunctions.searchItemOverlay()
//========================================================
var nSearOvlWPx = 0

// SGlobal variables used by tatCounter 
// ====================================
// Define variables
var sc_project	 = 1186861; 
var sc_invisible = 1; 
var sc_partition = 10; 
var sc_security	 = "bc0806a2"; 

// Start the page display.  
// ======================
// This code including the functions it calls, actually writes code to the page using
// the document.write function.  This eliminates having to rewrite the same code page after page by putting it in
// a javascript process called when a page is instantiated.
//
with (document)
{

	/*
	=====================================================================================================================
	StatCounter

	This function initiates statcounter code from the services' website.  The icon to show stateounter is places only
	on the main index.html page.
	
	====================================================================================================================
	*/
	write( installStatcounter() );

	/*
	====================================================================================================================
	Top Panel

	This is the header at the top of the screen.  It is a defined area with a gackground image.  It also contains, at the
	right top corner of the screen, a site searchbar.  Two searchbar options are provided.  Google search for use when
	google is actually working, and Freefind for when it is not.

	The top panel is not printed, only displayed on screen.  There is a substitute print header for printed documents
	====================================================================================================================
	*/
	write( showTopPanel() );

	/*
	=====================================================================================================================
	Facebook

	Installs the Facebook linking script.  Needs to be installed on every page that owns a Facebook link. See
	Navigation Panel Code for the actual link.
	=====================================================================================================================	
	*/
	write ( initFacebook() ) ;
		
	/*
	=====================================================================================================================
	LeftPanel

	is the navigation panel on the left edge of the page. Its width is fixed at about 200 px.  IE and Navigator
	display widths differently so adjustment is made in the code.  This java script code writes the Navigation panel
	in HTML code.  The Javascript code is contained in leftpanel.js and replaces the former navigation.js.
	=====================================================================================================================	
	*/
	write ( showLeftPanel() );
	
} //endwith ( document )


/*
=======================================================================================================================
This is the end of the code that executes when a page loads.  Below are functions called from documents or other JS
functions
=======================================================================================================================

=======================================================================================================================
Start Javascript Functions
==============================================================================================================================================================================================================================================

=======================================================================================================================
function getKeywords() 		Retrieves the content of meta name = "keywords".
	Arguments								None
	Return									Key words as a comma-delimited string. or a blank string if none are found.
=======================================================================================================================
*/
function getKeywords()
{
	// Get the content of the "Keywords" <meta> tag.  They keywords are displayed as search terms to th user.  this is
	// the easiest and most efficient way to store search terms.  Most search engines no longer use the keywords 
	// meta tag.
	var m = document.getElementsByTagName('meta');
	
	// Parse the <meta> tags looking for the name "Keywords".  The keywords meta tag is used to hold the search terms
	// related to or expanding on the current document.
	for (var i = 0; i < m.length; i++ )
	{
		if( m[i].name == "keywords" || m[i].name == "Keywords" || m[i].name == "searchterms"|| m[i].name == "Searchterms" )
		{
			return( m[i].content );
		}
	}
	
	return ( "" );
	
} // end getKeywords() ------------------------------------------------------------------------------------------------

/*
=======================================================================================================================
function getStringCharacterCount() 							
	Arguments								cStr	The string for which the number of characters is to be returned.
	Return									(i) 	Returns the number of characters in atrimmed string.
=======================================================================================================================
*/
function getStringCharacterCount( cStr )
{
	cStr = stringTrim( cStr );
	return ( cStr.length );
}

/*
=======================================================================================================================
  getTitle() 		Gets the title <meta> tag content, cleans it up and returns it as a string.
=======================================================================================================================
*/
function getTitle()
{
	var cTitle = document.title ;
	
	// Clean up the title if required.  Some titles contain the "|" character dividing the main title from sub-title.
	var nTo = cTitle.indexOf("|") ;
	if ( nTo != -1 )
	{
		// Get the substring up to the "|" character.
		cTitle = cTitle.substr( 0, nTo );
	}
	
	// Clean up leading and trailing spaces
	cTitle = cTitle.replace(/^\s*|\s*$/g,"");
	
	return cTitle ;

} // end getTitle()

/*
=======================================================================================================================
  initFacebook() 		Installs the initialization code for the link to Facebook.
=======================================================================================================================
*/
function initFacebook()
{
	with ( document )
	{
		write( '<div id="fb-root"></div>');
		write( '<script> (function(d, s, id) {');
		write( '  var js, fjs = d.getElementsByTagName(s)[0];');
		write( '  if (d.getElementById(id)) {return;}');
		write( '  js = d.createElement(s); js.id = id;');
		write( '  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";');
		write( '  fjs.parentNode.insertBefore(js, fjs);');
		write( '}(document, \'script\', \'facebook-jssdk\'));</script>'); 
	 	} //endwith ( document )

	return("");
}
/*
=======================================================================================================================
  installStatcounter() 		Installs the initialization code for the statcounter service from the service's
													web site.
=======================================================================================================================
*/

function installStatcounter ()
{
	with ( document )
	{

		write( '<div id="noprint">' );
		write('<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"> 	</script>');
		// Handle browers that have javascript turned off
		write('<noscript>');
		write('<a href="http://www.statcounter.com/" target="_blank">');
		write('<img src= 	"http://c11.statcounter.com/counter.php?sc_project=1186861&java=0&security=bc0806a2&invisible=1" alt="website statistics" border="0"></a>');
		write('</noscript>');
		write( '</div>' ); //noprint
		// End StatCounter insert
		
	} //endwith ( document )
	
	return( "" ) // return a blank string to document.write
	
} // endfunction installStatcounter()

/*
=======================================================================================================================
function isGecko() 	Returns true if the browser is a gecko browser, like Mozilla and Netscape.
	Arguments									None
	Returns										True if the browser is a Gecko browser, otherwise false
	Calls											None	
=======================================================================================================================
*/ 
function isGecko()
{
	// Get a copy of the userAgent string
	var ua = window.navigator.userAgent;

	// Find the Gecko version.  If not Gecko, version will be -1
	return ( ua.indexOf( "Gecko" ) > -1 ) ;
	
} // end isGecko()

/*
=======================================================================================================================
function isIE() 						Returns true if the browser is a IE browser.
	Arguments									None
	Returns										True if the browser is an IE browser, otherwise false
	Calls											None	
=======================================================================================================================
*/ 
function isIE()
{
	// Get a copy of the userAgent string
	var ua = window.navigator.userAgent;

	// Find the IE version.  If not IE, version will be -1
	return ( ua.indexOf( "MSIE" ) > -1 ) ;
	
} // end isIE()

/*
=======================================================================================================================
function navigationHelp() 	Formats and isplays navigation help text at the end of a document, including the search
														term list in columnar format.
	Arguments									None
	Returns										Blank string
	Calls											showMainMenu()
														showSearchTermList()
														showSearchBar()
=======================================================================================================================
*/
function navigationHelp() 
{

	// If the browser is not one that can display search terms, then this section should not be displayed.
	if ( !isIE() && !isGecko() ) { return "" ; }
	
	with( document )
	{
		// Create a div to display the text.  It should be blocked from printing.
		write('<br> <div id="noprint" style="text-align:left">');
		// Display the heading
		write('<div class="h2du" style="line-height:50px;text-align:center">');
		write('Did You Find What You Were Looking For?</div>');
		write('<div class="h4" style="line-height:50px; text-align:center">No?  Then Let Us Help You.</div> <br>');
	// Start Content
		write('<span class="drop-cap">O</span>ur site contains over a hundred articles on remodeling, renovating and updating your home, so it is not always easy to find all the articles that contain the information you are looking for.  This is especially true if you reached our site using a search engine like Yahoo or Google. Search engine indexing robots are very fast, not very smart.  They do not understand synonyms or know when two or more terms or phrases mean the same thing.  Nor do they have the foggiest notion of concept searching.  They look only for specific word groups.  If the search words you use do not closely match the words appearing on a web page, the search engine will probably miss it entirely.  Even less helpful is the fact that if a web search engine finds more than one relevant page on a web site, it will probably display only the first page it finds &mdash; which may not be the best page for your purpose.');
		write('<br><br>');

		// Insert a menu float right
		write('<span class="floatleftinsert" style="background-color:#998c7e; width:235px">') ;
	
		// Start main selection menu
		//
		write( showMainMenu() );
		//
		write( '</span>')
		// End menu float right
			
		write('To overcome the limitations of the major search engines, we have provided navigation tools on our site to help you find the information you are looking for.  So, if you did not find it on this page, do not give up just yet. ');
		write('<br><br>&nbsp;&nbsp;&nbsp&bull;&nbsp;<span class="h5l">Main Topics.</span>  At the top left of the page you will see the main topic menu.  If you are looking for information about, for instance, kitchen remodeling, select "Kitchen" to go to a gateway page that introduces the topic, but also leads you to many more articles on various aspects of kitchen remodeling.  From the Kitchen page, you can, for example, go to articles on selecting cabinets, cabinet construction, countertops, design concepts, flooring, lighting, architectural integration, and structural issues.');
		write('<br><br>&nbsp;&nbsp;&nbsp&bull;&nbsp;<span class="h5l">Article Indexes.</span> We maintain two indexes to articles, one by <a href="srticleslist.htm">topic</a> and a second by <a href="articlesalpha.htm">title</a>.  They contain a summary of the content of the article to help you locate the one that contains the information you are looking for.</li> ');
		write('<br><br>&nbsp;&nbsp;&nbsp&bull;&nbsp;<span class="h5l">Site Search.</span> The information on a particular topic you are looking for may be spread across several articles.  For example, if you want to know all about countertops, there are separate articles on countertop materials, appropriate countertop materials for various styles of kitchens and baths, setting the proper countertop height for maximum comfort, and so on: all in different articles.  The best way to find all of the articles that deal with countertops would be to search our site for the term "countertop".  This will lead you to every article in which the word "countertop" is used.  Our site search utility does this for you.  The search box is located at the top right corner of this page.  Enter a search term, and click the "site search" button to display all of the articles containing the term.<br><br><br>');

		// Display the search terms
		write (showSearchTermList());

		// Install the floating search box.  This is invisible until the user clicks on a search term at thich time it
		// becomes visible after it is positioned in the center of the screen.  All of the bar's properties are set 
		// in stylesheet.css
		//
		// IE throwing an error error 800a03e8 9/10/11.  No one is quite sure what this error is, but it is fatal.  One
		// gent suggest it occurs when IE tries to call a javascript process that has not yet been loaded -- i.e. a
		// threading problem.  I tried to use his fix with DomReady.ready(), but it did not work.. Code returend to
		// original form on 9/10/11.
		//
   	write('<div id="searchBox" class="t12" style="cursor:pointer">');
			
 		// This function creats the controls on a hidden searchbar.  The searchbar is displayed when an item in the
		// search term list is clicked.  
		// Arguments:  
		//		se = 'google' or "notgoogle".  Googled displays the google adSense search bar.  The alternative is FreeFind.
		//				 the se var is set at the top of default.js as a static variable.  
		//		true if display a close button.
		//
		//		return - empty string
		//
		write( showSearchbar( googleSearch, true ) );
		
		write('</div>');
		
	} //endwith( document )
	
	return ("")

} // endnavigationHelp() 

/*
=======================================================================================================================
function showAboutUsMenu() 	Displays the about us menu on the navigation (left) panel.
	Arguments		None
	Returns			Blank string
=======================================================================================================================
*/

function showAboutUsMenu()
{
	with ( document )
	{
		// Start About Us menu
		//
		write('<span class="h3rev">About Us</span>');
		
		write('<ul style="color:ivory; list-style-position:outside;">');
		write('<li><a href="index.html">Home</a></li>');
		write('<li><a href="designbuilder.htm">Design-Builder</a></li>');
		write('<li><a href="warranties.htm">Warranties</a></li>');
		write('<li><a href="contactus.htm" target="_blank">Contact Us</a></li>');
		write('</ul>');
		//
		// End About Us menu
	}
	
	return "" ;
} // end showAboutUsmenu()

/*
=======================================================================================================================
function showAffiliations() 	Displays affiliations on the navigation (left) panel.
	Arguments		None
	Returns			Blank string
=======================================================================================================================
*/
function showAffiliations()
{
	with ( document )
	{
		// Start Addiliations Display 
		//

		// Start divider
		write('<div align="center" style="color:ivory; line-height:1.1em">');

		// Heading
		write('<span class="h3rev">Affiliations</span><br>');

		
		// Makes <a> tags display in reverse
		write('<li class="none-outside">' );
			
		// Start BBB
		// 		
		write('Honor Roll Member of the Better Business Bureau.');
		write('<br><br>');
		write('<a href="http://www.bbbonline.org/cks.asp?id=1051110105347"><img alt="Go to BBB Reliability Program" border="0" id="BBB" src="images/Left_Panel/BBBLogo.gif"></a>');
		write('<br><br>');
		write('BBB Acredited Business');
		write('<br><br>');
		write('<a href="http://www.bbbonline.org/cks.asp?id=1051110105347"><img alt="Go to BBB Web Site" border="0" id="BBBAcredited" src="images/Left_Panel/BBBAcreditedBusiness.png"></a>');
		write('<br><br>');
		write('We adhere to and strongly support the ethical standards required of BBB member businesses. <br>'); 
		write('For more information, please contact<br>');
		write('<a href="http://www.lincoln.bbb.org">BBB of Nebraska</a><br>');
		write('<br><br>');
		//
		// End BBB
	
		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// Start NARI
		//
		write('<br>');
		write('<a href="http:///www.nari.org"><img alt="NARI logo" id="NARI" src="images/Left_Panel/NARI.jpg" width="120px"></a>');
		write('<br><br>');
		write('Member of the <br> <a href="http:///www.nari.org">National Association of the Remodeling Industry</a>.');
		write('<br>');
		write('NARI members adhere to a strict code of ethics and standards of practice.'); 
		write('<br><br>');
		// 
		// End NARI
			
		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// Start NKBA
		//
		write('<br>');
		write('<a class="filterimage" href="http:///www.nkba.com"><img alt="National Kitchen and Bath Association" id="NKBA" src="images/Left_Panel/NKBA.jpg" width="95%"></a>');
		write('<br><br>');
		write('Member of <br> <a href="http:///www.nkba.com">The National Kitchen &amp; Bath Association</a>');
		//
		// End NKBA
		write('</li>' );
		write('</div>' );
		//
		// End of Afficliations

	}
	
	return "" ;

} // end showAffiliations()

/*
=======================================================================================================================
function showArticlesIndexMenu() 	Displays the articles index menu on the navigation (left) panel.
	Arguments		None
	Returns			Blank string
=======================================================================================================================
*/

function showArticlesIndexMenu()
{
	with ( document )
	{
		// Start articles index selection menu
		//
		write('<span class="h3rev"><img src="images/New.png" align="right" alt="New" width="50px"> Articles</span>');
		write('<ul style="color:ivory; list-style-position:outside;">');
		write('<li><a href="articlesalpha.htm">Alphabetical List</a></li>');
		write('<li><a href="articleslist.htm">Topical List</a></li>');
		write("</ul>");
		//
		// End articles index selection menu
	}
	
	return "";
	
} // end showArticlesIndexMenu()

/*
=======================================================================================================================
function showCopyright() 		Displays a copyright notice on the navigation ( left) panel
	Arguments		None
	Returns			Blank string
=======================================================================================================================
*/
function showCopyright()
{
	with (document )
	{
		// Copyright Notice
		//
		// Start divider
		write('<div align="center" class="t12" style="color:ivory" >');
		
		// Start bold text
		write('<b>');
		
		// getThisYear is in jsfunctions.js
		try{
		write('Copyright &copy;&nbsp;' + getThisYear() +'<br>' );
		}
		catch ( e ) {
		}
		write('StarCraft Custom Builders<br>');
		write('Design/Build Remodeling<br>' ) ;
		write('P. O. Box 80265<br>');
		write('Lincoln, NE 68501-0265<br>');
		write('All Rights Reserved');
		write('<br><br>');
		// Horizontal Line
		write('<hr class="hrreverse">');

		write('By accessing this web site, you agree to our <br> <a href="TermsofService.htm">Terms of Service</a>.');
		
		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// end bold text
		write('</b>');
		
		// End Divider
		write('</div>');

		//
		// End Copyright Notice
	}
	
	return "" ;
	
} // end showCopyright()

/*
=======================================================================================================================
function showFacebook() 		Displays Facebook link
	Arguments		None
	Returns			Blank string
=======================================================================================================================
*/
function showFacebook()
{
	document.write( '<div class="fb-like-box" data-href="http://www.facebook.com/pages/StarCraft-Custom-Builders-DesignBuild-Remodeling-Historic-Restoration/210348012367189" data-width="200" data-height="110" data-colorscheme="light" data-show-faces="false" data-stream="false" data-header="false"></div>'); 

	return "";
	
}  // end showFacebook()

// --------------------------------------------------------------------------------------------------------------------
// showGoogleAdPanel()  	Display the screen box that holds the google ad panel.
//												Moved from jsfunction.js 12/26/11
// --------------------------------------------------------------------------------------------------------------------
//
function showGoogleAdPanel( nwidth, nheight, cAdSlot ) 
{
	// googleAds static keyword set in default.js
	if ( googleAds )
	{

		with ( document )
		{
				write('<div id="noprint">' );
				write('<br>');
				write('<img alt="Google AdSense" src="images/GoogleAdSenseLogo.png" width="120px"> ');
				write('<div class="t8" style="color:gray; font-size:smaller; text-align:center"><br>Paid advertising.</div>');
				write( googleAdPanel( nwidth, nheight, cAdSlot ) );
				write('<div style="color:gray; font-size:smaller; line-height:90%; text-align:center"> Paid advertising.<br>Read Google\'s privacy policy <a href="http://www.google.com/intl/en/privacy/">here</a>.</div>') ;
				write('<br>');
				write('</div>') ;
		} // endwith( document )
	}
	return ("");

} // end showGoogleAdPanel(nwidth, nheight, cAdSlot)

/* 
===================================================================================================================
 showHowHelpful() 
	Description			Formats and displays the How-Helpful dialog and allows the user to sent a rating to our e-mail.
	Arguments				c_Title 	The title of the document.  if not passed, it is obtained from the <meta> title tag
														using getTitle().
									a c_Title, if so, use it.
	Calls						showSocialNetworkLinks() - Social network links.
	Return					Blank string to document.write.
===================================================================================================================
*/
function showHowHelpful( cTitle ) 
{
	if ( cTitle == null || cTitle === "undefined" )
	{ 
		// If the title is not passed as an argument, get the title from the meta title tag.
		cTitle = getTitle();
	}
	
	var c_NextLine = ' Please Rate "' + cTitle + '"'

	with( document )
	{
	// Prevent the How Helpful form from printing //
		write('<a name="how_helpful"></a>'); 
		write('<div id="noprint">');
		write('<br><br>');
		write('<center>');
		write('<div style="background-color:#cccc99; border:5px solid #6d6360; width: 840px">');
		
		// Start Form:  This form processes at the Yahoo server.
		write('<form method=post action="http://us.1.p12.webhosting.yahoo.com/forms?login=jmedgar">');

		write('<span class="h3" style="display:block; text-align:center">');
		write(c_NextLine);
		write('<hr class="hrnormal">');
		write('</span>');

		write('<table border=0 cellpadding="5" style="background-color:transparent; width:830px">');

		write('<tr class="strong" style="text-align:left" valign="top">'); 

		write('<td style="width=:260px">');
		write('How helpful was this article?<br>');
		write('<input type="radio"  name="rating" value="Not Helpful" >			Not Helpful<br>');
		write('<input type="radio"  name="rating" value="Somewhat Helpful" > Somewhat Helpful<br>');
		write('<input type="radio"  name="rating" value="Helpful" >					Helpful<br>');
		write('<input type="radio"  name="rating" value="Very Helpful" >		  Very Helpful<br>');
		write('</td>');

		write('<td style="width:320px">');
		write('<span style="font-size:1.2em">Can we make this article better?  If so, please tell us how.</span><br>');
		write('<textarea name="comments" rows="6" cols="35"></textarea>');
		write('</td>');

		write('<td style="width:250px" >');
		write('Do you want us to respond to your feedback? If so, please tell us your...<br><br>');
		write('<span class="t14" style="vertical-align:middle">'); 
		write('&nbsp;Name: ');
		write('<input type="text" name="real_name" value="" width="200px"><br>');
		write('E-mail: ');
		write('<input type="text" name="real-mail" value="">');

		write('</span>');
		write('</td>');

		write('<tr>');
		write('<td align="center" colspan="3">');
		write('<input name="btnSubmit" id="btnSubmit" type="submit" value="Click here to send us your rating">');
		write('&nbsp;or <a href="contactus.htm" target="_blank">contact us</a> for more information.');
		write('</td>');
		write('</tr>');

		write('<tr>');
		write('<td align="center" colspan="3">');
		write('<span class="t14">We do not give out personal information. <a href="privacy.disclosures.htm">Our privacy policy</a></span>.');
		write('</tr>');

		write('</table>');

		c_NextLine='<input type="hidden" name="subject" value="' + cTitle +'">';
		
		write(c_NextLine);

		write('<input type="hidden" name="next_url" value="http://starcraftcustombuilders.com/contactus3.htm">');
		write('</form>');
		write('</div>');
		write('</center>');

	} //endwith( document )
		
	return("");

} //end showHowHelpful()

/*
=======================================================================================================================
function showLeftPanel() 		Displays navigation panel at the left of the screen.  This includes the main selection
														menu, a list of affiliations, the articles index menu and copyright notice
=======================================================================================================================
*/

function showLeftPanel()
{

	with ( document )
	{
	
		// Make the LeftPanel invisible to the printer.  The leftpanel class is defined in stylesheet.css.
		write('<div id="noprint" class="leftpanel">');

		// Show "This Old House" panel
		write( showThisOldHouse() );

		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// Start main selection menu
		//
		write( showMainMenu() );
			
		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// Show articles index selection menu
		write( showArticlesIndexMenu() ) ;

		// Horizontal Line
		write('<hr class="hrreverse">');
	
		// Show About Us section
		write( showAboutUsMenu() ) ;
		
		// Horizontal Line
		write('<hr class="hrreverse">');

		// Show Arriliation Panel
		write( showAffiliations() ) ;
	
		// Horizontal Line
		write('<hr class="hrreverse">');
		
		// Show copyright notice
		write( showCopyright() ) ;
		
		// Show AdSense Panel for left panel
		// This does not display correctly in IE, and the problem is in the Google code. The ad panel displays
		// in the main body instead of the <div> provided for it.
		if ( !isIE() )
		{
			write('<div align="center" style="align:center; background-color:ivory; text-align:center; width:100%;">');
			write( showGoogleAdPanel(160, 600, "0269069705") ); // Pass width, height and google ad id #. Returns ""
			write('</div>');
		}
		
		// End of NoPrint ID
		write('</div>');
		
	} // end with( document )

	return ( "" )
	
} // end showLeftPanel()

/*
=======================================================================================================================
function showMainMenu() 		Displays main menu as an unordered list.
	arguments:	None
	return			Blank string		
=======================================================================================================================
*/
function showMainMenu()
{
	with ( document )
	{
		// Heading
		write('<span class="h2rev">I would like a new...</span>');
		
		// Start unordered list
		write('<ul style="color:ivory; list-style-position:outside;">');
		write('<li><a href="kitchen.htm">Kitchen</a></li>');
		write('<li><a href="bath.htm">Bath</a></li>');
		write('<li><a href="addition1.htm">Addition</a></li>');
		write('<li><a href="builtin.htm">Furniture/Built-In</a></li>');
		write('<li><a href="closet.htm">Closet/Storage</a></li>');
		write('<li><a href="home.office.htm">Home Office</a></li>');
		write('<li><a href="deck.handbook.htm">Deck/Porch</a></li>');
		write('<li><a href="windows.htm">Window/Door</a></li>');
		write('<li><a href="garage.htm">Garage/Outbuilding</a></li>');
		write('<li><a href="http://www.sandcreekpostandbeam.com">Post & Beam</a></li>');
		write('<li><a href="insulation.htm">Insulation</a></li>');
		// End unordered list
		write("</ul>");
		//
		/* End main selection menu */
	}
	
		return "";
}

/*
=======================================================================================================================
function showSearchBar() 		Displays the control on the searchBar <div>.  There are two searchbars on most pages.  The
														static bar at the top right of the page, and the popup bar associated with the search terms
														list.  The <div> that hold the search bar controls are instantiated elsewhere in code.
	arguments:	_googleSearch			If true, the google search engine is being displayed, if false, FreeFind is being used.
							lPopSrchBx		If true, the popup search box is the <div> being populated.	
=======================================================================================================================
*/

function showSearchbar( _googleSearch, lPopSrchBx )
{
	// _googleSearch,		s - Specified whether the search engine is set for google search or googleSearch search 
	// lPopSrchBx 	l - Specifies whether this is the search bar shown in top panel (false) or the second,
	//                  pop-up seach bar shown when a search term is clicked.  See jsfunction.js/navigationHelp()
  try{
	
	with( document )
	{
	
		if ( lPopSrchBx )
		{
			// Top Header and Close Button
			// --------------------------
			// For a popup search box there is a title bar that contains a close "X" indicator. and allows the box to
			// be dragged with the mouse (using drag function in jsfunctions.js).
			//
			// Top header and Close button
			//
			// Start titlebar div
			//
			write( '<div id="titleBar" style= "border-bottom: 1px solid #d3d3d3; cursor:move;  font-family:arial, helvetica, sans-serif; font-size:1.5em; font-weight:bold; line-height:2em; margin:-10px 0px 5px 0px; text-align:left; vertical-align:center; " onMouseDown = "dragStart(event, this.parentNode)" onMouseUp = "dragStop()">' );

			// Show the closing "X" character on the titlebar
			write( '<span style="cursor: pointer; float:right; width:1em" onclick = "this.parentNode.parentNode.style.display= \'none\'" onmouseover = "this.style.color = \'yellow\'" onmouseout = "this.style.color = \'white\'">X</span>' ) ;

			// Show the header caption
			write( 'Site Search' );

			// End titlebar div
			write( '</div>' ) ; 
			 
			write( '<div> Enter the word or expression to search, then click "Site Search".</div>');
		}
		else
		{
			if ( isIE() ) { write( '<div style="font-weight:bold; font-size:90%; margin-top:-5px;"> Enter the word or expression to search, then click "Site Search".</div>'); }
			else          { write( '<div style="font-weight:bold; font-size:90%; margin-top: 3px;"> Enter the word or expression to search, then click "Site Search".</div>'); }
		}
			
	} // endwith( document )
	
	// If the _googleSearch artument evaluates to google, use the google AdSense search box	
	if (_googleSearch) 
	{
		
		with ( document ) 
		{
			write('<form method="get" action="http://starcraftcustombuilders.com/search.results.htm" style="margin-top:5px; margin-bottom:3px" target="_top">');
			
			write('<input type="hidden" name="domains" value="starcraftcustombuilders.com"></input>');
			
			// The search term input text control.  The class "textField" is defined in stylesheet.css.  The "searchText' id
			// is used in javascript.js/showSearchBox to find the search box and insert a value that is the default search
			// string
			if ( lPopSrchBx )
			{
				write('<input type="text" id="searchText" class="textfield" name="q" maxlength="255" value="" id="sbi">');
			}
			else
			{
				write('<div align="center" style="margin-bottom:3px;"><input type="text" class="textfield" name="q" maxlength="255" value="" id="sbi"></div>');
			}

			// Display site search button
			write('<input type="image" alt="Use your browser back button to return to this page." id="sbb" name="sa" src="/images/search.png" style="cursor:pointer; vertical-align:middle" title="Use your browser back button to return to this page." >');

			// Display search help button
			write("&nbsp;");
			
			write('<a href="searchhelp.htm" accesskey="H" rel="help" taget="_blank" >');
			write('<img src="/images/help.png" alt="help button" border=0 style="vertical-align:middle"></a>');
			
			// These hidden fields are instruction to the google backend
			write('<input type="hidden" name="sitesearch" value="" id="ss0"> </input>');
			write('<input type="hidden" name="sitesearch" value="starcraftcustombuilders.com" checked id="ss1">');
			write('<input type="hidden" name="client" value="pub-2587501670346134"></input>');
			write('<input type="hidden" name="forid" value="1"></input>');
			write('<input type="hidden" name="ie" value="ISO-8859-1"></input>');
			write('<input type="hidden" name="oe" value="ISO-8859-1"></input>');
			write('<input type="hidden" name="safe" value="active"></input>');
			write('<input type="hidden" name="cof"');
			write('	value="GALT:#0066CC;GL:1;DIV:#999999;VLC:990000;AH:center');
			write(' ;BGC:FFFFEE;LBGC:FFFFEE;ALC:0066CC;LC:0066CC;T:000000;GFNT:CCCCCC;GIMP:6666ff;FORID:11">');
			write('<input type="hidden" name="hl" value="en"></input>');
			
			// End of the form
			write('</form>');
		} // endwith( document )
	
	} // endif(_googleSearch)
	
	else // Not google search box.  Use Freefind.com search utility
	{

		/* FreeFind contact information
				Site URL: http://starcraftcustombuilders.com/
        E-mail  : jime@starcraftcustombuilders.com
        Password: 68379760
        Site ID : 14461024
		*/

		// Define the search window arguments
		var searchwin		 	= 'http://www.freefind.com/searchtipspop.html';
		var searchwinname	= 'searchtips';
		var searchwinattr	= 'resizable=yes,scrollbars=yes,width=508,height=508';

		with ( document ) 
		{
			// FreeFind Search Engine Codes
			//
			// Start Form
			write('<form action="http://search.freefind.com/find.html" method="get" style="margin-top:5px; margin-bottom:3px" target= "_self">');
			
			write('<input type="hidden" name="si" value="14461024">');
			write('<input type="hidden" name="pid" value="r">');
			write('<input type="hidden" name="n" value="0">');
			write('<input type="hidden" name="_charset_" value="">');
			write('<input type="hidden" name="bcd" value="&#247;">');
			write('<input type=hidden name=nsb >' );
			
			// The search term input text control.  The class "textField" is defined in stylesheet.css.  The "searchText' id
			// is used in javascript.js/showSearchBox to find the search box and insert a value that is the default search
			// string
			write( '<table align="center" border = "0" cellpadding = "0"><tr><td> ');
			
			if ( lPopSrchBx )
			{
				write('<input type="text" id="searchText" class="textfield" name="query" size="15" ');
			}
			else
			{
				write('<input type="text" class="textfield" name="query" size="15"');
			}
			write('</td><td>') ;
			
			// Display the sitesearch button
			write('<input type="image" src="/images/search.png" style="cursor:pointer; vertical-align:middle" >');	
			write('</td><td>') ;
			
			// Display search help button
			write('<a href="searchhelp.htm" accesskey="H" rel="help" taget="_blank" >');
			write('<img src="/images/help.png" alt="help button" border=0 style="vertical-align:middle"></a>');

			write('</td></tr></table>') ;
			
			write('</form>');
		
		} // endwith( document )
	
	} // endif (_googleSearch)	
	
	with ( document )
	{

		if ( lPopSrchBx )
		{				
		
			// display the powered by phrase and close button on search box 2 only.
			//
			var cPoweredBy = 'FreeFind' ;		
			if ( _googleSearch ) { cPoweredBy = "Google"; }

			// Powered by
			write( '<div align="left" style="text-align:left; valign="super"' );
			write( '<span class="t10">Powered by&nbsp;' + cPoweredBy + '&reg;</span> ' );
			write( '</div>' );

		} // endif ( lPopSrchBx )
	
	} //endwith( document )
	
	} // end try
	catch ( e ) {
	}
	
	return ("");	// return a blank string to document.write.
	
} // end function showSearchBar()

/*
=======================================================================================================================
function showSearchTermList() 
	description			Add a <div> to body which is used to display search terms in columns.  Columns and terms are added
									by showSearchTermListColumns().  The <div> added is id="colParent".
	arguments:			None
	call hierarchy: navigationHelp()
										showSearchTermList()
											showSearchTermListColumns()
=======================================================================================================================
*/
function showSearchTermList()
{

	// Create & display a heading string using the title of this document.  Title is a meta-object in the header.
	//
	// getTitle() returns a cleaned up title from the <meta> tag of the document.
	var cTitle = getTitle();
		
	// Display the Header at the top of colParent
	with ( document )
	{
		
		write('<span class="h4du" style="text-align:center">Search Terms Related to "' + cTitle + '"</span><br>');
		write('<span class="drop-cap">K</span>nowing the right search expression to use is somewhat of an art.  There are lots of terms used in construction and remodeling that may not be familiar to you.  And, search engine indexing robots do not look at language the way you do.  So you may search for "kitchen remodeling" and miss a great article on strategies for updating yor old kitchen because the article does not happen to include the words "kitchen remodeling".  So to help you identify possible search expressions, we have prepared a list of search terms that relate to this article. It is, of course a very limited list, but it should at least get you started. If you discover a search expression that leads to exactly the information you are looking for, <a href="contactus.htm">tell us</a> about it.  We are always looking for good additions to our list.' );
		write('<br><br>' );
		write('<span class="h5" style="text-align:center">(Click a search term to open the site search window)</span><br>');
	//
	} //end with( document )

	// End of Header Section

	////////////////////////////////////////////////////////////
	//Add a new colParent division.  Basic attributes are set here, but the height is set in showSearchTermListColumns()
	//
	var addStyle = "overflow:hidden; position:relative; text-align:left; text-overflow:ellipsis; white-space:nowrap";
	document.write('<div class="t14" id="colParent" style="'+ addStyle + '"></div>');

	// display the columns on colParent
	document.write( showSearchTermListColumns() ) ;

	// Set the document resize to repead this function if the document is resized.
	window.onresize = showSearchTermListColumns;
	
	return('');

} // end showSearchTermList()------------------------------------------------------------------------------------------

/*
=======================================================================================================================
function showSearchTermListColumns() 
	description			Displays search terms in columns on div id colParent.  Calculates the width and height of columns
									and the number of columns required to display the list.
	arguments:			None
	call hierarchy: showSearchTermListColumns()
										getKeywords()
										getStringCharacterCount()
										testDiv()
										getStringPixelMetrics()
										getViewportWidth()
										isGecko()
=======================================================================================================================
*/
// --------------------------------------------------------------------------------------------------------------------
// 	showSearchTermListColumns() Recreates the search list columns on a <div> with id="colParent".  
//	Called by 	showSearchTermList () and the windows.onResize event.  
//							If the search list is not displayed, just returns false. 
// --------------------------------------------------------------------------------------------------------------------
// 
function showSearchTermListColumns() 
{

	// Get a reference to the column parent container <div>
	var oColParent = document.getElementById( "colParent" );
	
	if ( !oColParent ) { return ("Could not find the colParent object.") ; }
		
	// Remove all the child <div>s in this div, if any exist.
	while (oColParent.firstChild) 
	{
	   oColParent.removeChild(oColParent.firstChild);
	}	

	// Recreate the columns.  This requires a new calculation of column width, the number of columns that will fit,
	// the number of rows required, and so on.
	//
	// Get the content of the "Keywords" <meta> tag.  They keywords are displayed as search terms to th user.  this is
	// the easiest and most efficient way to store search terms.  Most search egines no longer use the keywords meta tag.
	var cList = getKeywords();
	if ( cList=="" ) { return ("No search terms found for this article."); }
	
	// Get the length of the string in characters less the "," separators
	//
	// Replace commas with "".  First, we have to turn the string into a regular expression
	var cCleanList = cList.replace(/,/g,'');
	
	// This is the length of the list in characters
	var nListLen = getStringCharacterCount( cCleanList );
	
	// Get the number of search terms in the list
	//
	// Put the items in the string into an array and lose the commas.
	var aList = cList.split("," );
	
	// Count the number of elements in the array.
	var nListItems = aList.length ;
	
	// Calculate the average number of characters in a search term then multiply it by 110% to get a nice, if
	// arbitrary column width
	var nAvChars = Math.round( nListLen / nListItems) ;
	
	// Get the width and height of the text in pixels.  getStringPixelMetrics() returns an array with the width
	// in the first element and the height in the second.
	//
	// Create a temporary divider to hold the string to be measured.  This already has appropriate formatting.
	var xTest = testDiv( true ) ;
	if ( xTest = null ) { window.status = "Test divider did not create. Cannot continue " ; return ( "" ) ; }
	
	// function returns the width and height of the string in pixels in an array. aPxDims[0] = width, aPxDims[1] = height
	var aPxDims = getStringPixelMetrics( cCleanList.substr( 0, nAvChars ), "TestDiv" );
	
	// Remove the temporary container
	xFailed = testDiv ( false ) ;
	
	if ( !aPxDims ) { return ( "Cannot calculate string pixel length."); }
	
	// String width in pixels
	var nColWPx = aPxDims[ 0 ];
	// If Mozilla, add 20 the the col width for padding.  this is removed later.
	if ( isGecko() ) { nColWPx = nColWPx + 20 ; }
				
	// The pixel height value returned includes vertical padding required to create the line height.  If this is not
	// wanted, adjust it out now.
	var nLineHPx = Math.round( aPxDims[ 1 ] );
		
	// Calculate the number of whole columns that will fit on this screen.  Reduce width by 17 pixels to account for
	// the vertical scroll bar.
	//
	var nScrnPx = getViewportWidth() - 17 ;
	
	// Mozilla can return negative values for nScrnPx if the window has not been instantiated.  If so, return.
	if ( nScrnPx <= 0 ) { window.status = "Negative window width."; return (""); }
	
	// To get the number of whole columns, divide screen width by colun width and get the even integer
	var nCols = Math.floor( nScrnPx / 370 );
	
	// Calculate the number of rows required to display the list
	var nRows 	= Math.round( nListItems / nCols ) ;

	// If th number of columns to be displayed is <=0, just return
	if ( nCols <= 0 ) { window.status = "Negative number of columns."; return (""); }
	
	// Calculate the total height of the column in pixels.  This is the starting column height.  It will be
	// adjusted later.
	//
	var nColHPx = Math.round( nRows * nLineHPx ) ;

	// Add padding to the bottom of the div for Mozilla type browers
	var nColBottomPad = 20 ; //20 ;
	if ( isGecko() ) { nColBottomPad = 30 ; } // 30
	
	// Set the height of oColParent to the new pixel height of the columns plus some paddin at the bottom.  
	// Width is "auto" and does not have to be set.
	//
	// Make sure not to assign a floating point or negative value to oColParent.style.height.  Both cause problems in
	// Mozilla.  Mozilla requires this to be set, IE does not care.
	
	var cHghtStr = Math.max( nColHPx + nColBottomPad, 0 ) + "px" ;
	oColParent.style.height = cHghtStr ;
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Set up to display the <div> that hold the actual column displays
	//
	var nBaseRow 	= 1 ;
	var cColInnerHTML  	= "" ;

	// Calculate the starting left position of the first column.  This calculation roughtly centers the columns
	var nLeft			= Math.floor( (nScrnPx - ( nColWPx * nCols ) )/2 );

	// If Mozilla, remove the column width padding we added earlier.
	if ( isGecko ) { nColWPx = nColWPx - 20 ; }

	// Declare variables outside the loops
	var cListInnerHTML 	= "" ;	
	var nAdjColHPx			= 0
	var cColHghtList    = ""
	// Add the column <div> and poulate them with the part of the list they are to display
	// 
	for ( i = 0; i < nCols; i++ )
	{

		// Create the new column div
		var oListCol = document.createElement( "div" ) ;
		
		// If the div was not created, just exit with message.
		if ( !oListCol ) { return ( "Unable to clreate list column." ); }
		
		// Add attributs to the column div
		with ( oListCol )
		{
			setAttribute( "id", "searchCol" + i);

			//style.backgroundColor = "#add8e6" ;
			style.cursor 				= "pointer" ;
			style.overflow			= "hidden" ;
			style.position			= "absolute" ;
			style.textOverflow	= "ellipsis" ;
			style.whiteSpace		= "nowrap" ;
			style.zIndex				= nCols - i ;
			
			// Position and size style attributes are set after position = absolute.			
			style.left			= nLeft + "px" ;
			style.top				= "0px"
			style.width			=	nColWPx + "px" ;
			
		}
				
		// Add the column to the document inside oColParent
		oColParent.appendChild( oListCol ) ;
		
		// Setup to show oListColumns.  These columns provide the containers that hold the invidual list items.
		//
		// Find the string segment to be displayed inside oListCol.
		// aList[] already exists -- created above
		for ( j = 0; j < nRows; j++ )
		{
			//  This helps prevent "undefined" items from appearing in the list
			if ( nBaseRow + j >= aList.length ) 
				{	
					break ;
				}
			else
			{
				// Create the div string
				cListInnerHTML = aList[ nBaseRow + j ] ;		
				
				cColInnerHTML = cColInnerHTML + '<div id = "sItem' + i + '-' + j + '" style="overflow:hidden; text-overflow: ellipsis; white-space:nowrap;" onmouseover = "showSearchItemOverlay( this, true )" />' + cListInnerHTML + "</div>" ;	
			
			} // End if/else

		} // endfor
		
		// Clean up cColInnerHTML to remove any "undefined" from the list
		var cColInnerHTML = cColInnerHTML.replace(/undefined<br>/g,'');
	
		// Add the column string segment to oListCol as innerHTML
		oListCol.innerHTML = cColInnerHTML ;
		
		// Now adjust column height to the actual height required to display the list
		//
		// Parse the oListCol.Height property to get just the integer.
		nAdjColHPx = Math.max( nAdjColHPx, oListCol.clientHeight ) ; 

		// Increment pointers
		//
		// Increment nLeft to move the next column to the right of this column
		nLeft = nLeft + nColWPx ;
		// If Mozilla, add a gutter
		if ( isGecko ) { nLeft = nLeft + 20 ; }
	
		//	
		// Increment nBaseRow to point to the next item in aList[] 
		nBaseRow = nBaseRow + nRows;
		
		// Erase the content of cColInnerHTML to prepare for the next loop.		
		cColInnerHTML = "" ;
		
	} // endfor
	
	// Create the searchOvl dif.  This is used in showSearchItemOverlay() moving with the cursor to overlay
	// the current search term
	var oSearchOvl = document.createElement( "div" ) ;
		
	// If the div was not created, just exit with message.
	if ( !oSearchOvl ) { return ( "Unable to clreate search overLay div." ); }
		
	// Add attributs to the column div
	with ( oSearchOvl )
	{
		setAttribute( "id", "searchOvl");

		//style.backgroundColor = "#add8e6" ;
		style.backgroundColor = "yellow" ;
		style.cursor 				= "pointer" ;
		style.display				= "none" ;
		style.fontWeight		= "bold" ;
		//style.visibiility		= "hidden" ;
		style.position			= "relative" ;
		style.whiteSpace		= "nowrap" ;
		style.width					= ( nColWPx * 2 ) + "px" ;
		style.zIndex				= 100 ;
	}
		
	// Add the column to the document inside oColParent
	with ( oColParent )
	{
		appendChild( oSearchOvl ) ;
		
		// Assign the adjusted height to oColParent
		var cHghtStr = nAdjColHPx + nColBottomPad + "px" ;
		oColParent.style.height = cHghtStr ;
	}
	
	return ( "" )
	
} // end showSearchTermListColumns()

/*
=======================================================================================================================
	showThisOldHouse() 		Displays the This Old House section on the navibation (left) panel

		Arguments	None
	
		Returns		Blank string
=======================================================================================================================
*/
function showThisOldHouse()
{
	with ( document )
	{
		// start the This Old House Section.  This is contained in a <div> for formatting
		write('<div style="text-align:center">');
		
		write('<h5 class="reversetext" style="display:inline">We proudly sponsor</h5>');
		write('<br>');
		write('<a class="filterimage" href="http://www.thisoldhouse.com"><img align="center" alt="This Old House" border="O" src="images/ThisOldHouseLogo.jpg"></a>');
		write('<br>');
		write('<h5 class="reversetext" style="display:inline; font-size:80%">');
		write("on Nebraska's PBS Station</h5><br>");
		write('<h5 class="reversetext" style="display:inline">');			
		write("<a class='filterimage' href='http://netnebraska.org/'>");
		write("<img src='/images/net.png' alt='NET TV' style='width:75px'> </a></h5>");
		write('<br>');
		write('<h5 class="reversetext" style="display:inline; font-size:80%">');
		write('See your local listings for show times in your area.</h5>');
		write('<br>');
			
		write('</div>');
		//
		//End of This Old Housesection
	}
	
	return "" ;
	
} // end showThisOldHouse()

/*
=======================================================================================================================
	showTopPanel() 		Displays top panel header that includes the static search bar.
	
		Arguments:			None
		
		Calls:  				showSearchBar()
=======================================================================================================================
*/
function showTopPanel()
{
	with ( document )
	{
		// Top panel should not print
		// Identify the object as a member of the "toppanel" class
		write('<div id="noprint" class="toppanel">');
	
		// Open the div that contains the searchbar
		write('<div class="searchBar">');	

		// This function inserts the searchbar into the top panel.  It returns an empty string.
		write( showSearchbar( googleSearch, false ) );
	
		write('</div>'); // noprint
	
		write('</div>'); // searchbar

	} // endwith( document )
	
	return ("") ; // return a blank string to document.write.
	
} // end showTopPanel()

/*
=======================================================================================================================
	stringTrim() 
				
		Arguments:			cStr		The string to be trimmed
		
		Returns:				(c)			cStr trimmed.
=======================================================================================================================
*/
function stringTrim( cStr )
{
	return cStr.replace(/^\s+|\s+$/g, '') ;
}
// end strngTrim()

/*
=======================================================================================================================
 	testDiv()

		Description:		Creates or deletes a temporty <div> container on a document.  The testDiv is used to get 
										the width and height of a string in pixels.  Getting these values requires that the string
										be placed on the document and formatting applied .  String width and height are dependent 
										on formatting.
 
 		Arguments:			lArg	If any argument is present so that arguments.length > 0, then delete the test object.
								  	Otherwise create a new test object.

 		Return:					A blank string if the process suceeds, null if it fails
=======================================================================================================================
*/

function testDiv( lCreateDiv )
{

	// If this function was called with true, create the test container.  If called with false, 
	//  then delete the test container.  If no argument is passed, then the function assumes that the action is delete.
	if ( !lCreateDiv )
	{
		// We are done with th test <div>, so it can be removed.
		var oTestDiv = document.getElementById( "TestDiv" );
		if ( !oTestDiv ) { window.status = "testDiv: Divider alrady deleted or cannot be found." ; return( null ); }
		
		// Remove the object from document
		document.body.removeChild( oTestDiv );
		
		return ( "" )

	}
	
	// Create the test object and return the ID of the object if it succeeds, otherwise, null.
	
	// To get the length of the list in pixels, place the list inside a divider.
	var oTestDiv = document.createElement( "div" ) ;
	//
  // If the object did not create, exit with message to the status bar.
	if ( !oTestDiv ) { window.status = "testDiv: Test divider did not Create" ; return ( null ) ; }
	
	// Set the attributes for the divider.
	with ( 	oTestDiv ) 
	{
		setAttribute("class", "t14" );
		setAttribute("id", "TestDiv" );
		style.fontFamily 	= "'Courier New', Courier, Serif" ;
		if ( isGecko() ) { style.lineHeight  = "1.41em" ; }
		if ( isIE() )    { style.lineHeight  = "1.23em" ; } 
		style.overflow		= "hidden" ;
		style.position 		= "absolute" ;
		style.textOverflow = "ellipsis" ;
		style.visibility 	= "hidden" ;
		style.whiteSpace	="nowrap" ;
		style.height			= "auto" ;
		style.width  			="auto" ;
		
	}
	//
	// Add the <div> to the document.body.  Since it is invisible it can be added anwhere so we do not
	// care about its position.
	document.body.appendChild( oTestDiv );
	//
 	return( "TestDiv" );
	
} // end testDiv()

