
function startMap(){
    
    try{
        myMap = new MQA.TileMap(document.getElementById('AdvmapHolder'),2,new MQA.LatLng(37.250556,-96.358333),"hyb")
        myMap.addControl(new MQA.LargeZoomControl());
                
        myMap.enableDragging(false);
        
        MQA.EventManager.addListener(myMap,'click',mapquestMapClick);
        setTimeout("cursorControl()", 750);
    }catch(e){
        
    }
}

function cursorControl(){
	   var doOverlay=true;
	   
	   if(doOverlay){
            AddGeoRss();            
        }
	
      //alert("doing cursor control");
       try{
        document.getElementById('AdvmapHolder').style.cursor='default';
        //console.log('AdvmapHolder cursor set');
       }catch(e){
        //console.log(e.message);
       }
     
       try{
            //document.mqOverlayDiv.style.cursor = "default";
            document.getElementById('mqtiledmap').style.cursor = "default";
           // console.log('mqtiledmap cursor set');
        }catch(e){
           // console.log(e.message);
        }
     
       try{
             document.getElementById('map.div1').style.cursor = "default";
             //console.log('map.div1 cursor set');
        }catch(e){
            //console.log(e.message);
           
        }
       try{
            //document.mqOverlayDiv.style.cursor = "default";
            document.getElementById('mqmaptilediv').style.cursor = "default";
            //console.log('mqmaptilediv cursor set');
        }catch(e){
            //console.log(e.message);
        }
        
       try{
            document.getElementById('mqPoiLineDiv').style.cursor = "default";
            //console.log('mqPoiLineDiv cursor set');
        }catch(e){
           // console.log(e.message);
        }
        
        try{
             document.getElementById('map.div.ldiv').style.cursor = "default";
            // console.log('map.div.ldiv cursor set');
            
        }catch(e){
            //console.log(e.message);
        }
        
         try{
            document.getElementById('mqCanvasDiv').style.cursor = "default";
        }catch(e){
            //console.log(e.message);
        }
        
         try{
            document.getElementById('mqOverlayDiv').style.cursor = "pointer";
            //console.log('mqOverlayDiv cursor set');
        }catch(e){
            //console.log(e.message);
        }
        
}

function mapquestMapClick(click){
	    
	
        var state = "";
        
        
        var clickedStartingPoint = new MQGeoAddress();
        var lcStartingPoint = new MQLocationCollection("clickedStartingPoint");
        try{
            //alert(click.ll);
            mapExec.reverseGeocode(click.ll,lcStartingPoint,"navt","us_postal");
            clickedStartingPoint = lcStartingPoint.get(0);
        }catch(e){
            //alert(e.message);
        }
        
        //alert(mapExec.reverseGeocode(click.ll,lcStartingPoint,"navt","us_postal"));
        try{
             var postalcode = clickedStartingPoint.getPostalCode();
        }catch(e){
             var postalcode = "";
        }
        
        try{
              var city = clickedStartingPoint.getCity();   
        }catch(e){
              var city = "";   
        }
       
         try{
              var state = clickedStartingPoint.getState();
        }catch(e){
              var state = "";
        }
        
            
        var serviceType = document.getElementById('serviceType').value;
        var radius = document.getElementById('radius').value;
        var maxResults = document.getElementById('maxResults').value;        
        
        
        //the app gets very slow if empty strings are passed for these vars
        if(radius.toString().length == 0){
            radius = 100;
        }
        
        if(maxResults.toString().length == 0){
            maxResults = 200;
        }
        
        //var items = parseUri($('uri').value);
        //pathInfo set in dspSearchLocations
        //var currentLocation = window.location;
        var currentLocation = pathInfo;
        //alert(currentLocation);
        var searchConnector = "?";
        
        /*
        if(window.location.search.toString().length != 0){
            searchConnector = "&"
        }else{
            searchConnector = "?"
        }*/
        
        if(state.toString().length > 0){
        	//now when clicking on the map, just return all of the facs in the state
        	
            window.location = currentLocation + searchConnector + "city=" + "&state=" + state + "&postalcode=" + "&doSearch=1" + "&serviceType=" + serviceType ;
        }    
}

function zoomClick(click){
    var currentZoomLevel = myMap.getZoomLevel();
    
    myMap.setCenter(click.ll);
    
    myMap.setZoomLevel(currentZoomLevel+1);
}

