// map a list of mlsNumbers

var   mapWin = "toolbar=0,status=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1"  

var customMapType = "r"; //Sets a default type, only applies if the custom code variable useCustomMapType is present and set to true - JDB 8/29/2007 VI#95731

if(typeof(debugMap)!="undefined" ) {
   mapWin = "toolbar=1,status=1,location=1,directories=0,menubar=1,scrollbars=1,resizable=1"; // debug version
}


function MapMlsNum(uid, prp, sInitService){
///alert('mapmlsnum')
	// I've replaced the original code for the mapping window with the following, which populates hidden
	// fields in a new form on the srh.asp page and then submits it to a new window. I did this because
	// the querystring created by the original code was too long if all properties were selected from
	// a quick search with more than 200 results. Please see srh.asp for more info. ~ MBS ~ 06/19/02
  
  if (typeof(top.mappingWindow) != "undefined" && top.mappingWindow != null) { top.mappingWindow.close(); }
  
  top.mappingWindow = window.open("", "Mapping", mapWin  );
  
  if ((typeof (sInitService) == "undefined") ||(sInitService=="undefined")){
	 top.mappingWindow.location.href = "/search/mapping/mapSql.asp?prp=" +prp+"&where="+ escape("uid in("+uid+")");
  }else{
	top.mappingWindow.location.href = "/search/mapping/mapSql.asp?prp=" +prp+"&where="+ escape("uid in("+uid+")")+"&InitService="+sInitService;
  }

/*
	if(typeof(document.frmMap) != "undefined") {
		document.frmMap.prp.value = prp;		
		document.frmMap.where.value = "uid in (" + uid + ")";
		document.frmMap.target= "Mapping";
		document.frmMap.submit();
	}
	else {
		top.mappingWindow.location.href = "/search/mapping/mapSql.asp?prp=" +prp+"&where="+ escape("uid in("+uid+")");
	}
	*/
	top.mappingWindow.focus();
}

function MapPublic(PropertyID){
	window.open("/VEMapping/defaultPublic.asp?action=public&prp=MLS"+"&mlslist="+PropertyID,"PublicMap","width=800,height=600,location=no,menubar=yes,status=no,toolbar=no,scrollbars=yes,resizable=yes");
}

function ButtonInit() {
////nomapServer defined in /SearchDetail/Scripts/DefaultUtl.asp
   if( ( parent.frames[0].nomapServer != 'undefined' ) && ( parent.frames[0].nomapServer == 'true') ) {
      return;
      }

	  
   var clearMap  =  ''

   if (document.all("LongitudeMax").value != "") {
      clearMap  = '<input TYPE="button" VALUE="Map Clear"  ONCLICK="clearMapBB()">'


     if (  document.all("latLong")!=null ) {
         // if we are on the custom search, then show latlong values
         document.all("latLong").innerHTML = 
         document.all("LongitudeMin").value  +"< longitude < " + document.all("LongitudeMax").value + "<br>"
        +document.all("LatitudeMin").value   +"< latitude < "  + document.all("LatitudeMax").value;
        
        if (typeof(top.main.SearchFrame.document.all("MapShapeSearch"))!="undefined"&&top.main.SearchFrame.document.all("MapShapeSearch")!=null){
			if (top.main.SearchFrame.document.all("MapShapeSearch").value.indexOf("POLY") > 0) {
				document.all("latLong").innerHTML = "Polygon Search Area Defined";
			}else if (top.main.SearchFrame.document.all("MapShapeSearch").value.indexOf("POLY") > 0) {
				document.all("latLong").innerHTML = "Circle Search Area Defined";
			}
        }
      }
   } else if (  document.all("latLong")!=null ) {
      // no lat/long so clear
      document.all("latLong").innerHTML = "";
   }

   if(document.all("mapClear")!=null) document.all("mapClear").innerHTML = clearMap;
   if(document.all("mapClear2")!=null) document.all("mapClear2").innerHTML = clearMap;
}


