
if(navigator.userAgent.indexOf("Opera")!=-1) GetBrowserType = "opera"
else if(navigator.appName == "Microsoft Internet Explorer") GetBrowserType = "ie"
else if(navigator.appName == "Netscape") GetBrowserType = "ns";

// IE version detection...
var verDetect = navigator.userAgent.toLowerCase();
function checkIt(string) {
	place = verDetect.indexOf(string) + 1;
	thestring = string;
	return place;
}
ieVersion = "";
if (checkIt('msie')) { ieVersion = verDetect.charAt(place + thestring.length); }


GetBrowserPlatform = "";
if(navigator.userAgent.indexOf("Mac_PowerPC")!=-1 || navigator.userAgent.indexOf("Macintosh")!=-1) GetBrowserPlatform = "mac";

storeMenuIndex = null;
storeButtonState = null;
storeThisElement = null;
menuActive = false;
menuTimeout = null;

drop1 = null;
drop2 = null;
drop3 = null;
drop4 = null;
drop5 = null;
drop6 = null;
drop7 = null;
drop8 = null;
drop9 = null;
drop10 = null;


function showMenu(menuIndex,buttonState,thisElement) {
	cancelHideMenu();
	if(menuActive && menuIndex!= storeMenuIndex) doHideMenu();
	if(!menuActive) {
		storeMenuIndex = menuIndex;
		storeButtonState = buttonState;
		storeThisElement = thisElement;
																	// TEXT ON MENU BUTTONS	
		if(buttonState==0) thisElement.className='MenuInactiveOver'  // inactive
		else if(buttonState==1) thisElement.className='MenuOffOver'  // active but not highlighted
		else if(buttonState==2) thisElement.className='MenuOnOver';  // highlighted
		
		if(SubMenuStrings[menuIndex].length > 0) {
			
			// Work out menu position
			SubMenuWidth = 170;
			
			ButtonOffset = document.getElementById('Spacer' + menuIndex).offsetLeft + 134; // use end number to tweak drop-down x pos
			if (menuIndex == 0) { ButtonOffset += 20; } // for "About iprism" (left-hand) menu drop-down only
			
			MenuAlign = "left";
			if((ButtonOffset + SubMenuWidth) > 746) {
				// Work menu position aligned right to next spacer div
				ButtonOffset = document.getElementById('Spacer' + (menuIndex+1)).offsetLeft;
				ButtonOffset -= SubMenuWidth;
				MenuAlign = "right";
			}
		
			// Write menu links
			buildMenu = "<DIV align='" + MenuAlign + "'>" + SubMenuStrings[menuIndex] + "</DIV>";
			document.getElementById('DropDownMenu').innerHTML = buildMenu;
			
			// Set position of menu + make visible
			if(GetBrowserType == "ns" || GetBrowserType == "opera") {
				document.getElementById('DropDownMenu').style.left = ButtonOffset + "px";
			} else {
				document.getElementById('DropDownMenu').style.posLeft = ButtonOffset;
				if (ieVersion < 7) { hideSelectLists(); }// *** for IE (pre v7) Select layering headache ***
			}
			document.getElementById('DropDownMenu').style.zIndex = 100;
			animateMenu();
		}
		menuActive = true;
	}
}

function animateMenu() {

	// Get depth of current menu
	menuHeight = document.getElementById('DropDownMenu').offsetHeight;
	
	// Position mask;
	if(GetBrowserType == "opera" && GetBrowserPlatform == "mac") {
		EdgeOffset = document.getElementById('MenuHeader').offsetLeft - 2;
	} else {
		EdgeOffset = document.getElementById('HeaderGreyOutline').offsetLeft + document.getElementById('MenuHeader').offsetLeft;
	}
	MenuOffset = document.getElementById('MenuArea').offsetLeft;
	xPos = MenuOffset + EdgeOffset;
	if(GetBrowserType == "ns" || GetBrowserType == "opera") {
		document.getElementById('DropDownMenuMask').style.left = xPos + "px";
	} else {
		document.getElementById('DropDownMenuMask').style.posLeft = xPos;
	}
	
	// Show menu
	drop1 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.9)) + ");",40);
	drop2 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.8)) + ");",80);
	drop3 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.7)) + ");",120);
	drop4 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.6)) + ");",160);
	drop5 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.4)) + ");",200);
	drop6 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.2)) + ");",240);
	drop7 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.1)) + ");",280);
	drop8 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.05)) + ");",320);
	drop9 = setTimeout("menuDrop(" + (0 - (menuHeight * 0.025)) + ");",360);
	drop10 = setTimeout("menuDrop(0);",400);
}

