//
// File : rest-rtwgmap-ui.js
//
// Description : Javascript functions for rendering components on the Dine Alberta Restaurants Map
//               implementation. Overrides several functions found in the 
//               RTWGMap's javascript lib
//
// Contents    : 
//               renderMarkerForSideListing(marker)
//               returnFilteredMarkers(markers)


 
    //
    // Custom Rendering for Dine AB Restaurant 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.address>  
            //                 <marker.town>  
            //                	
            
            // 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/red.png';
            normalImage = '/app68/listings/icons/maps/green.png';
            if(marker.color)
              normalImage = '/app68/listings/icons/maps/' + marker.color + '.png';
                
    	   // add js to make the marker change it's icon if/when the mouse is over the link
		    var tooltipText = marker.tooltip.entityify();
                    
            html += '  onmouseover="bringToFront('+ marker.id + '); gmarkers['+marker.id+'].setImage(\''+ highliteImage + '\'); showTooltip(gmarkers['+marker.id+'], \''+tooltipText+'\');  "';
            html += '  onmouseout="gmarkers['+marker.id+'].setImage(\'' + normalImage + '\'); hideTooltip();"';
			
			//side listing text
            html += '  >' +marker.name + '</a><br/><span class="smallText">'  + marker.address  + '</span>' + '</a><br/><span class="smallText">' +marker.town + '</span><br/><br/>';
        }
        
        return (html);
    }   
    

         
   
   	//
	// Get the label/header for the side listings
	// @see returnFilteredMarkers
	//
	var getSideListingsLabel = function() {
		
        var label = "Serves Regional Cuisine";

		//var markerTypeLabel = markerInfo.markerTypeLabel;
        
        /*if(isFiltering() && selectedFilters[0] != null) {
        	return selectedFilters[0].label ;// + markerTypeLabel;
        }
        
    	if(globalRegion && globalRegion.label && markerTypeLabel != globalRegion.label ) { 
        	label = globalRegion.label;
        } else {
            label = markerTypeLabel;
        }*/
		
		return label;         
    }
    
    
    
    //
    // Get the url to print the current markers/listings
    //
    var getPrintUrl = function(label) {
      //print link
      var subLabel = '';
      var markerTypeLabel = markerInfo.markerTypeLabel;
      
      if(isFiltering() && selectedFilters[0] != null) {
        	subLabel = selectedFilters[0].label ;
			}else if(globalRegion && globalRegion.label && markerTypeLabel != globalRegion.label ) { 
        	subLabel = globalRegion.label;
      } else {
      	//label = markerTypeLabel;
      }
      if(subLabel != null && subLabel.length > 0)
	      label = label + ' - ' + subLabel ;
			var printIcon = "/app21/rtw/icons/maps/printer2.gif";
			return "<center><a href='javascript:printCurrentListings(\"" + label + "\");'><img src='" + printIcon + "' border='0'/></a></center>";
    }
   
   