function clearMapBB() {
   top.main.SearchFrame.document.all("LongitudeMin").value = "";
   top.main.SearchFrame.document.all("LongitudeMax").value = "";
   top.main.SearchFrame.document.all("LatitudeMin").value  = "";
   top.main.SearchFrame.document.all("LatitudeMax").value  = "";
   
   

   if (typeof(top.main.SearchFrame.document.all("MapShapeSearch"))!="undefined"&&top.main.SearchFrame.document.all("MapShapeSearch")!=null){
	top.main.SearchFrame.document.all("MapShapeSearch").value  = "";
   }

   ButtonInit();
}


function DoMap() {
   if ( typeof(document.SmallSub.MapAction) != "undefined") {
	document.SmallSub.MapAction.value = "";
   }
   if (top.mappingWindow != null) { top.mappingWindow.close(); }
   top.mappingWindow = window.open("", "Mapping", mapWin);
   document.SmallSub.target       = "Mapping";
   document.SmallSub.action       = "/Search/mapping/MapSql.asp";
   x=GenSql(true); // Only needs bare minimum, x= need for mac to fource gensql to finish before continuing
   if ( typeof(document.FormOne.Search1) != "undefined") 
   {
   document.FormOne.Search1.value ="Search";  // allow Searching THIS LINE CAUSES AN ERROR WHERE Search1 not defined
   }
   if ( typeof(document.FormOne.Search2) != "undefined") 
   {
   document.FormOne.Search2.value ="Search"; //Allow bottom button to change back as well if it exists.
   }

   document.SmallSub.target       = "_self"; 
   window.setTimeout("ResetTargetToSelf()",  500); // try to set target value in 1/2 second.
   window.setTimeout("closeBlank()", 4000); //Will close the mapping popup if no criteria was entered
}

//closeBlank added for VI# 103387
function closeBlank()
{
    if (top.mappingWindow.location == "about:blank") 
    { 
        top.mappingWindow.close(); 
    }
}

function DoMap2() {
   top.mappingWindow = window.open("", "Mapping", mapWin);
   document.SmallSub.target       = "Mapping";
   document.SmallSub.action       = "/Search/mapping/MapSql.asp";
   document.SmallSub.where.value  = "";
   document.SmallSub.submit();   ////This is the line that GenSql(true) causes 
   document.FormOne.Search1.value ="Search";  // allow Searching
   //document.SmallSub.target       = "_self";
   window.setTimeout("ResetTargetToSelf()",  500); // try to set target value in 1/2 second.
}

function DoExtendedMapSearch() {
   if (top.mappingWindow != null) { top.mappingWindow.close(); }
   top.mappingWindow = window.open("", "Mapping", mapWin);
   document.SmallSub.target       = "Mapping";
   document.SmallSub.action       = "/Search/mapping/MapSql.asp";
   document.SmallSub.MapAction.value = "Search";
   document.SmallSub.where.value  = "";
   document.SmallSub.submit();   ////This is the line that GenSql(true) causes 
   document.FormOne.Search1.value ="Search";  // allow Searching
   //document.SmallSub.target       = "_self";
   window.setTimeout("ResetTargetToSelf()",  500); // try to set target value in 1/2 second.
}

function ResetTargetToSelf() {
   document.SmallSub.target       = "_self";
}

function GenSqlDownload(){
   var thisAct = GetDownloadAction();
   if(thisAct.length>1) {
	  document.SmallSub.action = GetDownloadAction();
      GenSql(true); // Only needs bare minimum
   }
}


function GenSearch() {
   document.SmallSub.action = "/"+GetSearchPath() + "Scripts/Srh.asp";
   GenSql(true); // Only needs bare minimum
}


/************ Digital Map 2.0 Implementation Functions Below ********************/