function menuDrop(getTop) {
	document.getElementById('DropDownMenuMask').style.visibility = "visible";
	document.getElementById('DropDownMenu').style.visibility = "visible";
	if(GetBrowserType == "ns" || GetBrowserType == "opera") document.getElementById('DropDownMenu').style.top = getTop + "px";
	else document.getElementById('DropDownMenu').style.posTop = getTop;
}
	

function hideMenu() {
	menuTimeout = setTimeout("doHideMenu();",200);
}

function doHideMenu() {

	if(storeThisElement != null) {
																		// TEXT ON MENU BUTTONS	
		if(storeButtonState==0) storeThisElement.className='MenuInactive' // inactive
		else if(storeButtonState==1) storeThisElement.className='MenuOff' // active but not highlighted
		else if(storeButtonState==2) storeThisElement.className='MenuOn'; // highlighted
		
		document.getElementById('DropDownMenu').style.visibility = "hidden";
		document.getElementById('DropDownMenuMask').style.visibility = "hidden";
		storeMenuIndex = null;
		storeButtonState = null;
		storeThisElement = null;
		menuActive = false;
		clearTimeout(drop1);
		clearTimeout(drop2);
		clearTimeout(drop3);
		clearTimeout(drop4);
		clearTimeout(drop5);
		clearTimeout(drop6);
		clearTimeout(drop7);
		clearTimeout(drop8);
		clearTimeout(drop9);
		clearTimeout(drop10);
		drop1 = null;
		drop2 = null;
		drop3 = null;
		drop4 = null;
		drop5 = null;
		drop6 = null;
		drop7 = null;
		drop8 = null;
		drop9 = null;
		drop10 = null;
		if ((GetBrowserType == "ie") && (ieVersion < 7)) { showSelectLists(); } // *** for IE (pre v7) Select layering headache ***
	}
}

function cancelHideMenu() {
	clearTimeout(menuTimeout);
	menuTimeout = null;
}

function doNoLink() {
	clearTimeout(menuTimeout);
}

function doLoginMessage() {
	alert ("Please Log-in to access this page.  ");
}

function doStepsMessage() {
	alert ("Please complete the preceding Steps before accessing this page.  ");
}

var totalSteps = 0; // used by function 'showStepInfo'

