//
// File : manure-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 Manure 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.additionalInfo.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/green.png';
            normalImage = '/app68/listings/icons/maps/red.png';
                
            html += '  onmouseover="gmarkers['+marker.id+'].setImage(\''+ highliteImage + '\'); showTooltip(gmarkers['+marker.id+'], \''+marker.name+ ' - ' +summary+'\');  "';
            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 = [];
       var categories = markerObj.additionalInfo.categories;
       for(var i = 0; i < categories.length; i++)  {
           var category = categories[i];           
           var html = eval( "markerObj.additionalInfo." + category.name + "Html");
         
           //add a zoom-in link    
       	   //html += "<br/><span class=\"smallTextCenter\"><a href=\"javascript:zoomIn('" + markerObj.id + "');\">Zoom In</a>" + "</span>&nbsp;&nbsp;";
    
       	   //create the tab
       	   tabs[i] = new GInfoWindowTab(category.label, html);
       }
       
       var opts = {maxWidth:340}; 
       gmarker.openInfoWindowTabs(tabs, opts);
    }