function DigitalMap(sAcctName, sAgentId, sAPN, sFIPS, sAddress, sCity, sState, sZip, sType, sFname, sLname, sMLSNum, sMapType) {
	if (szDMCUsername.length == 0){
		szDMCUsername = sAgentId;
		initDMC();
	}
	
	customMapType = sMapType;

	if (sType == "SMARTMAP"||sType == "SMARTMAP1"){
		if (sAddress.length > 0 ){
			getSmartMap().queryByLocation(sAPN,sFIPS,sAddress,sCity,sState,sZip,sMLSNum);
		}else{
		    getSmartMap().openMap();
		}
	} else if (sType=="QMLite1.1"){
		if (typeof(_QuickPointLite)!="undefined"){
			getQuickPointLite().queryByLocation(sAPN,sFIPS,sAddress,sCity,sState,sZip,sMLSNum);
	    }
	}else{
	   if (typeof(_QuickMap)!="undefined"){
			getQuickMap().queryByLocation(sAPN,sFIPS,sAddress,sCity,sState,sZip,sMLSNum);
	   }else if(typeof(window.parent._QuickMap)!="undefined"){
			window.parent.getQuickMap().queryByLocation(sAPN,sFIPS,sAddress,sCity,sState,sZip,sMLSNum);
	   }
	}
}

function initDMC(){
	if (typeof(szDMCUsername)!="undefined"){

		// window name (second parameter) must be same as the variable name
		_SmartMap = new __DMPSmartMapInterface("/ShareServer/DigitalMap.asp", "_SmartMap", width, height, szDMCUsername);


		// window name (second parameter) must be same as the variable name
		_QuickMap = new __DMPQuickMapInterface(proxyURL, "_QuickMap", _SmartMap, szDMCUsername);
		
		//QuickPoint Lite is used in public detail reports
		_QuickPointLite = new __DMPQuickMapInterface(proxyURL, "_QuickPointLite", null, szDMCUsername, "QuickPointLite");
	}
}

/************ Digital Map 2.0 Implementation Init Below ********************/
var width = 800;
var height = 600;
var proxyURL = "/ShareServer/DigitalMap.asp";
var _SmartMap;
var _QuickMap;
var _QuickPointLite;
var szDMCUsername = "";



/************ Digital Map 2.0 windowing functions from thier Sample Application Map.js file ********************/

function getQuickMap()
{
	var tempWin = window;
	while (tempWin != null && tempWin.parent != tempWin && tempWin._QuickMap == null) {
		tempWin = tempWin.parent;
	}
	return tempWin._QuickMap;
}

function getQuickPointLite()
{
	var tempWin = window;
	while (tempWin != null && tempWin.parent != tempWin && tempWin._QuickPointLite == null) {
		tempWin = tempWin.parent;
	}
	return tempWin._QuickPointLite;
}

function getSmartMap()
{
	var tempWin = window;
	while (tempWin != null && tempWin.parent != tempWin && tempWin._SmartMap == null) {
		tempWin = tempWin.parent;
	}
	return tempWin._SmartMap;
}


/*****************************************************************************************************************************
	QUICKMAP INTERFACE - CODE FROM DMC FILE __DMPQuickMapInterface.js
******************************************************************************************************************************/

  /**
  * Digital Map Products QuickMap Interface
  */