// **************** menu externalisation... ****************
function createMenu (loggedIn, btnHL, Qset, subHL) { // all parameters are integer
// (logged in?, which top button to highlight, which Qset we're in, which drop-down item to highlight)

	document.writeln ('<div id="HeaderShadowContainer"><div id="HeaderGreyOutline"><div id="MenuHeader"></div></div></div>');
	document.writeln ('<div id="PageShadowContainer"><div id="PageGreyOutline"><div id="PageWhite">');
	document.writeln ('<div id="MenuOuter">');
	document.writeln ('<div id="MenuArea">');
	
	document.writeln ('<script type="text/javascript">'); // Can't figure out why, but the dropdowns
	document.writeln ('var MenuTotal = 7;'); // won't work without these 2 javascript lines
	document.writeln ('var SubMenuStrings = new Array();'); // being added using "document.writeln"
	document.writeln ('</script>');
	
	
	// ******* DROP DOWN LINKS *******
	// for button 1 (About iprism)
	btnID = 0;
	SubMenuStrings[btnID] = ""
	
	
	// for button 2 (Contact)...
	btnID = 1;
	SubMenuStrings[btnID] = "";
	
	
	// for button 3 (Get a Quote)...
	btnID = 2;
	SubMenuStrings[btnID] = "";
	
		

	// for button 4 (My Account)
	btnID = 3;
	SubMenuStrings[btnID] = "";

	// for button 5 ( Documents )
	btnID = 4;	
	SubMenuStrings[4] = "";
	
	// for button 6 ( Home )
	btnID = 5;	
	SubMenuStrings[5] = "";
	
	// ******* end of "make DROP-DOWN LINKS" *******
	
	

	// ******* make TOP BUTTONS *******
	document.writeln ("<div id='Spacer0' class='MenuButtonFirstSpacer'></div>");
	
	btnID = 1;
	btnText = "Home";
	btnLink = "'index.asp' accesskey='1' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");
	
	document.writeln ("<div id='Spacer1' class='MenuButtonSpacer'></div>");
	
	btnID = 2;
	btnText = "About Us";
	btnLink = "'aboutus.asp' accesskey='2' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");
	
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");

	btnID = 3;
	btnText = "Sales";
	btnLink = "'sales.asp' accesskey='3' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");
	
	document.writeln ("<div id='Spacer3' class='MenuButtonSpacer'></div>");
	
	btnID = 4;
	btnText = "Lettings";
	btnLink = "'lettings.asp' accesskey='4' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");
	
	document.writeln ("<div id='Spacer4' class='MenuButtonSpacer'></div>");

	btnID = 5;
	btnText = "Around Harwich & Dovercourt";
	btnLink = "'around.asp' accesskey='2' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");
	
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");

	btnID = 6;
	btnText = "Contact Us";
	btnLink = "'contactus.asp' accesskey='h' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()'>" + btnText + "</a>");	

	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	document.writeln ("<div id='Spacer2' class='MenuButtonSpacer'></div>");
	btnID = 7;
	btnText = "Admin";
	btnLink = "'http://www.oldchelmsfordians.com/corymaintenance/index.asp' accesskey='h' ";
	if (btnHL != btnID) { btnClass = "class='MenuOff' "; btnParam = 1; } else { btnClass = "class='MenuOn' "; btnParam = 2; }
	document.writeln ("<a href=" + btnLink + btnClass + "onMouseover='showMenu(" + [btnID-1] + "," + btnParam + ",this)' onclick='doHideMenu' onMouseout='hideMenu()' target='_blank'>" + btnText + "</a>");	

	document.writeln ("<div id='Spacer5' class='MenuButtonLastSpacer'></div>");
	document.writeln ("</div>");
	document.writeln ("</div>");
	document.writeln ("<div id='DropDownMenuMask'><div id='DropDownMenu' onMouseover='cancelHideMenu()' onMouseout='hideMenu()'></div></div>");
	document.writeln ("</div></div></div>");
	// ******* end of "make TOP BUTTONS" *******
}
// ********************* end of "createMenu" function *********************


// The functions below are a work-around for the IE select list layering headache...
// hiding offending select lists on menu drop-down or bubble-help popup activation, and re-showing them on menu rolloff
// The array "selectList" is defined in the Header of each individual HTML page, if necessary.
// The functions "hideXtra" & "showXtra" are in "iprism-core.js"

var selectList=new Array (0); // default for all "no problem" pages
// this Array is re-built in the Head of each HTML page if there any drop-down select lists on the page.

function hideSelectLists () {		
	if (selectList.length > 0) {
		//alert ('selectList.length =' + selectList.length + '   (Hiding)');
		var i=0; 
		for (i=0; i<selectList.length; i++) {
			hideXtra(selectList[i]);
			showXtra(selectList[i] + 'x');
		} 	
	}	
}

function showSelectLists () {
	if (selectList.length > 0) {
		//alert ('selectList.length =' + selectList.length + '   (RE-showing)');
		var i=0; 
		for (i=0; i<selectList.length; i++) {
			showXtra(selectList[i]);
			hideXtra(selectList[i] + 'x');
		}
	}
}