
//***********************************************	
//***************** FUNCTIONS *******************
//***********************************************

//*******************START UP FUNCTIONS *********

// start up
function startUp() {
	setTool(document.frmMain.tool.value);
	showPanel(document.frmMain.panel.value);
	setZoomBoxSettings();
	showGlow(0,0);
}



//*******************TOOL FUNCTIONS *************

//set tool
function setTool(sTool){
	setToolImage(sTool);
	document.frmMain.tool.value = sTool;
}


//set tool image
function setToolImage(sTool){
	sOldTool = document.frmMain.tool.value;
	theOldImg = eval("document.B_"+sOldTool);
	theOldImg.src = "images/b_"+sOldTool+"_off.gif";
	theNewImg = eval("document.B_"+sTool);
	theNewImg.src = "images/b_"+sTool+"_on.gif";
}

//set cmd
function setCmd(sCmd){
	document.frmMain.cmd.value = sCmd;
	//document.getElementById("imgMap").click();
	document.frmMain.submit();
	showLayer("Splash");
}


//*******************PANEL FUNCTIONS *********
//hide panels
function hidePanel(){
	sOldPanel = document.frmMain.panel.value;
	theOldImg = eval("document.T_"+sOldPanel);
	theOldImg.src = "images/t_"+sOldPanel+"_off.gif";
	hideLayer(sOldPanel);
}

//show panel
function showPanel(sPanel){
	hidePanel();
	theImg = eval("document.T_"+sPanel);
	theImg.src = "images/t_"+sPanel+"_on.gif";
	showLayer(sPanel);
	document.frmMain.panel.value = sPanel;
	thePanel = document.getElementById("PanelBG");
	thePanel.scrollTop = 0;	
}

//*******************FIND FUNCTIONS *********

//do find
function doFind(){
	theForm = document.frmMain;
	addr = theForm.txtAddr.value;
	zip = theForm.txtZip.value;
	sch = theForm.ddlSchool.options[theForm.ddlSchool.options.selectedIndex].value;
	route = theForm.ddlRoute.options[theForm.ddlRoute.options.selectedIndex].value;
	chk = addr + sch + route;
	if(chk.length == 0){
		alert("Please enter an address or select a school.");
	} else {
		theForm.schoollist.value = "";
		theForm.selschool.value = "";
		theForm.selroute.value = "";
		if(addr.length > 0){
			setCmd("FINDADDR");
		}
		if(sch.length > 0){
			setCmd("SELECTSCHOOL");
		}
		if(route.length > 0){
			setCmd("SELECTROUTE");
		}
	}
}

//do clear
function doClear(){
	doClearForm();
	setCmd("CLEAR");
}

//do clear form
function doClearForm(){
	document.frmMain.txtAddr.value = "";
	document.frmMain.txtZip.value = "";
	document.frmMain.ddlSchool.selectedIndex = 0;
	document.frmMain.ddlRoute.selectedIndex = 0;
	document.frmMain.locX.value = "";
	document.frmMain.locY.value = "";
	document.frmMain.loc.value = "";
	document.frmMain.schoollist.value = "";
	document.frmMain.selschool.value = "";
	document.frmMain.selroute.value = "";
	document.frmMain.neareststops.value = "";
}

//select location
function selectLocation(x, y, locAddr){
	document.frmMain.locX.value = x;
	document.frmMain.locY.value = y;
	document.frmMain.loc.value = locAddr;
	setCmd("SELECTLOCATION");
}


//select school
function selectSchool(sSchool){
	document.frmMain.selschool.value = sSchool;
	setCmd("REMAP");
}

//select route
function selectRoute(sRoute){
	document.frmMain.selroute.value = sRoute;
	setCmd("REMAP");
}

//****************** KEY DOWN FUNCTIONS ********

//search key down
function searchKeyDown(event){
	if(event.keyCode == 13){
		window.event.keyCode = 0;
		doFind();
	}else{
		document.frmMain.ddlSchool.selectedIndex = 0;
		document.frmMain.ddlRoute.selectedIndex = 0;
	}
}

//activate School search
function activateSchoolSearch(event){
	theForm = document.frmMain;
	theForm.txtAddr.value = "";
	theForm.txtZip.value = "";
	theForm.ddlRoute.selectedIndex = 0;
}

//activate route search
function activateRouteSearch(event){
	theForm = document.frmMain;
	theForm.txtAddr.value = "";
	theForm.txtZip.value = "";
	theForm.ddlSchool.selectedIndex = 0;
}


//****************** HELP FUNCTIONS ************

// show help
function showHelp(sTopic){
	helpURL = "help.htm"+"#"+sTopic;
	if (typeof helpWin == 'undefined'){
		helpWin = window.open(helpURL, "Help", "width=600,height=800,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=300,top=0");
		helpWin.opener = self;
	} else {
		if (helpWin.closed){
			helpWin = window.open(helpURL, "Help", "width=600,height=800,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=300,top=0");
			helpWin.opener = self;
		} else {
			helpWin = window.open(helpURL, "Help", "width=600,height=800,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=300,top=0");			
			helpWin.focus();
		}
	}
}





