var defaultHeader = "/GBBMain/Home%20Header.htm";
var defaultSidebar = "/GBBMain/Sidebar.htm";
var defaultMain = "/GBBMain/Home.htm";

var headerFrameName = "gBB_TopNavBar";
var sideFrameName = "gBB_SideNavBar";
var mainFrameName = "gBB_MainWindow";


// Calling syntax:

//	General
//	ForceFrameSetup("MainContent.htm", "Header.htm", "Sidebar.htm");

//	From within a main content window:
//	ForceFrameSetup(window.location.href, "TheHeaderForThisContent.htm", defaultSidebar);

//	From within a header window:
//	ForceFrameSetup("", window.location.href, defaultSidebar);

//	From within a sidebar window:
//	ForceFrameSetup("", "", window.location.href);

function ForceFrameSetup(docMain, docHeader, docSidebar)
{
	// If we're displaying this page standalone (like from a search engine), force the correct
	//	frame structure
	if( top.location.href.indexOf("GBBindex.html") == -1 &&
		top.location.href.indexOf("GBBindexDynFrames.htm") == -1 )
		// Pass all these page parameters to our handy-dandy dynamic-frames displayer
		top.location.replace("/GBBindexDynFrames.htm?" + docMain + "&" + docHeader + "&" + docSidebar);
	
	// else, if we're already in the correct frame structure, force the correct pages within the frames
	else
	{
		// Record window location objects
		var objHeaderLoc = top.frames(headerFrameName).window.location;
		var objSidebarLoc = top.frames(sideFrameName).window.location;
		var objMainLoc = top.frames(mainFrameName).window.location;
			
		// If a page name was supplied for a frame, and it is not already being displayed in that frame,
		//	display it there
		if( docHeader != "" && objHeaderLoc.href.indexOf(docHeader) == -1 ) objHeaderLoc.replace(docHeader);
		if( docSidebar != "" && objSidebarLoc.href.indexOf(docSidebar) == -1 ) objSidebarLoc.replace(docSidebar);
		if( docMain != "" && objMainLoc.href.indexOf(docMain) == -1 ) objMainLoc.replace(docMain);

		// If any frames are still empty, fill them
		if( objHeaderLoc.href == "" || objHeaderLoc.href == "about:blank" ) objHeaderLoc.replace(defaultHeader);
		if( objSidebarLoc.href == "" || objSidebarLoc.href == "about:blank" ) objSidebarLoc.replace(defaultSidebar);
		if( objMainLoc.href == "" || objMainLoc.href == "about:blank" ) objMainLoc.replace(defaultMain);
	}
}
