function getCheckedFilters(){
    checkedFilters=new Array();
    var numOfCheckedFilters=0;
	var filters = document.filterForm.elements;
	try {
		for (i=0;i<filters.length;i++){
			if (filters[i].checked){
				checkedFilters[numOfCheckedFilters]={key:filters[i].id,value:"true"};
				numOfCheckedFilters++;
			}
		}
    } catch (e) {}
    return checkedFilters;
}



// leftover function from purtilo tinkering
function pause(millisecondi) {
      var now = new Date();
      var exitTime = now.getTime() + millisecondi;
      while(true)
      {
	now = new Date();
	if(now.getTime() > exitTime) return;
      }
}



function setMapLocation(textName) {
    var fieldName;
    if (textName == "startLoc")
	fieldName = "routingStartTextField";
    else if (textName == "endLoc")
	fieldName = "routingStopTextField";
    else return;
    var value = document.getElementById(fieldName).value;
    if (value == "Custom location") {
	clearError(fieldName);
	return;  //it's okay, no need to do this function
    }
    // create the object
    var param = {
	input: value
    };
    var paramString = JSON.stringify(param);
    
    /// make the getBuildingsInfo query
    setMessage("Finding building information...");
    if (textName == "startLoc")
	ajax("getBuildingInfo", paramString, setStartLocation);
    else if (textName == "endLoc")
	ajax("getBuildingInfo", paramString, setStopLocation);
}

/**
 *	@function setStartLocation
 *	Called from 
 */
function setStartLocation() {
    if (xmlHttp.readyState == 4 && xmlHttp.responseText.length > 0) {
		var respJSON;
		try {
			respJSON = eval('('+xmlHttp.responseText+')');
		} catch (e) {
			setError("routingStartTextField", "Error: Building name in start field does not exist.");
			removeStartMark();
			//alert("Could not eval json string " + xmlHttp.reponseText+ " " + e.description);
			return false;
		}
		//setDebug1("x: "+respJSON.x+" y: "+respJSON.y);
		if (respJSON.x == null || respJSON.y == null) {
			setError("routingStartTextField", "Error: Building name in start field does not exist.");
			removeStartMark();
			return;
		}
		var lonlat = lonLatToMercator(new OpenLayers.LonLat(respJSON.x / 10000000, respJSON.y / 10000000));
		if (startMark != null) markers.removeMarker(startMark);
		startMark = new OpenLayers.Marker(lonlat, startIcon.clone());
		startPos = lonlat;
		markers.addMarker(startMark);
		setMessage("Building found.");
		if (stopPos != null) setTimeout('compute()', 100);
    }
}
function setStopLocation() {
    if (xmlHttp.readyState == 4 && xmlHttp.responseText.length > 0) {
		var respJSON;
		try {
		    respJSON = eval('('+xmlHttp.responseText+')');
		} catch (e) {
		    setError("routingStopTextField", "Error: Building name in stop field does not exist.");
		    removeStopMark();
		    //alert("Could not eval json string " + xmlHttp.reponseText+ " " + e.description);
		    return false;
		}
		if (respJSON.x == null || respJSON.y == null) {
		    setError("routingStopTextField", "Error: Building name in stop field does not exist.");
		    removeStopMark();
		    return;
		}
		var lonlat = lonLatToMercator(new OpenLayers.LonLat(respJSON.x / 10000000, respJSON.y / 10000000));
		if (stopMark != null) markers.removeMarker(stopMark);
		stopMark = new OpenLayers.Marker(lonlat, stopIcon.clone());
		stopPos = lonlat;
		markers.addMarker(stopMark);
		setMessage("Building found.");
		if (startPos != null) setTimeout('compute()', 100);  
    }
}
