//
// File : bertha-rtwgmap-ui.js
//
// Description : Javascript functions for rendering components on a RTWGMap
//               implementation. Overrides several functions found in the 
//               RTWGMap's javascript lib
//
// Contents    : 
//               renderMarkerForSideListing(marker)
//               returnFilteredMarkers                        
//               showInfoTabs
//  

 
    //
    // Custom Rendering for Bertha Listings on the sidebar
    //
    var renderMarkerForSideListing = function(marker){
        var html = "";
        if(marker != null)
        {
	        //
            // render the marker as a link that calls "myclick(marker.id)" when it's selected
            // (shows the gmap bubble - information bubble usually)
            // with the marker's icon changing colour if/when the mouse is over the link
            //
            // In this implementation the sideListing text will be : 
            //                 <marker.name> - with a href/link to call myclick() to show the info bubble
            //       <marker.additionalInfo.summary>  - number of listings per category
            //                	
            var summary = marker.severityLevel + ' [' + marker.totalCount + ']';
            var tooltip = marker.name.entityify() + " - " + summary;
                        
            // open the marker's info bubble if the sideListing link is clicked
            html += '<a class="smallText" href="javascript:myclick(' + marker.id + ')"';
            
            // add js to make the marker change it's icon if/when the mouse is over the link
            var highliteImage = '/app68/listings/icons/maps/' + marker.color + '.png';
            normalImage = '/app68/listings/icons/maps/' + marker.color + '.png';
                
            html += '  onmouseover="gmarkers['+marker.id+'].setImage(\''+ highliteImage + '\'); showTooltip(gmarkers['+marker.id+'], \''+ tooltip + '\');  "';
            html += '  onmouseout="gmarkers['+marker.id+'].setImage(\'' + normalImage + '\'); hideTooltip();"';
			
	              
			//side listing text
            html += '  >' +marker.name + '</a><br/><span class="smallText">'  + summary  + '</span><br/><br/>';
        }
        
        return (html);
    }   
        
  
 
   
     // 
    // Overrides showInfoTabs in rtwgmap-ui.js
    //
    // show the info tabs for a markerObj when the user clicks it's gmarker
    // see createGMarker(markerObj)
    //
    var showInfoTabs = function(gmarker, markerObj) {
              
       // Build the gmarker's window tabs - one for each category
       var tabs = [];
                      
	   // Build the gmarker's window tabs 
	   var i=0;
       for(tabLabel in markerObj.infoTabs)	{
        	var label = tabLabel;
        	var html = markerObj.infoTabs[tabLabel];
        	tabs[i++] = new GInfoWindowTab(label, html);        	
    	}       

       var opts = {maxWidth:340, selectedTab:i-1}; 
       gmarker.openInfoWindowTabs(tabs, opts);
    }

   //
   // Initialize the side listing with some simple instructions/overview
   //
   var initSideListing = function() {
	    document.getElementById("sideListing").innerHTML = "<br/>Choose a risk level in the list above to show the survey results for trap locations in Alberta.";
   }