function getResults(city,state,postalcode,country,maxMatches,radius,serviceType) {
     
    
    //hold the locations for display on the lower half of the page
    var locations = new Array();
    var myShapeCollection = new MQA.ShapeCollection();
    myShapeCollection.Name = "myPois";
    
    var hasCityInfo = (city.length > 0 && city.toString().toLowerCase() != 'city');
    var hasStateInfo = (state.length > 0);
    
    var hasPostalCodeInfo = ((postalcode.length > 0) && postalcode.toString().toLowerCase()!='zip');
    
    //alert(hasPostalCodeInfo);
   
    if( ( hasCityInfo && hasStateInfo  ) || hasPostalCodeInfo ){
        //geocode the address  
	    var address = new MQAddress();
	    var gaCollection = new MQLocationCollection();  
	    
	    if(postalcode == '94909'){
	    	city='Kentfield';
	    	state='CA';
	    }
	    
	    /*
	    alert('city: ' + city);
	    alert('state: ' + state);
	    alert('postalcode: '+ postalcode);
	    */
	    
	    address.setCity(city);
	    address.setState(state);
	    //alert("here");
	    if(postalcode.toString().toLowerCase()!='zip'){	      
	       address.setPostalCode(postalcode);   
	    }else{
	    	document.getElementById('postalcode').value='';
	    	address.setPostalCode('');
	    }  
	    
	    address.setCountry(country);
	    
	    geoExec.geocode(address, gaCollection);           
             
        //get the geocode result
        var geoAddr = gaCollection.get(0);        
        
       
            
        if(geoAddr.getPostalCode().length ==0 && (postalcode.length > 0 && postalcode.toString().toLowerCase()!='zip')){
        	        	
        	document.getElementById('infoDiv').innerHTML = 'The zip code you entered, '+ postalcode +', was not found';
        	document.getElementById('postalcode').value='Zip';
        	startMap();
        	
        	if(postalcode.toString().toLowerCase()!='zip'){
	        	var postalCodeFix = "";
	        	postalCodeFix = address.getPostalCode().substring(0,4);
	        	postalCodeFix = postalCodeFix + '0';  
        	}  	 
        	        	
        	address.setPostalCode(postalCodeFix);
        	
        	gaCollection = new MQLocationCollection();  
        	
        	geoExec.geocode(address, gaCollection); 
        	
        	geoAddr = gaCollection.get(0);
        	
        	
        }else{
    
	        //create a variable for the origin of the search
	        var origin = geoAddr.getMQLatLng();
	        
	        //call search function, get back a FeatureCollection of results        
	        var searchRes = new doSearch(origin,maxMatches,radius);
        }
        
        //alert("searchRes:" + searchRes.getSize());
        
        if(searchRes.getSize()>0){
            //get the records for this search
            
            var moreInfo = getMoreInfo(searchRes);
            
            processDoSearch(origin,searchRes,moreInfo,serviceType,locations,myShapeCollection);   
            
            document.getElementById("postalcode").value = geoAddr.getPostalCode();
            document.getElementById("city").value = geoAddr.getCity();
            document.getElementById("showSearchNumbers").value = 1;
        }else{
            document.getElementById("postalcode").value = "Zip";
            document.getElementById("city").value = "City";
            document.getElementById("showSearchNumbers").value = 0;
            processStateCriteria(state,serviceType,locations,myShapeCollection);
        }
        
           document.getElementById("state").value = geoAddr.getState();     
       
    }else{
        
        if(hasStateInfo){
            document.getElementById("postalcode").value = "Zip";
            document.getElementById("city").value = "City";
            processStateCriteria(state,serviceType,locations,myShapeCollection);
        }else{
            
            processAll(serviceType,locations,myShapeCollection);           
            
        }
        
        
    }       
    
    myMap = new MQA.TileMap(document.getElementById('AdvmapHolder'),5,origin,"map");        
    myMap.addControl(new MQA.LargeZoomControl());   
    //add the shapecollection to the map
    myMap.addShapeCollection(myShapeCollection);
   
    
    myMap.bestFit(); 
    
    if((postalcode.length==0 && city.length ==0) && myMap.getZoomLevel()> 4){
    	myMap.setZoomLevel(4);
    }
           
        
    if(parseInt(myMap.getZoomLevel()) > 10){
        myMap.setZoomLevel(10);
    }
    
    return locations;   
}

