var Current1 = 0;
var Current2 = 0;
var Current3 = 0;
var New1 = 0;
var New2 = 0;
var TopMenu = 'Overview_Detail';
var DetailMenu = 'HANDEL_UKWMO Bunkers_UKWMO Communications_Land Line_Radio';
var Tab11 = 'Detection_Public Warning_Royal Observer Corps_Civilian Government';
var Tab21 = 'HANDEL Warning System_WB400&amp;600_WB1400_Before HANDEL';
var Tab22 = 'ROC Observer Post_ROC Groups and Sectors_RGHQ Locations_Web Links';
var Tab23 = 'Post Comms Era1_Post Comms Era2_Era1 Networks_Era2 Networks_External Links_S+DX_Speech Multiplex';
var Tab24 = 'GPO&gt;BT_EMSS_Other WB&rsquo;s';
var Tab25 = 'MOULD_My Hunt for Masts_Home Office Radio_Emergency Services Era1_Emergency Services Era2';

function WriteMenu(Row1, Row2, Row3)
{
	Current1 = Row1;
	Current2 = Row2;
	Current3 = Row3;
	New1 = Row1;
	New2 = Row2;
	var NavText = '<div class="TabIndex"><ul class="TabList1" id="ml1">';
	NavText += Assemble(TopMenu, "Lev1", Current1);
	NavText += '</ul><ul class="TabList2" id="ml2">';
	Menu = "Subjects";
	if(Row1 == 2)
			Menu = DetailMenu;
	NavText += Assemble(Menu, "Lev2", Current2);
	NavText += '</ul><ul class="TabList3" id="ml3">';
	Menu = Tab11;
	if(Row1 == 2)
		{
			switch(Row2)
			{ case 1: Menu = Tab21; break;
			  case 2: Menu = Tab22; break;
			  case 3: Menu = Tab23; break;
			  case 4: Menu = Tab24; break;
			  case 5: Menu = Tab25; break;
			}
		}
	NavText += Assemble(Menu, "Lev3", Current3);
	NavText += '</ul><p class="right"><a href="SiteIndex.htm">Site Index</a>';
	if(Current3 != 0)
		NavText += '&mdash;<a href="index.htm">HOME PAGE</a>';
	NavText += '</p></div>';
	document.write(NavText);
}

function Assemble(ItemList, Class, n)
{
	var ListArray = ItemList.split("_");
	var ListSize = ListArray.length;
	var LI = '<li class="'+Class;
	var CodeText = "";
	for(x=0;x<ListSize;x++)
	{
		if(x==(n - 1))
		{
			CodeText += LI+'a">'+ListArray[x]+'</li>';
		}else
		{
			CodeText += LI+'i">';
			CodeText += '<a class="mnu" href="JavaScript:SW'+Class+'('+(x+1)+')">'+ListArray[x]+'</a></li>';
		}
	}
	return CodeText;
}

function SWLev1(n)
{
	New1 = n;
	document.getElementById("ml1").innerHTML = Assemble(TopMenu, "Lev1", New1);
	SWLev2(1);
}

function SWLev2(n)
{
	New2 = n;
	Menu = "OverView";
	if(New1 == 2)
			Menu = DetailMenu;
	document.getElementById("ml2").innerHTML = Assemble(Menu, "Lev2", New2);
// Modify Row 3 of Menu
	Menu = Tab11;
	if(New1 == 2)
		{
			switch(New2)
			{ case 1: Menu = Tab21; break;
			  case 2: Menu = Tab22; break;
			  case 3: Menu = Tab23; break;
			  case 4: Menu = Tab24; break;
			  case 5: Menu = Tab25; break;
			}
		}
	var Lev3Selection = 0;
	if((New1 == Current1)&&(New2 == Current2))
		{
			Lev3Selection = Current3;
		}
	document.getElementById("ml3").innerHTML = Assemble(Menu, "Lev3", Lev3Selection);
}

function SWLev3(n)
{
	var NewPage = 'Page'+New1+New2+n+'.htm';
	//window.top.location.replace(NewPage);
	window.top.location.href = NewPage;
}

function IncludeBig()
{
	var CodeText = '<div id="viewer" style="z-index:1000;"><h1 class="viewer">CLOSE Bigger Picture <a href="JavaScript:CloseBig();" style="background-color:red; color:white; text-decoration:none;">&nbsp;&nbsp;X&nbsp;&nbsp;</a></h1><div id="BigScroll"><img src="img/wait.gif" id="BigImg"></div></div>'
	document.write(CodeText);
}

function ShowBig(BigName, iWidth, iHeight)
{
	var myWidth = 0, myHeight = 0;
	var scrOfX = 0, scrOfY = 0;

	if( typeof( window.innerWidth ) == 'number' ) 
	{
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    }
	if( typeof( window.pageYOffset ) == 'number' )
	{
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
    }
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
    {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
    }
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
    {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
    }
    		// set sizes of divs. Offset by 10px
    scrOfY += 10;
    scrOfX += 10;
    var ViewObj = document.getElementById("viewer");
	ViewObj.style.visibility = "visible";
	ViewObj.style.top = scrOfY + "px";
	ViewObj.style.left = scrOfX + "px";
	// To allow a margin of 10px all round reduce by 20px
	myWidth -= 40;
	myHeight -= 40;
	ViewObj.style.width = myWidth + "px";
	ViewObj.style.height = myHeight + "px";
	// make BigScroll larger than image for scroll bars
	iWidth += 30;
	iHeight += 30;
	if(iWidth > (myWidth - 20)) iWidth = myWidth - 20;	// 10px either side
	if(iHeight > (myHeight - 50)) iHeight = myHeight - 50;	//40px H1 and 10px below
	document.getElementById("BigScroll").style.width = iWidth + "px";
	document.getElementById("BigScroll").style.height = iHeight + "px";
	document.getElementById("BigImg").src = BigName;
//	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
}

function CloseBig()
{
    var ViewObj = document.getElementById("viewer");
	ViewObj.style.visibility = "hidden";
	ViewObj.style.width = "100px";
	ViewObj.style.height = "100px";
	document.getElementById("BigScroll").style.width = "100px";
	document.getElementById("BigScroll").style.height = "100px";
//	document.getElementsByTagName('html')[0].style.overflow = '';
}
