//**************************************************************
//* GLOBALS
//**************************************************************
var glCurButton = null;
//**************************************************************


//**************************************************************
//* FUNCTION: ChangeFrame
//**************************************************************
function ChangeFrame(buttonNumber,location)
{
	var color;
	var header = FindHeader();

	var curStatus = window.status;
	if (location == null)
	{
		location = header.glCurLocation;
		if (location == null)
			return;
	}

	//*****************************************
	//SHOW THE CHECKOUTBUTTON
	//*****************************************
	if (header.glNumOrders > 0)
	{
		if (NETSCAPE)
		{
			header.document.CheckOutButton.visibility = "show";
			header.document.PrintButton.visibility = "hide";
		}
		else
		{
			header.CheckOutButton.style.visibility = "visible";
			header.PrintButton.style.visibility = "hidden";
		}
	}
	else
	{
		if (NETSCAPE)
		{
			header.document.CheckOutButton.visibility = "hide";
			header.document.PrintButton.visibility = "hide";
		}
		else
		{
			if (header.CheckOutButton)
			{
				header.CheckOutButton.style.visibility = "hidden";
			}
			if (header.PrintButton)
			{
				header.PrintButton.style.visibility = "hidden";
			}
		}
	}
	//*****************************************

	//*****************************************
	//RESET ALL THE BUTTONS FIRST
	//*****************************************
	ResetMenuButtons();
	//*****************************************

	//*****************************************
	//SET THE ACTIVE BUTTON:
	//*****************************************
	SetActiveButton(buttonNumber);
	//*****************************************

	header.glCurLocation = location;

	switch(location)
	{
		case 'HOME':
			ChangeHomeFrame(buttonNumber);
			break;
		case 'FRATERNAL':
			ChangeFraternalFrame(buttonNumber);
			break;
		case 'OTHER':
			ChangeOtherFrame(buttonNumber);
			break;
		default:
			break;
	}
	window.status = curStatus;
}
//**************************************************************

//**************************************************************
//* FUNCTION: ChangeHomeFrame
//**************************************************************
function ChangeHomeFrame(buttonNumber)
{
	var newMainURL = null;
	var newTOCURL  = null;
	var header     = FindHeader();

	header.glCurHomeButton = buttonNumber;
	
	switch (buttonNumber)
	{
		case 1:
			newMainURL = homeURL + "/main.htm";
			newTOCURL  = homeURL + "/mainTOC.htm"
			break;
		case 2: //FRATERNAL
			//newMainURL = homeURL + "/fraternal/main.htm";
			newMainURL = homeURL + "/main.htm";
			newTOCURL  = homeURL + "/fraternal/fraternalTOC.htm"
			break;
		case 3: //OTHER
			//newMainURL = homeURL + "/fraternal/main.htm";
			newMainURL = homeURL + "/main.htm";
			newTOCURL  = homeURL + "/other/otherTOC.htm"
			break;
		case 4: //ABOUT KEN
			newMainURL = homeURL + "/aboutKen.htm";
			//newTOCURL  = homeURL + "/mainTOC.htm"
			break;
		default:
			break;
	}

	if (newMainURL != null)
	{	
		if (parent.MAIN.location.href != newMainURL)
		{
			parent.MAIN.location.href = newMainURL;
		}
	}

	if (newTOCURL != null)
	{
		if (parent.TOC.location.href != newTOCURL)
		{
			parent.TOC.location.href  = newTOCURL;
		}
	}
}
//**************************************************************

//**************************************************************
//* FUNCTION: ChangeFraternalFrame
//**************************************************************
function ChangeFraternalFrame(buttonNumber)
{
	var newMainURL = null;
	var newTOCURL  = null;

	switch (buttonNumber)
	{
		case 1:
			newMainURL = homeURL + "/main.htm";
			newTOCURL  = homeURL + "/mainTOC.htm"
			break;
		case 2:
			newMainURL = homeURL + "/fraternal/easternStar.htm";
			break;
		case 3:
			newMainURL = homeURL + "/fraternal/mason.htm";
			break;
		case 4:
			newMainURL = homeURL + "/fraternal/shriner.htm";
			break;
		case 5:
			newMainURL = homeURL + "/fraternal/yorkRite.htm";
			break;
		case 6:
			newMainURL = homeURL + "/fraternal/scottishRite.htm";
			break;
		case 7:
			newMainURL = homeURL + "/fraternal/rainbow.htm";
			break;
		case 8:
			newMainURL = homeURL + "/fraternal/youth.htm";
			break;
		case 9:
			newMainURL = homeURL + "/fraternal/other.htm";
			break;

		default:
			break;
	}	

	if (newMainURL != null)
	{	
		if (parent.MAIN.location.href != newMainURL)
		{
			parent.MAIN.location.href = newMainURL;
		}
	}

	if (newTOCURL != null)
	{
		if (parent.TOC.location.href != newTOCURL)
		{
			parent.TOC.location.href  = newTOCURL;
			//alert(parent.TOC.location.href);
		}
	}
}
//**************************************************************

//**************************************************************
//* FUNCTION: ChangeOtherFrame
//**************************************************************
function ChangeOtherFrame(buttonNumber)
{
	var newMainURL = null;
	var newTOCURL  = null;

	switch (buttonNumber)
	{
		case 1: //HOME
			newMainURL = homeURL + "/main.htm";
			newTOCURL  = homeURL + "/mainTOC.htm"
			break;
		case 2: //LICENSE PLATE
			newMainURL = homeURL + "/other/licensePlate.htm";
			break;
		case 3: //STANDARD BADGES
			newMainURL = homeURL + "/other/standardBadges.htm";
			break;
		case 4: //TAGS
			newMainURL = homeURL + "/other/tags.htm";
			break;
		case 5: //LABELS
			newMainURL = homeURL + "/other/labels.htm";
			break;
		case 6: //PREDEFINED
			newMainURL = homeURL + "/other/preDefined.htm";
			break;
		default:
			break;
	}	

	if (newMainURL != null)
	{	
		if (parent.MAIN.location.href != newMainURL)
		{
			parent.MAIN.location.href = newMainURL;
		}
	}

	if (newTOCURL != null)
	{
		if (parent.TOC.location.href != newTOCURL)
		{
			parent.TOC.location.href  = newTOCURL;
			//alert(parent.TOC.location.href);
		}
	}
}
//**************************************************************

//**************************************************************
//* FUNCTION: ResetMenuButtons
//**************************************************************
function ResetMenuButtons()
{
	var buttons;
	var evalStr;
	
	buttons = document.images;
	for (var imageNumber=0; imageNumber < buttons.length;imageNumber++)
	{
		evalStr = "document.images[" + imageNumber + "].src=button" + (imageNumber+1) + "Off.src"
		eval(evalStr);
	}
}
//**************************************************************

//**************************************************************
//* FUNCTION: SetActiveButton
//**************************************************************
function SetActiveButton(buttonNumber)
{
	var evalStr;
	var header = FindHeader();
	var imageNumber = buttonNumber-1;

	evalStr = "document.images[" + imageNumber + "].src=button" + buttonNumber + "On.src"
	eval(evalStr);
	glCurButton   = buttonNumber;
}
//**************************************************************