function doSearch(LLobj,maxMatches,radius) {
    //set up the SearchCriteria - centerLL, radius, num of results
    var sCriteria = new MQRadiusSearchCriteria();
    
    sCriteria.setMaxMatches(maxMatches);
    sCriteria.setRadius(radius);
    
    sCriteria.setCenter(LLobj);
    
    //empty FeatureCollection to hold the search results
    var searchResults = new MQFeatureCollection();
    
    //dbLayerQuery.setExtraCriteria("disabledDate is null and pushedLiveDate is not null");
    dbLayerQuery.setExtraCriteria(doSearchExtraCriteria);
    
    //Search!
    searchExec.search(sCriteria,searchResults,'',dbLayerQueryCollection);
    //return the featurecollection
    return searchResults;
}

function processDoSearch(origin,searchRes,moreInfo,serviceType,locations,myShapeCollection){
    
    var filterServiceType = false;

    if(serviceType.length > 0){
        filterServiceType = true;
    }
    
    
    var columnPosition = 1;
    locationPos = 0;
    
     // use the facility ajax proxy
	var thisFacilityProxy = new facilityProxy();
   
    
   for( var i=0; i<searchRes.getSize(); i++) {
        //alert("getting more info");
        
        var mi = new MQRecordSet();
        mi = moreInfo;                 
        
        if(!mi.isEOF()){
            
            resultPoint = searchRes.get(i);

             // check if the facility is disabled
    		var facilityDisabled = thisFacilityProxy.isFacilityDisabled(mi.getField("RecordId"));
            
            if (facilityDisabled != 1) {
	            if(filterServiceType){
	                                            
	                if( mi.getField("LOB").toLowerCase() == serviceType.toLowerCase() ){
	                    
	                    var poiLL = new MQA.LatLng(mi.getField("Lat"),mi.getField("Lng"));
	                    var distanceFromOrigin = poiLL.arcDistance(origin);
	                                        
	                    thisLocation = createLocation(mi,resultPoint.getDistance(),columnPosition);                 
	                    
	                    locations[locationPos]=thisLocation;
	                   
	                    poi = new MQA.Poi(poiLL);
	                    poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(mi));
	                    poi.setValue('infoContentHTML', infoContentHTMLBuilder(resultPoint.getDistance(),mi));
	                    poi.setValue('key',resultPoint.getKey());
	                    myShapeCollection.add(poi);              
	                    
	                                     
	                }
	            
	            }else{
	                
	                var poiLL = new MQA.LatLng(mi.getField("Lat"),mi.getField("Lng"));
	                var distanceFromOrigin = poiLL.arcDistance(origin);
	                    
	                thisLocation = createLocation(mi,distanceFromOrigin,columnPosition);                
	                
	                locations[locationPos]=thisLocation;
	                
	                poi = new MQA.Poi(poiLL);
	                poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(mi));
	                poi.setValue('infoContentHTML', infoContentHTMLBuilder(resultPoint.getDistance(),mi));
	                poi.setValue('key',resultPoint.getKey());
	                myShapeCollection.add(poi);
	                
	            }
            }
           
           mi.moveNext();
        }
        
        locationPos++; 
        columnPosition++;
        
        //3 columns, so if 4, reset
        if(columnPosition==4){
            columnPosition=1;
        }
        
    }
    return locations;
}

