	function getSwitch () {
		var hr = window.location.href;
		debug ("href " + hr);
		if (isDl)
			hr = hr.replace(/\/sgdl/, "/sgl");
		else
			hr = hr.replace(/\/sgl/, "/sgdl");
		debug ("becomes " + hr, 1);
		return hr;
	}
	
	function init() {
		// isDev = 0;
		// return;
		if (!isDev) {
			getEl("loginFormName").value = "";
			getEl("loginFormPw").value = "";
		}
		debug ("href=" + window.location.href + ", isDl=" + isDl, 1);
		getEl("ldlMapButton").href = getSwitch();
		menu(menuHome);
		dispEl ("showTree", isDevInt);
		dispEl ("debug", isDevInt);
		debugText ("About to call newRequest", 1);
		HTTP.getText("sg_summgrid_inject.php", domInject, "DOMsummGrid", initDOMsummGrid);
	  waitForLoad.Cnt = 0; 
		// getEl("bannerAdFrame").window.location.replace ("banner-add04.html");
		waitForLoad.timerId = setInterval("waitForLoad()",100);
		//changeBannerAd();				// set random add first time round
		//changeBannerAd.timerId = setInterval("changeBannerAd()", 60000); // .. and change every minute
	}
	/*
	function changeBannerAd() {
		window.frames["bannerAdFrame"].window.location.replace ("banner-add0" + Math.floor(Math.random()*7.99 + 1) + ".html");		
	} // changeBannerAd
	*/
	function initDOMsummGrid() {
		summGridLoaded = 1;
		showNSummRows(nNominees);
		if (menu.currMen == menuHome)	{			// will be waiting for us to finish
			loadOff();
			dispEl ("DOMsummGrid", 1);
		}
		setTimeout (getHomePageStats, 1000);
	}
	function completeInit() {
		populateSummGrid();		// populate summary grid
		if (isDl) {
			var tit = document.title;
			var p = tit.lastIndexOf(' ');
			tit = tit.substr(0,p) + ' DEPUTY' + tit.substr(p);
			document.title = tit;
			getEl("mastheadBanner").src = "images/sgbandpm.png";
		}
		setDocTitle();
		loadOff();
		debugText ("Loaded: screen.width = " + screen.width, 1);
		debug ("Browser: " + navigator.appName + " version " + navigator.appVersion, 1);
		debug ("isIE: " + isIE, 1);
																																																						/*
																																																						if (isDev) {
																																																							// submitLogin(4);
																																																							return;
																																																						}
																																																						*/
																																																						if (userNo) {
																																																							submitLogin(userNo);
																																																							return;
																																																						}
		getEl("loginFormName").focus();
		getEl("loginFormName").select();
		// HTTP.getText("sg_mp_sel_inject.php", domInject, "DOMmpSel", initMpSel);
			// gets DOM injection text; calls function domInject on completion, with final two params
	}
	
	function waitForLoad() {
	// This waits until  we are reloaded (inUpdate set false by loading script)
		if ((mainLoaded && summGridLoaded) || (waitForLoad.Cnt >= 100)) {
			clearInterval(waitForLoad.timerId);
			completeInit()
		}
		else {
			waitForLoad.Cnt++;
		}
	} // waitForLoad
	