function __DMPQuickMapInterface(proxyURL, windowName, smartMap, agentId, applicationName) 
{
	var XMLDocClass = "MSXML2.DOMDocument.3.0";
	if (applicationName == null || applicationName =="") {
		applicationName="QuickMap";
	}
	var width = 509;
	var height = 455;
	var windowOptions = "status=yes,toolbar=no,menubar=no,location=no,fullscreen=no";
	windowOptions += ",height="+height+",width="+width;
	
	var mapReady = false;
	var mapWindow = null;

	var queryName = null;
	var savedAPNs = null;
	var savedFIPS = null;
	var savedAddress = null;
	var savedCity = null;
	var savedState = null;
	var savedZip = null;
	var savedMLS = null;

	this.exists = function(){
		return true;
	}
	/**
	 * check for existing map window
	 * return true if window exist and can be scripted to, false otherwise.
	 */
	this.mapWindowExists = function() {
		try {
	 		if (mapWindow != null && mapWindow.closed != true) {
				var queryHandler = mapWindow.window.environment.packages.getValue("ExternalAppIntegration");	 		
				if (queryHandler != null) return true;
	 		}
 		} catch (ex) {}
 		return false;
	}
	
	/**
	 * check if map is ready for integration
	 * return true if map window exists and has received callBack for map load
	 *        false otherwise
	 */
	this.isMapReady = function() {
		// check for map window exists
		if (this.mapWindowExists() == false) {
			// map window doesn't exist
	 		// set map ready to false
	 		mapReady = false;
	 		// launch new map window 
			this.openMap();
		}
		// return map readiness stage
		return mapReady;
	}
	
	this.getMapReferenceOnAncestor = function(curWindow)
	{
		try {
			if (curWindow == null) return null;
			if (curWindow._QuickMapWindow != null
				&& curWindow._QuickMapWindow.window.closed != true){
				return curWindow._QuickMapWindow;
			}
			var tempMapWin = null;
			if (curWindow.parent != curWindow) {
				tempMapWin = this.getMapReferenceOnAncestor(curWindow.parent);
			}
			if (tempMapWin != null) return tempMapWin;
			return this.getMapReferenceOnAncestor(curWindow.opener);
		} catch (ex) {
			//alert("set map reference on ancestor(): " + ex.description);
			return null;
		}
	}

	this.setMapReferenceOnAncestor = function(curWindow, mapWin)
	{
		try {
			if (curWindow == null) return;
			curWindow._QuickMapWindow = mapWin;
			if (curWindow.parent != curWindow) {
				this.setMapReferenceOnAncestor(curWindow.parent, mapWin);
			}
			if (curWindow.opener != null) {
				this.setMapReferenceOnAncestor(curWindow.opener, mapWin);
			}
		} catch (ex) {
			//alert("set map reference on ancestor(): " + ex.description);
		}
	}
	
	/** 
	 * launch map on new window
	 */
	this.openMap = function() {
 		try {
			if (this.mapWindowExists()) {
				// map window exist, probably in 
				// loading state, do not open new window
				mapWindow.focus();
				return;
			}
			
			mapWindow = this.getMapReferenceOnAncestor(window);
			// map window does not exist, launch
			// map in a new window, name this window
			// the same as the variable name you used to 
			// store reference to this instance
			// remember to launch window with all menu and toolbar off
			// to maximize your display area
			if (mapWindow == null) {
		 		mapWindow = window.open(proxyURL 
		 				+ "?APPLICATION="+applicationName+"&AgentId="+agentId, 
		 				windowName, windowOptions);
		 		this.setMapReferenceOnAncestor(window, mapWindow);
	 		} else {
	 			mapReady = true;
	 		}
	 		mapWindow.opener = window;
			mapWindow.window.focus();
		} catch (ex){
			alert(applicationName + ".openMap(): " + ex.description);
		}
	}

	/**
	 * this method will be called by Map after Map load is completed.
	 * now you can script to map window
	 * this method will also be call when Map need to send any 
	 * data back to your application
	 * @param event xml string
	 * format:
	 *  <DMPEvent eventName="...">...</DMPEvent>
	 */
	this.callBack = function(eventXMLString) 
	{
		try {
			mapReady = true;
			// load event xml string to xml document
/*			var eventXMLDoc = new ActiveXObject(XMLDocClass);
			eventXMLDoc.loadXML(eventXMLString);

			// get event name
			var doc = eventXMLDoc.documentElement;
			var eventName = doc.getAttribute("eventName");
*/
var eventName = eventXMLString.replace(/[\w|\s|>|<|"|']*eventName='([\w]+)'[\w|\s|>|<|/|'|"]*/g,'$1');
			// if event is map load
			if (eventName == "MapLoad") {
				// set map readiness to true
				mapReady = true;
				// set reference to object manager (us to create query later)
				gObjectManager = mapWindow.window.gObjectManager;
				if (queryName == "APN") {
					this.queryByAPNs(savedAPNs, savedFIPS);
				} else if (queryName == "Location") {
					this.queryByLocation(savedAPNs, savedFIPS, savedAddress, savedCity, savedState, savedZip, savedMLS);
				}
			}
			else if (eventName == "OpenSmartMap") {
				this.openSmartMap(savedAPNs, savedFIPS, savedAddress, savedCity, savedState, savedZip, savedMLS);
			}
			// custom code
		} catch (ex) {
			alert(applicationName+".callBack(): " + ex.description);
		}
	}
		
	/**
	 * query by apns (also known as TaxId)
	 * @param apn list, common delimited
	 * @param fips (state code + county code)
	 */
	this.queryByAPNs = function(apns, fips)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			savedAPNs = apns;
			savedFIPS = fips;
			queryName = "APN";
			
			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}

			// map is ready
			if (apns == null || fips == null) return;
			mapWindow.window.focus();
			//var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			var queryHandler = mapWindow.window.environment.packages.getValue("ExternalAppIntegration");
			queryHandler.queryByAPNs(apns,fips);
		} catch (ex) {
			alert(applicationName+".queryByAPNs(APN=\""
				+apns+"\", fips=\""
				+fips+"\"): " + ex.description);
		}
	}
	
	this.queryByLocation = function(apn, fips, address, city, state, zip, sMLSNum)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			if (apn != null) apn = apn.toString();
			savedAPNs = apn;
			savedFIPS = fips;
			savedAddress = address;
			savedCity = city;
			savedState = state;
			savedZip = zip;
			savedMLS = sMLSNum;
			
			queryName = "Location";
			
			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}

			// map is ready
			// if (apn == null || fips == null) return;
			mapWindow.window.focus();
			var queryHandler = mapWindow.window.environment.packages.getValue("ExternalAppIntegration");

                  if(typeof(useCustomMapType) != 'undefined' && useCustomMapType == true)

                  {

                        queryHandler.SetMapStyle(customMapType,15);

                  }

                  queryHandler.queryByLocation(apn, fips, address, city, state, zip, sMLSNum);

		} catch (ex) {
			alert(applicationName+".queryByLocation(apn=\""+apn+"\", fips=\""+fips+"\", address=\""
				+address+"\", city=\""+city+"\", state=\""
				+state+"\", zip=\""+zip+"\"): " + ex.description);
		}
	}

	this.openSmartMap = function (apn, fips, address, city, state, zip, sMLSNum)
	{
		try {
			if (smartMap == null) {
				return;
			}
			if (apn == null && (address == null 
					|| (city == null && zip == null))) {
					smartMap.openMap();
			} else {
				smartMap.queryByLocation(apn, fips, address, city, state, zip, sMLSNum);
			}
			
		} catch (ex) {
			alert("QuickMap.openSmartMap('"+apns+"', "+fips+") error: " + ex.description);
		}
	}

}		
	