function processStateCriteria(state,serviceType,locations,myShapeCollection){
    try{
            var moreInfo = new MQRecordSet();
            var ids = new MQStringCollection();         
            var fields = new MQStringCollection();          
            dbLayerQuery.setExtraCriteria("state = '" + state + "'" + processStateCriteriaExtraCriteria);     
            searchExec.getRecordInfo(fields, dbLayerQuery, moreInfo, ids);         
                
            var filterServiceType = false;
        
            if(serviceType.length > 0){
                filterServiceType = true;
            }

            var locationIndex = 0;
            var columnPosition = 1;
            var distance = "";
            
            // use the facility ajax proxy
    		var thisFacilityProxy = new facilityProxy();
            
            while(!moreInfo.isEOF()){

            	// check if the facility is disabled
        		var facilityDisabled = thisFacilityProxy.isFacilityDisabled(moreInfo.getField("RecordId"));
                
                if (facilityDisabled != 1) {
                	
	                //alert("columnPosition: " + columnPosition);      
	                if(filterServiceType){
	                                    
	                    if( moreInfo.getField("LOB").toLowerCase() == serviceType.toLowerCase() ){
	                       
	                        thisLocation=createLocation(moreInfo,distance,columnPosition);
	                                                
	                        locations[locationIndex]=thisLocation;
	                        
	                        var poiLL = new MQA.LatLng(moreInfo.getField("Lat"),moreInfo.getField("Lng"));
	                        
	                        poi = new MQA.Poi(poiLL);
	                        poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(moreInfo));
	                        poi.setValue('infoContentHTML', infoContentHTMLBuilder("",moreInfo));
	                        poi.setValue('key',moreInfo.getField('RecordId'));                   
	                        myShapeCollection.add(poi);             
	                        locationIndex++;
	                    }
	                
	                }else{
	                        
	                    thisLocation=createLocation(moreInfo,distance,columnPosition);
	                    
	                    locations[locationIndex]=thisLocation;
	                    
	                    var poiLL = new MQA.LatLng(moreInfo.getField("Lat"),moreInfo.getField("Lng"));
	                    
	                    poi = new MQA.Poi(poiLL);
	                    poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(moreInfo));
	                    poi.setValue('infoContentHTML', infoContentHTMLBuilder("",moreInfo));
	                    poi.setValue('key',moreInfo.getField('RecordId'));
	                    myShapeCollection.add(poi);
	                    locationIndex++;
	                }
	                
	                columnPosition++;
	            
	                //3 columns, so if 4, reset
	                if(columnPosition==4){
	                    columnPosition=1;
	                }
                
                }
                moreInfo.moveNext(); 
             }
            
        }catch(e){
            //alert("searchExec.search error: " + e.message);
        }
}

function processAll(serviceType,locations,myShapeCollection){
    //alert("processAll");
    //alert("serviceType:" + serviceType);
    
    try{
           var moreInfo = new MQRecordSet();
            var ids = new MQStringCollection();         
            var fields = new MQStringCollection();       
            var dateFormat = '0000-00-00';   
                          
            var filterServiceType = false;
        
            if(serviceType.length > 0){
                //alert("getting service types");
                filterServiceType = true;
                dbLayerQuery.setExtraCriteria("LOB = '" + serviceType + "'");         
            }else{
                //alert("getting all");
                dbLayerQuery.setExtraCriteria("LOB='OP' OR LOB='OR'");         
            }
            
            searchExec.getRecordInfo(fields, dbLayerQuery, moreInfo, ids);    
            
            var locationIndex = 0;
            var columnPosition = 1;
            var distance = "";
           
        	// use the facility ajax proxy
    		var thisFacilityProxy = new facilityProxy();
    		
            
            while(!moreInfo.isEOF()){
            	

        		// check if the facility is disabled
        		var facilityDisabled = thisFacilityProxy.isFacilityDisabled(moreInfo.getField("RecordId"));

                if (facilityDisabled != 1) {
            	
                 //alert("columnPosition: " + columnPosition);      
                 if(filterServiceType){
                                    
                    if( moreInfo.getField("LOB").toLowerCase() == serviceType.toLowerCase() ){
                       
                        thisLocation=createLocation(moreInfo,distance,columnPosition);
                                                
                        locations[locationIndex]=thisLocation;
                        
                        var poiLL = new MQA.LatLng(moreInfo.getField("Lat"),moreInfo.getField("Lng"));
                        
                        poi = new MQA.Poi(poiLL);
                        poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(moreInfo));
                        poi.setValue('infoContentHTML', infoContentHTMLBuilder("",moreInfo));
                        poi.setValue('key',moreInfo.getField('RecordId'));                   
                        myShapeCollection.add(poi);             
                        
                    }
                
                }else{
                        
                    thisLocation=createLocation(moreInfo,distance,columnPosition);
                    
                    locations[locationIndex]=thisLocation;
                    
                    var poiLL = new MQA.LatLng(moreInfo.getField("Lat"),moreInfo.getField("Lng"));
                    
                    poi = new MQA.Poi(poiLL);
                    poi.setValue('infoTitleHTML',infoTitleHTMLBuilder(moreInfo));
                    poi.setValue('infoContentHTML', infoContentHTMLBuilder("",moreInfo));
                    poi.setValue('key',moreInfo.getField('RecordId'));
                    myShapeCollection.add(poi);
                }
                
                locationIndex++;
                columnPosition++;
            
                //3 columns, so if 4, reset
                if(columnPosition==4){
                    columnPosition=1;
                }
                
                }
                moreInfo.moveNext(); 
             }
         
        }catch(e){
            //alert("searchExec.search error: " + e.message);
        }
}

function getMoreInfo(searchRes){
	
	
    var ids = new MQStringCollection();    
    var moreInfo = new MQRecordSet();
    var fields = new MQStringCollection();
    for (i = 0; i < searchRes.getSize(); i++){
    	ids.add(searchRes.getAt(i).getKey());
    }
         
    searchExec.getRecordInfo(fields, dbLayerQuery, moreInfo, ids);

    return moreInfo;
    
}

function getUrlSafeFacilityName(theName){  
    
    var facName = theName.replace(/ /g,"-").replace(/:/g,"");
        
    facName = facName.replace(/&/g,"and");
    
    facName = facName.replace(/\./, '');
    
    return facName;
    
}

function seoFacilityUrl(recordId,city,state,facilityName){
    var seoFacilityUrl = new String();
    
    var dashedCityName = city.replace(/ /g,"-");
    
    var dashedFacilityName = getUrlSafeFacilityName(facilityName);
            
    seoFacilityUrl += '<a target="_top" href=http://' + window.location.hostname + '/facility/' + recordId+ '/' + dashedCityName + '/' + state + '/'+ dashedFacilityName + '>' + facilityName + '</a>';
    
    return seoFacilityUrl;
}

function infoTitleHTMLBuilder(mi){
    var infoStr = new String();
     
    //infoStr += '<a target="_top" href=http://' + window.location.hostname + '/facility/' + mi.getField('RecordId')+ '/' + dashedCityName + '/' + mi.getField('state')+ '/'+ escape(dashedFacilityName) + '>' + mi.getField('N') + '</a><br/>'
    
    //alert(seoFacilityUrl(mi.getField('RecordId'),mi.getField('city'),mi.getField('state'),mi.getField('N')));
     infoStr += seoFacilityUrl(mi.getField('RecordId'),mi.getField('city'),mi.getField('state'),mi.getField('N'));
     infoStr +="<br/>";
    
    return infoStr;
}

function infoContentHTMLBuilder(dist,mi){
    var infoStr = new String();
        
    infoStr +=seoFacilityUrl(mi.getField('RecordId'),mi.getField('city'),mi.getField('state'),mi.getField('N'));
    infoStr +='<br/>';
    
    infoStr += mi.getField('address') + '<br/>';
    infoStr += mi.getField("city") + ", "  ;
    infoStr += mi.getField("state") + " " + mi.getField("postal") + '<br/>' ;       
    
    /*  
    var service = new String();
    
    if(mi.getField("LOB")=='OP'){
        service = 'Orthotics and Prosthetics<br/>';
    }else{
        service = 'Outpatient Rehabilition<br/>';
    }
    infoStr += service;
    */
    
    //infoStr += '<a href=http://' + window.location.hostname + '/content.cfm/facility?facilitypublicid=' + mi.getField("facilityPublicId") + '> View ' + mi.getField('N') + ' facility page </a><br/>'; 
    
    var drivingDirections = new String();
    
    drivingDirections += '<a href=http://' + window.location.hostname + '/content.cfm/driving-directions';
    
    //drivingDirections += '?startLat=' + encodeURIComponent(mi.getField('Lat'));
    //drivingDirections += '&startLng=' + encodeURIComponent(mi.getField('Lng'));
    drivingDirections += '?address1=' +  encodeURIComponent(mi.getField('address'));
    drivingDirections += '&city=' +  encodeURIComponent(mi.getField('city'));
    drivingDirections += '&state=' +  encodeURIComponent(mi.getField('state'));
    drivingDirections += '&postal=' +  encodeURIComponent(mi.getField('postal'));
    
    drivingDirections += '> Get Driving Directions '  + '</a><br/>'; 
    
    infoStr += drivingDirections;
    
    return infoStr
}

function AddGeoRss(){
                  
        var xmlDocToLoad = "http://" + window.location.hostname + "/common/modules/mapquest/usaRss.xml";
    
        try{
           myXMLDoc=document.implementation.createDocument("","",null);
           myXMLDoc.load(xmlDocToLoad);
           myPolygonCollection = new MQA.ShapeCollection();
           myXMLDoc.onload = ffLoadGeoRSS;
           
        }catch(e){
            
            myXMLDoc=new ActiveXObject("MSXML2.DOMDocument");
            myXMLDoc.async="false";
            myXMLDoc.load(xmlDocToLoad);
            if (myXMLDoc.readyState==4){                
                ieLoadGeoRSS();
            }
           
        }
        
    myPolygonCollection.setName("myPolygonCollection");    
    
    myMap.addShapeCollection(myPolygonCollection);

    
}