/*****************************************************************************************************************************
	SMARTMAP INTERFACE - CODE FROM DMC FILE __DMPSmartMapInterface.js
******************************************************************************************************************************/
		
 /**
  * Digital Map Products - SmartMap Interface
  */
function __DMPSmartMapInterface(proxyURL, 
	windowName, width, height, agentId) 
{
	var windowOptions = "toolbar=no,menubar=no,location=no,resizable=yes";
	if (width == null || isNaN(width) || width < 100) width = 800;
	if (height == null || isNaN(height) || height < 100) height = 600;
	windowOptions += ",height="+height+",width="+width;
	
	var applicationName = "SmartMap";
	var XMLDocClass = "MSXML2.DOMDocument.3.0";
	var gObjectManager = null;
	var mapReady = false;
	var mapWindow = null;
	
	var savedResource = null;
	var savedFilter = null;
	var savedAPNs = null;
	var savedFips = null;
	var savedAddress = null;
	var savedCity = null;
	var savedState = null;
	var savedZip = null;
	var savedMLS = null;
	var savedStreet1 = null;
	var savedStreet2 = null;
	var lastQueryName = null;
	
	/**
	 * check for existing map window
	 * return true if window exist and can be scripted to, false otherwise.
	 */
	this.mapWindowExists = function() {
		try {
	 		if (mapWindow != null && mapWindow.closed != true) {
	 			return true;
	 		}
 		} catch (ex) {}
 		return false;
	}
	
	/**
	 * check if map is ready for integration
	 * return true if map window exists and has received callBack for map load
	 *        false otherwise
	 */
	this.isMapReady = function() {
		// check for map window exists
		if (this.mapWindowExists() == false) {
			// map window doesn't exist
	 		// set map ready to false
	 		mapReady = false;
	 		// launch new map window 
			this.openMap();
		}
		// return map readiness stage
		return mapReady;
	}

	this.getMapReferenceOnAncestor = function(curWindow)
	{
		try {
			if (curWindow == null) return null;
			if (curWindow._SmartMapWindow != null
				&& curWindow._SmartMapWindow.window.closed != true){
				return curWindow._SmartMapWindow;
			}
			var tempMapWin = null;
			if (curWindow.parent != curWindow) {
				tempMapWin = this.getMapReferenceOnAncestor(curWindow.parent);
			}
			if (tempMapWin != null) return tempMapWin;
			return this.getMapReferenceOnAncestor(curWindow.opener);
		} catch (ex) {
			//alert("set map reference on ancestor(): " + ex.description);
			return null;
		}
	}

	this.setMapReferenceOnAncestor = function(curWindow, mapWin)
	{
		try {
			if (curWindow == null) return;
			curWindow._SmartMapWindow = mapWin;
			if (curWindow.parent != curWindow) {
				this.setMapReferenceOnAncestor(curWindow.parent, mapWin);
			}
			if (curWindow.opener != null) {
				this.setMapReferenceOnAncestor(curWindow.opener, mapWin);
			}
		} catch (ex) {
			//alert("set map reference on ancestor(): " + ex.description);
		}
	}
	/** 
	 * launch map on new window
	 */
	this.openMap = function() {
		if (this.mapWindowExists()) {
			// map window exist, probably in 
			// loading state, do not open new window
			mapWindow.focus();
			return;
		}
		
		mapWindow = this.getMapReferenceOnAncestor(window);
		// map window does not exist, launch
		// map in a new window, name this window
		// the same as the variable name you used to 
		// store reference to this instance
		// remember to launch window with all menu and toolbar off
		// to maximize your display area
		if (mapWindow == null) {
	 		mapWindow = window.open(proxyURL 
	 				+ "?APPLICATION="+applicationName+"&AgentId="+agentId, 
	 				windowName, windowOptions);
	 		this.setMapReferenceOnAncestor(window, mapWindow);
 		} else {
 			mapReady = true;
 			gObjectManager = mapWindow.window.gObjectManager;
 		}
 		mapWindow.opener = window;
 		try {
			mapWindow.window.focus();
		} catch (ex){
		}
	}

	/**
	 * this method will be called by Map after Map load is completed.
	 * now you can script to map window
	 * this method will also be call when Map need to send any 
	 * data back to your application
	 * @param event xml string
	 * format:
	 *  <DMPEvent eventName="...">...</DMPEvent>
	 */
	this.callBack = function(eventXMLString) {
		try {
			// load event xml string to xml document
/*			var eventXMLDoc = new ActiveXObject(XMLDocClass);
			eventXMLDoc.loadXML(eventXMLString);

			// get event name
			var doc = eventXMLDoc.documentElement;
			var eventName = doc.getAttribute("eventName");
*/
var eventName = eventXMLString.replace(/[\w|\s|>|<|"|']*eventName='([\w]+)'[\w|\s|>|<|/|'|"]*/g,'$1');
			// if event is map load
			if (eventName == "MapLoad") {
				// set map readiness to true
				mapReady = true;
				// set reference to object manager (us to create query later)
				gObjectManager = mapWindow.window.gObjectManager;
				
				//rerun previous query command, now that map is ready.
				if (lastQueryName == "query") {
					this.query(savedResource, savedFilter);
				} 
				else if (lastQueryName == "apn") {
					this.queryByAPNs(savedAPNs, savedFips);
				} 
				else if (lastQueryName == "address") {
					this.queryByAddress(savedAddress, savedCity, savedState, savedZip, savedMLS);
				} 
				else if (lastQueryName == "intersection") {
					this.queryByIntersection(savedStreet1, savedStreet2, savedFips);
				}
				else if (lastQueryName == "Location") {
					this.queryByLocation(savedAPNs, savedFips, savedAddress, savedCity, savedState, savedZip, savedMLS);
				}
			}
			// custom code
		} catch (ex) {
			alert(applicationName+".callBack(): " + ex.description);
		}
	}
	
	/**
	 * do generic query 
	 * @param resource name
	 * @param condition - query filter in sql 
	 */
	this.query = function(resource, condition) {
		try {
			// save query parameters in case map 
			// is not ready for integration
			lastQueryName = "query";
			savedResource = resource;
			savedFilter = condition;
			
			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}
			// map is ready
			if (resource == null || condition == null) return;
			// call Map object manager to create a query object
			var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			// set the query resource name
			queryHandler.setResourceName(resource);
			
			// bring map window into focus
			mapWindow.window.focus();

			// execute query with the query filter
			queryHandler.query(condition);
		} catch (ex) {
			alert(applicationName+".query(resource=\""
				+resource+"\", condition=\""
				+condition+"\"): " + ex.description);
		}
	}
	/**
	 * query by apns (also known as TaxId)
	 * @param apn list, common delimited
	 * @param fips (state code + county code)
	 */
	this.queryByAPNs = function(apns, fips)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			lastQueryName = "apn";
			savedAPNs = apns;
			savedFips = fips;
			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}
			// map is ready
			if (apns == null || fips == null) return;
			// call Map object manager to create a query object
			var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			
			// bring map window into focus
			mapWindow.window.focus();

			// execute query by apns (AKA taxid)
			queryHandler.queryByAPNs(apns, fips);
		} catch (ex) {
			alert(applicationName+".queryByAPNs(APN=\""
				+apns+"\", fips=\""
				+fips+"\"): " + ex.description);
		}
	}
		
	/**
	 * query by address
	 * @param address
	 * @param city
	 * @param state
	 * @param zip
	 */
	this.queryByAddress = function(address, city, state, zip)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			lastQueryName = "address";
			savedAddress = address;
			savedCity = city;
			savedState = state;
			savedZip = zip;

			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}
			// map is ready
			if (address == null || (city == null && zip == null)) return;
			// call Map object manager to create a query object
			var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			
			// bring map window into focus
			mapWindow.window.focus();

			// execute query by address 
			queryHandler.queryByAddress(address, city, state, zip);
		} catch (ex) {
			alert(applicationName+".queryByAddress(address=\""
				+address+"\", city=\""+city+"\", state=\""
				+state+"\", zip=\""+zip+"\"): " + ex.description);
		}
	}
			
	/**
	 * query by address
	 * @param address
	 * @param city
	 * @param state
	 * @param zip
	 */
	this.queryByLocation = function(apn, fips, address, city, state, zip, sMLSNum)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			lastQueryName = "Location";
			savedAPNs = apn;
			savedFips = fips;
			savedAddress = address;
			savedCity = city;
			savedState = state;
			savedZip = zip;
			savedMLS = sMLSNum;

			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}
			// map is ready
			if (address == null || (city == null && zip == null)) return;
			// call Map object manager to create a query object
			var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			
			// bring map window into focus
			mapWindow.window.focus();

			// execute query by address 
			queryHandler.queryByLocation(apn, fips, address, city, state, zip, sMLSNum);
		} catch (ex) {
			alert(applicationName+".queryByLocation(apn=\""+apn+"\", fips=\""+fips+"\", address=\""
				+address+"\", city=\""+city+"\", state=\""
				+state+"\", zip=\""+zip+"\"): " + ex.description);
		}
	}
			
	/**
	 * query by street intersections
	 * @param first street name (required)
	 * @param second street name (optional)
	 * @param fips (required) (state code + county code) 
	 */
	this.queryByIntersection = function(street1, street2, fips)
	{
		try {
			// save query parameters in case map 
			// is not ready for integration
			lastQueryName = "intersection";
			savedStreet1 = street1;
			savedStreet2 = street2;
			savedFips = fips;

			if (this.isMapReady() != true) {
				// do nothing;
				// when map is ready, call this query again. 
				return;
			}
			// map is ready
			if (street1 == null && street2 == null && fips == null) return;
			// call Map object manager to create a query object
			var queryHandler = gObjectManager.constructObject("SmartMapCatalog:QueryHandler");
			
			// bring map window into focus
			mapWindow.window.focus();

			// execute query by intersection
			queryHandler.queryByIntersection(street1, street2, fips);
		} catch (ex) {
			alert(applicationName+".queryByIntersection(street1=\""
				+street1+"\", street2=\""+street2+"\", fips=\""
				+fips+"\"): " + ex.description);
		}
	}
}