function removeGeoRSS(){
    var mapShapeCollections = myMap.getShapeCollectionNames();
    for (i=0;i<mapShapeCollections.length;i++){
        //alert(mapShapeCollections[i]);
        if(mapShapeCollections[i].toString()=='myPolygonCollection'){
            myMap.removeShapeCollection(mapShapeCollections[i]);
        }
     }
}

function ieLoadGeoRSS() {
    //alert("loading GeoRSS");
    myPolygonCollection = new MQA.ShapeCollection();
    try{
     for (i = 0; i < myXMLDoc.getElementsByTagName("item").length; i++) {
        
        myPolygonOL = new MQA.PolygonOverlay();
        myPolygonOL.setBorderWidth(2);
        myPolygonOL.setColor("#FFEC8B");
        myPolygonOL.setFillColor("#FFEC8B");
        myPolygonOL.setFillColorAlpha(0.25);
        myPolygonOL.setKey("Polygon");
        
        var title = myXMLDoc.getElementsByTagName("title")[i].text;
        //alert(title);
        var c = myXMLDoc.getElementsByTagName("georss:polygon")[i].text;
        //alert(c);
        
        var tmp = c.split(/ /);
        var myShapePts = new MQLatLngCollection();
        for (j = 0; j < tmp.length; j++) {
            myShapePts.add(new MQLatLng(tmp[j], tmp[j+1]));
            j++;
        }
        myPolygonOL.setShapePoints(myShapePts);
        myPolygonCollection.add(myPolygonOL);
       
    }
    }catch(e){
        //alert(e.message);
    }
}

function ffLoadGeoRSS() {
     
     for (i = 0; i < myXMLDoc.getElementsByTagName("item").length; i++) {
        try{
        myPolygonOL = new MQA.PolygonOverlay();
        myPolygonOL.setBorderWidth(2);
        myPolygonOL.setColor("#FFEC8B");
        myPolygonOL.setFillColor("#FFEC8B");
        myPolygonOL.setFillColorAlpha(0.25);        
        
        var title = myXMLDoc.getElementsByTagName("title")[i].textContent;
        
        myPolygonOL.setKey(title);
        
        var c = myXMLDoc.getElementsByTagNameNS("http://www.georss.org/georss","polygon")[i].textContent;
        
        var tmp = c.split(/ /);
        var myShapePts = new MQLatLngCollection();
        for (j = 0; j < tmp.length; j++) {
            myShapePts.add(new MQLatLng(tmp[j], tmp[j+1]));
            j++;
        }
        myPolygonOL.setShapePoints(myShapePts);
        //alert("adding:" + title);
        myPolygonCollection.add(myPolygonOL);
        }catch(e){
            //alert(e.message)
        }
        
    }
    document.getElementById('mqOverlayDiv').style.cursor = "pointer";
}

function createLocation(moreInfo,distance,columnPosition){
    var thisLocation = new Object;
    
    thisLocation.recordId = moreInfo.getField('RecordId');                  
    thisLocation.name = moreInfo.getField('N');
    thisLocation.address = moreInfo.getField('address');
    thisLocation.city = moreInfo.getField('city');
    thisLocation.state = moreInfo.getField('state');
    thisLocation.postal =  moreInfo.getField('postal');
    thisLocation.LOB = moreInfo.getField("LOB");
    thisLocation.facilityPublicId = moreInfo.getField("facilityPublicId");
    thisLocation.distance = distance;
    thisLocation.columnPosition = columnPosition;
    
    return thisLocation;
}

function showHideSearchNumbers(){
    var zip = document.getElementById('postalcode').value;
    var city = document.getElementById('city').value;
    var showSearchNumbers = document.getElementById('showSearchNumbers').value;
    
    //alert(zip.toString().toLowerCase());
    //alert(city.toString().toLowerCase());
    
    if(zip.toString().toLowerCase() != 'zip' && city.toString().toLowerCase()!='city' && showSearchNumbers==1 ){
      document.getElementById('searchNumbers').style.display = "inline";
    }
    
}



