/* garagesX.js    GARAGES DATA

   v.21f SUV: absolute type
   v.21g Min Hours Spec (SWP)
   images fix
   v.21i No Parking Facilities...
   v.21l floating Arrive/Departure area
   v.21m  versions (get variable)
   v.21n - flashing floating Arr/Dep area
   v.21o7 Partner version (Priority "Partner" Task)
*/

var AREA_CACHE_BORDER = .1;      // Distance in km (approx.) around the viewport to cache

var lastSelectedGarage = null;  // Last selected garage marked on map

var CurrentError = 0;

var SORT_RATE = 1;
var SORT_STREET = 2;
var SORT_AVENUE = 3;
var SORT_NAME = 4;

var arrNAresults = Array("", "",
                         "No Daily Parking",
                         "Parking Limited to ___ Hours",
                         "Arrival Time Equals Closing Time",
                         "Facility Closed at Arrival and/or Departure Time",
                         "Departure Time Equals Opening Time",
                         "No Overnight Parking",
                         "Facility Closed on Date of Arrival and/or Departure" );


var arrWeekDay = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var arrMonthAbbr = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); 


var sort_results = SORT_STREET;   // Sort results by rate/street/avenue

var fetchedBounds = new Array();  // Areas for which garages have been fetched

// Garages in fetched areas; contains all garages that were downloaded, in array of Garage objects
var garages = new Array();        

var cheapestGarage = null;
var cheapestGarCharge = null;

var DTax;
var MTax;

// Current request date:
var requestDate2, // string
currRequestDate;  // Date object

var strTodayDate; // string of today date , format MM/DD/YY , set in listGareges

////  AllManhattan feature
// array of garage IDs (licences) for the certain page number (index of the array)
var arrAllManhattan = new Array(); 
var arrAllManhattanMC = new Array(); // analog of arrAllManhattan for motorcycles

var arrAllManhattanSUV = new Array();
var arrAllManhattanLUX = new Array();

var num_currAllManh = 0;
var popMapIcon = null;

var currSpclsDate = null;
// currSpclsDate - global var ( Date object) to keep current date for specials
// (both specials and coupons) while user selects in popup calendar.
// When popup closed, the currRequestDate value assigned to currSpclsDate .
 

var timerMapDetailLabel = null; // used to hide gar detail poup with delay
var MapDetailLabelGarage = null;

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FORMAT and HELP functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

////     jsFormatTime
function jsFormatTime(oDate, addMins)
{ // format time from Date obj as "11:30AM"
  // used in detail popups
  
if(addMins)  
{ // this addition allows add/subtract minutes from oDate
var new_val = oDate.valueOf() + (addMins*60000);
var oDate = new Date(new_val);
}  
  
var hours = oDate.getHours();
var AMPM = "AM";
if(hours > 12)
{hours -= 12;
AMPM = "PM";
}
else if(hours == 12)
AMPM = "PM";

var minutes = oDate.getMinutes();

var strRet = hours;

if(minutes>0)
{
if(minutes <10) minutes = "0" + minutes;
strRet += ":" + minutes;
}

strRet += AMPM;
if(strRet == "0AM")strRet = "12AM";

return strRet;
}

////     jsSearchHours
function jsSearchHours(oDateArr, oDateDep)
{// difference between Arr and Dep formatted as "HH.MM"
 // used in detail popups
var Diff = (oDateDep.getTime()  - oDateArr.getTime())/60000;
var Hours = Math.floor(Diff/60);
var Min =   Math.floor(Diff%60);
if(Min == 0)return  Hours;
if(Min == 30)Min = 5;
return  Hours + "." + Min;
}

////     jsWeekdayFix
function jsWeekdayFix(oDateArr, oDateDep)
{ // add weekday to Dep if it differs from Arr's
var dep_wd = oDateDep.getDay();

var week = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

if(oDateArr.getDay()!=dep_wd)
return "&nbsp;" + week[dep_wd];
else
return ""; 
}

////     getAbsolutePositionOf
function getAbsolutePositionOf(obj)
{ // position of obj
  var left = 0;
  var top = 0;
  do
  { // go up through all parents, adding offsets
    left += obj.offsetLeft;
    top += obj.offsetTop;
    obj = obj.offsetParent;
  }while(obj);
  return new Array(left, top);
}
////     fmtCurrency
function fmtCurrency(amount)
{
  var dollars = Math.floor(amount);
  var cents = Math.round((amount - dollars) * 100) + "";
  if(cents.length < 2)
    cents = "0" + cents;
  // 
  return "$" + dollars + ((cents != "00")?"." + cents:"");
}
////     AvenueAddress
function AvenueAddress(building, avenue, nearStreet)
{ // useful for combining avenue address of certain format
  this.building = building;
  this.avenue = avenue;
  this.nearStreet = nearStreet;

  this.getStreetHTML = 
    function()
    {
      return (this.nearStreet != null && this.nearStreet != "") ? this.nearStreet : "&nbsp;";
    };
  this.getAvenueHTML = 
    function()
    {
      return this.avenue;
    };
  this.toSimpleString =
    function()
    {
      return this.building + " " + this.avenue;
    };
  this.toString = 
    function()
    {
      var addr = this.building + " " + this.avenue;
      if(this.nearStreet != null && this.nearStreet != "")
        addr += " (" + this.nearStreet + ")";
      return addr;
    };
}
////     StreetAddress
function StreetAddress(building, street, betweenAvenue1, betweenAvenue2)
{// useful for combining street address of certain format
  this.building = building;
  this.street = street;
  this.betweenAvenue1 = betweenAvenue1;
  this.betweenAvenue2 = betweenAvenue2;

  this.getStreetHTML = 
    function()
    {
      if(this.street.substring(0,2) == "W " || this.street.substring(0,2) == "E ")
        return this.street.substring(2);
      else
        return this.street;
    };
  this.getAvenueHTML = 
    function()
    {
      return (this.betweenAvenue1 != null && this.betweenAvenue2 != null && this.betweenAvenue1 != "" && this.betweenAvenue2 != "") ? this.betweenAvenue1 + " / " + this.betweenAvenue2 : "&nbsp;";
    };
  this.toSimpleString =
    function()
    {
      return this.building + " " + this.street;
    };
  this.toString = 
    function()
    {
      var addr = this.building + " " + this.street;
      if(this.betweenAvenue1 != null && this.betweenAvenue2 != null && this.betweenAvenue1 != "" && this.betweenAvenue2 != "")
        addr += " (bet. " + this.betweenAvenue1 + " & " + this.betweenAvenue2 + ")";
      return addr;
    };
}

////     getGMTTime
function getGMTTime(d)
{
  return d.getTime() - d.getTimezoneOffset()*60*1000;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Label functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

////     HideMapDetailLabel
function HideMapDetailLabel(oGar)
{ // hide garage detail popup on the map
     if(MapDetailLabelGarage)MapDetailLabelGarage.showingMapDetailLabel = false;

     DisplayElem("map_detail_label", "none");
      
     if(typeof(oGar)=='undefined')oGar = MapDetailLabelGarage.garage;
    
     // Exp Wins
     if(typeof(setWindowHeight)=="function")setWindowHeight(oGar, "overclose");      
     
     clearTimeout(timerMapDetailLabel);
}


var FlikerTimer = null; // timer for all flicking messages
var b_flick = true;

////     FlickText
function FlickText()
{ // the function called by FlikerTimer timer defined in Init() [index.php]
  // it changes styles for all defined spans simultaneously

var add = "";

if(b_flick)
var new_class = "flickoff";
else
var new_class = "flickon";

b_flick = !b_flick; // switch it

var enter = document.getElementById('flick5');
if(enter){
if(!parking_isCase)
enter.className = new_class + "5";
else
enter.className = "flickon5";
}

if(GetElement('flick15') && bDayNotFocus)
{
if(parking_isCase)
GetElement('flick15').className = "flickon15static";
else
GetElement('flick15').className = new_class + "15";
}

// every text (span) to be flicking has id of type 'flick' + i
// so it goes through them and changes className 
for( var i = 1; i < 15; i++)
{
// 15 Arr/Dep area

oSpan = document.getElementById('flick' + i);
if(!oSpan)continue;
  
add = i;


// some have different IDs but the same class name
if(i == 1 || i == 2 || i == 3)add = "2"; 
if(i == 5 || i == 14)continue;


if(i == 7 || i == 8 || i == 9)add = "7";

if(i == 12 || i == 13)add = "12";

oSpan.className = new_class + add;


}
  

}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   UPDATE and LIST garages functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* *********************
updateGarages
********************* */

function updateGarages(par)
{ //// called on map move end, by map event
  //// the function checks whether needed garages(data) is JScript or should be downloaded
  // par - if set means that "All Manhattan" should go to 1st page (from Monthly 'Reguler', 'SUV or Van ... btns )
  
  CurrentError = 0; 

   // hide all Exp Wins
   if(typeof(ClearAllExpWindows)=="function")
   ClearAllExpWindows();

   //DisplayElem("charge_float", "none");

   // hide popups 
   HideGreenDetails();
    
  if(num_currAllManh)
  {
    
   if(par == 1)num_currAllManh = 1;
  
   if(parking_vehicle == VEHICLE_MOTORCYCLE)
   var loc_exists = arrAllManhattanMC[num_currAllManh];
   else
   var loc_exists = arrAllManhattan[num_currAllManh];


  if(!loc_exists)
     {
     //arrAllManhattan[numAllManhattan] = new Array('1','2');
     sort_results = SORT_RATE; //SORT_RATE  rates_away
     return fetchGaragesAroundBounds(0, num_currAllManh);
     }
     else
     {
     return listGarages(num_currAllManh);
     }

  }



  var viewportBounds = gMap.getBounds(); // displayed map area 

  // If any part of the viewport is outside the downloaded areas, download garage data
  var fetchViewport = true;
  
  for(var i=0; i<fetchedBounds.length; i++)
  {
    if( fetchedBounds[i].containsBounds(viewportBounds) )
    {
      
      if(MS_VERSION!=2)// Monthly Specs
      if(typeof(arrFetchedMonthSpecs)!='undefined') 
      arrCurrentMonthSpecs = arrFetchedMonthSpecs[i];
      
      fetchViewport = false;
      break;
    }
  }

  // If any of the garages in the area don't have data for this parking case, download garage data
  var fetchCase = false;
  if(!fetchViewport && parking_isCase)
  {
    for(var id in garages)
    {
      if(!garages[id].primaryEntrance)continue;
    
      if(viewportBounds.contains(garages[id].primaryEntrance.latLng) 
          && !garages[id].hasCaseResult(parking_arrival, parking_departure, parking_vehicle) )
      {
        fetchCase = true;
        break;
      } 
    }
  }
  // check whether daily was to ensure specials uploaded
  if(!fetchViewport && GREEN && !parking_isCase && !parking_isMonthly)
  {
    for(var id in garages)
    {
      if(!garages[id].primaryEntrance)continue;

      if(viewportBounds.contains(garages[id].primaryEntrance.latLng) 
         && !garages[id].dailyLoaded)
      {
        fetchCase = true;
        break;
      } 
    }
  }
  
  if(fetchViewport || fetchCase)
    fetchGaragesAroundBounds(viewportBounds);  // download; calls listGarages() when done
  else
    listGarages(); // just refresh garages
}

/* *********************
fetchGaragesAroundBounds
********************* */

function fetchGaragesAroundBounds(centreBounds, manh)
{ /// called by updateGarages() or  ByAllManhattan() (mapX.js)
  /// prepare URL and request XML
   // manh - if set it's All Manhattan and manh is number of the page to request
  
    
  if(!manh) // non-AllManhattan
  {
  // bounds extended by cache border (converting kilometers to approx. lat/lon for NY)
 
  var bounds = new GLatLngBounds(new GLatLng(parseFloat(centreBounds.getSouthWest().lat()) - parseFloat(AREA_CACHE_BORDER/671),
                                            parseFloat(centreBounds.getSouthWest().lng()) - parseFloat(AREA_CACHE_BORDER/571)),
                                 new GLatLng(parseFloat(centreBounds.getNorthEast().lat()) + parseFloat(AREA_CACHE_BORDER/671),
                                            parseFloat(centreBounds.getNorthEast().lng()) + parseFloat(AREA_CACHE_BORDER/571)));

if(
(parseFloat(bounds.getSouthWest().lat()) + parseFloat(AREA_CACHE_BORDER/671))
 ==
(parseFloat(bounds.getNorthEast().lat()) - parseFloat(AREA_CACHE_BORDER/671))
)
{

alert("\nPLEASE CLICK THE **REFRESH** BUTTON IN YOUR BROWSER. PARKING FACILITIES FAILED TO PROPERLY LOAD.\n\n\n" +

"If you continue to have trouble and...\n\n" + 

"BestParking is NOT your home page,\n" + 
"(1) close and reopen the browser window or tab,\n" +
"(2) adjust window size and/or sidebar view (e.g., Favorites), and only then\n" + 
"(3) freshly load BestParking.com - DO NOT adjust window size or sidebar again\n" + 
"until you have run your intial search and you see the Google map displayed.\n\n" + 

"BestParking IS your home page,\n" +
"(1) close and reopen the browser window or tab,\n" +
"(2) DO NOT adjust window size and/or sidebar view (e.g., Favorites)\n" +
"until you have run your initial search and you see the Google map displayed.");

return;
}

  
  var url = XML_GARAGES_URL;
  url += "?area=" + bounds.getSouthWest().lng() + "," + bounds.getSouthWest().lat() + "," + bounds.getNorthEast().lng() + "," + bounds.getNorthEast().lat();
  if(parking_isCase)
    url += "&arr=" + getGMTTime(parking_arrival)/1000 + "&dep=" + getGMTTime(parking_departure)/1000 + "&veh=" + parking_vehicle;
  if(!parking_isMonthly)
  url += "&daily";
  
  if(typeof COMPANY != 'undefined')if(COMPANY != '')
  url += "&company=" + escape(COMPANY); 
  
  }
  else  // AllManhattan
  {
  var url = XML_GARAGES_URL + "?manh=" +  manh + "&veh=" + parking_vehicle;
  }
  
  if(GetElement("debug_div"))if(GetElement("debug_div").style.display == 'block')
  GetElement("debug_div").value = url;  
  var xmlDoc = getXML(url, doneFetchGaragesAroundBounds);

  
   /* *********************
   doneFetchGaragesAroundBounds
   ********************* */
  function doneFetchGaragesAroundBounds(xmlDoc)
  { /// XML request callback function
    /// Parse XML data for garages returned
   
    if(xmlDoc == null || xmlDoc.xml == "")
    {
      //alert("xmlDoc" + xmlDoc);
      alert("Could not retrieve garage data at this time. Please try again shortly.");
      return;
    }
    
  try {
   
   var xmlGeneral = xmlDoc.documentElement.getElementsByTagName("General")[0];
   
   DTax =   xmlGeneral.getAttribute("dtax");
   MTax =   xmlGeneral.getAttribute("mtax");
   
   requestDate2 =   xmlGeneral.getAttribute("reqdate2");
   
   var tmp_arr_date = requestDate2.split("-");

   currSpclsDate = currRequestDate = currDate = new Date(tmp_arr_date[0],
      tmp_arr_date[1] - 1,
      tmp_arr_date[2], 0, 0, 0);
      
    var xmlAllManh = xmlDoc.documentElement.getElementsByTagName("AllManhattan")[0];

   if(!xmlAllManh) //// Non-'All Manhattan'
   {
   
   var centreBounds = gMap.getBounds();
     
   var bounds = new GLatLngBounds(new GLatLng(parseFloat(centreBounds.getSouthWest().lat()) - parseFloat(AREA_CACHE_BORDER/671),
                                            parseFloat(centreBounds.getSouthWest().lng()) - parseFloat(AREA_CACHE_BORDER/571)),
                                 new GLatLng(parseFloat(centreBounds.getNorthEast().lat()) + parseFloat(AREA_CACHE_BORDER/671),
                                            parseFloat(centreBounds.getNorthEast().lng()) + parseFloat(AREA_CACHE_BORDER/571)));
   }

   
   if(xmlAllManh) // 'All Manh'
   {
   var numAllManh = xmlAllManh.getAttribute("num"); // page number
   var vehAllManh = xmlAllManh.getAttribute("veh");
   
   var strAllManh = new String(xmlAllManh.firstChild.nodeValue);
   
  // set array of garage licences for the page (numAllManh)
  if(vehAllManh == VEHICLE_MOTORCYCLE)
   arrAllManhattanMC[numAllManh] = strAllManh.split(","); 
  else 
   arrAllManhattan[numAllManh] = strAllManh.split(",");
   
   // SUV, Lux garages lists
   
  var xmlAllManhSUV = xmlDoc.documentElement.getElementsByTagName("AllManhattanSUV")[0];
  var strAllManhSUV = new String(xmlAllManhSUV.firstChild.nodeValue);
  arrAllManhattanSUV[numAllManh] = strAllManhSUV.split(","); 
  
  var xmlAllManhLUX = xmlDoc.documentElement.getElementsByTagName("AllManhattanLUX")[0];
  var strAllManhLUX = new String(xmlAllManhLUX.firstChild.nodeValue);
  arrAllManhattanLUX[numAllManh] = strAllManhLUX.split(",");   
   
   }
   
   var xmlGarages = xmlDoc.documentElement.getElementsByTagName("Garage");
    
    // go through all garages
    for(var i=0; i<xmlGarages.length; i++)
    {
      var xmlGarage = xmlGarages[i];
      var licenceNumber = xmlGarage.getAttribute("licenceNumber");
      
      // CREATE new garage object
      if( garages[licenceNumber] == null )
      {
        var g = new Garage();
        // parse licence number, name, longitude and latitude, opening hours, capacity, phone
        g.licenceNumber = licenceNumber;
        
        g.garageNumber = getXMLAttr(xmlGarage, "garageNumber");
        
        g.company = xmlGarage.getAttribute("company");
        g.name = xmlGarage.getAttribute("name");
        if(g.company != "")g.name = g.company + " " + g.name;

        g.baseGreen = g.green = getXMLAttr(xmlGarage, "green", 0); 
        
        g.dps2nd = getXMLAttr(xmlGarage, "dps2nd", 0);
        g.lst7 = getXMLAttr(xmlGarage, "lst7", 0);
        
        //green==0 for plain garage, green==1 for RG and green==2 for R one
        g.sredir = getXMLAttr(xmlGarage, "sredir", 0); 
        
        g.noDPS = getXMLAttr(xmlGarage, "noDPS", 0);

        g.freeSUVspec = 0;
        g.freeSUVspec = getXMLAttr(xmlGarage, "freeSUVspec");
        
        g.blckTxt = 0;
        g.blckTxt = getXMLAttr(xmlGarage, "blackTxt");

        g.partner = getXMLAttr(xmlGarage, "partner");
        g.partner2 = getXMLAttr(xmlGarage, "p2"); // partner : list 2
        
        var xmlOpeningHours = xmlGarage.getElementsByTagName("OpeningHours");
        if( xmlOpeningHours.length > 0 && xmlOpeningHours[0].firstChild != null )
        g.openingHours = xmlOpeningHours[0].firstChild.nodeValue;
        
        g.capacity = xmlGarage.getAttribute("capacity");
        g.phone = xmlGarage.getAttribute("phone");
        g.phoneday = xmlGarage.getAttribute("phoneday");
        g.entranceNotes = xmlGarage.getAttribute("entranceNotes");
       
        // monthly spec
        g.monspec = getXMLAttr(xmlGarage, "monthspec");
        
        // contact date
        g.contact = getXMLAttr(xmlGarage, "contact");
        
        g.addresses = xmlGarage.getAttribute("addresses") + "<br>";
        
        // parse entrances
        var xmlEntrances = xmlGarage.getElementsByTagName("Entrance");
        g.addressHTML = "";
        g.entrances = new Array();
        // currently just single 1st entrance in used
        for(var n=0; n<xmlEntrances.length; n++)
        {
          var xmlEntrance = xmlEntrances[n];
          g.addressHTML += xmlEntrance.getAttribute("addressText") + "<br>";
          var entrance = new Entrance( g, new GLatLng(xmlEntrance.getAttribute("latitude"), xmlEntrance.getAttribute("longitude")) );
           
          if(n == 0)
          {
            // ExpWin
            //g.entrance_other = new EntranceOther( g, new GLatLng(xmlEntrance.getAttribute("latitude"), xmlEntrance.getAttribute("longitude")) );
            g.primaryEntrance = entrance;
            g.streetText = xmlEntrance.getAttribute("streetText");
            g.avenueText = xmlEntrance.getAttribute("avenueText");
          }
          g.entrances[n] = entrance;
        }
        
        if(g.addressHTML=="<br>")g.addressHTML = "";
        
        // parse monthly parking scheme data
        var xmlMonthlyParkingSchemes = xmlGarage.getElementsByTagName("MonthlyParkingScheme");
        if(xmlMonthlyParkingSchemes.length > 0)
        {
          var xmlMonthlyParkingScheme = xmlGarage.getElementsByTagName("MonthlyParkingScheme")[0];
          // Reg
          var xmlBaseRate = getXMLAttr(xmlMonthlyParkingScheme, "baseRate");
          if(xmlBaseRate)
          g.setMonthlyRate(VEHICLE_REGULAR, xmlBaseRate.split(" "));
          // SUV
          var xmlSuvRate = getXMLAttr(xmlMonthlyParkingScheme, "suvRate");
          if(xmlSuvRate)
          g.setMonthlyRate(VEHICLE_SUV, xmlSuvRate.split(" "));
          // Lux
          var xmlLuxRate = getXMLAttr(xmlMonthlyParkingScheme, "luxRate");
          if(xmlLuxRate)
          g.setMonthlyRate(VEHICLE_LUXURY, xmlLuxRate.split(" "));
          // M/C
          var xmlmcRate = getXMLAttr(xmlMonthlyParkingScheme, "mcRate");
          if(xmlmcRate)
          g.setMonthlyRate(VEHICLE_MOTORCYCLE, xmlmcRate.split(" "));
          
        }

        // Add garage to local list
        garages[licenceNumber] = g;
        
      }
      
        
        if(!garages[licenceNumber].dailyLoaded)
        {
        garages[licenceNumber].baseGreen = garages[licenceNumber].green = getXMLAttr(xmlGarage, "green", 0); 
        //green==0 for plain garage, green==1 for RG and green==2 for R one
        garages[licenceNumber].partner = getXMLAttr(xmlGarage, "partner");
                
        }        
        
        
      //excluded dates
      if(xmlGarage.getAttribute("exclDates"))   
      garages[licenceNumber].exclDates = " " + xmlGarage.getAttribute("exclDates"); 

       
      // insert or replace comments for garage
      var xmlDailyComments = xmlGarage.getElementsByTagName("DailyComments");
      if( xmlDailyComments.length > 0 && xmlDailyComments[0].firstChild != null )
        garages[licenceNumber].dailyComments = xmlDailyComments[0].firstChild.nodeValue;
      
      var xmlMonthlyComments = xmlGarage.getElementsByTagName("MonthlyComments");
      if( xmlMonthlyComments.length > 0 && xmlMonthlyComments[0].firstChild != null )
        garages[licenceNumber].monthlyComments = xmlMonthlyComments[0].firstChild.nodeValue;

      var xmlMonthlyTopAttrs = xmlGarage.getElementsByTagName("MonthlyTopAttr");
      if( xmlMonthlyTopAttrs.length > 0 && xmlMonthlyTopAttrs[0].firstChild != null )
        garages[licenceNumber].monthlyTopAttr = xmlMonthlyTopAttrs[0].firstChild.nodeValue;

      var xmlDailyTopAttrs = xmlGarage.getElementsByTagName("DailyTopAttr");
      if( xmlDailyTopAttrs.length > 0 && xmlDailyTopAttrs[0].firstChild != null )
        garages[licenceNumber].dailyTopAttr = xmlDailyTopAttrs[0].firstChild.nodeValue;

      var xmlDailyEventAttrs = xmlGarage.getElementsByTagName("DailyEventAttr");
      if( xmlDailyEventAttrs.length > 0 && xmlDailyEventAttrs[0].firstChild != null )
        garages[licenceNumber].dailyEventAttr = xmlDailyEventAttrs[0].firstChild.nodeValue;

      //alert(garages[licenceNumber].monthlyTopAttr);


     // If charge information was returned for a specific parking case, parse and store it
      var xmlDailyCases = xmlGarage.getElementsByTagName("DailyCase");
      
      for(var n=0; n<xmlDailyCases.length; n++)
      {
        var xmlDailyCase = xmlDailyCases[0];
        
        var SUVdaily = xmlDailyCase.getAttribute("SUVdaily");
        var SUVrate = xmlDailyCase.getAttribute("SUVrate");
        var SUVunit = xmlDailyCase.getAttribute("SUVunit");
        
        garages[licenceNumber].suvType = getXMLAttr(xmlDailyCase, "SUVtype", 1);
                             
        // combine strSUV
        if(! (POP_SUVTAX_TYPE==3 && SUVdaily == "0.00"))
        {
        
        if(SUVdaily != "")
        garages[licenceNumber].strSUV = "$" + SUVdaily + " Per Day"; 
        if (SUVrate != "" && SUVrate != "0")
        garages[licenceNumber].strSUV = "$" + SUVrate + " every " + SUVunit + " Hrs";
        
        }
        
        //alert(parking_isCase);
                                              
        if(parking_isCase)
        {
        var arrGMT = new Date( parseInt(xmlDailyCase.getAttribute("arrival")) * 1000 );
        var depGMT = new Date( parseInt(xmlDailyCase.getAttribute("departure")) * 1000 );
        var veh = parseInt( xmlDailyCase.getAttribute("vehicle") );
        
        var charge = parseFloat( xmlDailyCase.getAttribute("charge") );
       
        var charge_str  = xmlDailyCase.getAttribute("charges");
        
        // compare Coupon
        var compCouponId = getXMLAttr(xmlDailyCase, "compCouponId", 0);
        var arrCompCoupon = null;
        
        if(compCouponId != 0)
        {
        var compCouponStr = getXMLAttr(xmlDailyCase, "compCouponStr", "");
        var arrCompCoupon = Array(compCouponId, compCouponStr);
        }
        
        var chargeComments = xmlDailyCase.getAttribute("comments");
        
        var SUVperirp = getXMLAttr(xmlDailyCase, "SUVpIRP");
        
        //if(SUVperirp)
       // alert(licenceNumber + ": SUVperirp: " + SUVperirp);
                
        // add daily case
        garages[licenceNumber].addCaseResult(arrGMT, depGMT, veh, charge, chargeComments, SUVperirp, charge_str, arrCompCoupon);
        
        }
        if(!parking_isMonthly)
        garages[licenceNumber].dailyLoaded = 1;
      } 
   
     } // END all garages
      
      
      //// parse Specials
      if(!parking_isMonthly)
      {
        if(typeof(parseXML_AllSpecs)=='function')
        {
        var xmlGarSpecs = xmlDoc.documentElement.getElementsByTagName("GarageSpecials")[0];
        parseXML_AllSpecs(xmlGarSpecs); // r_rg_functions.js 
        }
      }
      
      //// Monthly Specs 
       if(MS_VERSION==2)
      { 
       if(typeof(parseXML_MonthlySpecsVer2)=='function')
       parseXML_MonthlySpecsVer2(xmlDoc);
      }
      else if(typeof(parseXML_MonthlySpecs)=='function')
       var loc_arrAreaMonSpec = parseXML_MonthlySpecs(xmlDoc);

      
      //// Weekly Specs (ExpWin)
      if(typeof(parseXML_WeeklySpecs)=='function')
      parseXML_WeeklySpecs(xmlDoc);
      
       // TIMER
       var xmlGeneral = xmlDoc.documentElement.getElementsByTagName("Timer")[0];
       PerfPHPTime =   xmlGeneral.getAttribute("time");
       
    
    // Add to list of downloaded areas
     if(!xmlAllManh)
     {
     fetchedBounds[fetchedBounds.length] = bounds;
          if(MS_VERSION!=2 && typeof(arrFetchedMonthSpecs)!='undefined') // Monthly Specs
          {
          arrFetchedMonthSpecs[fetchedBounds.length - 1] = loc_arrAreaMonSpec;
          arrCurrentMonthSpecs = loc_arrAreaMonSpec; 
          }
     }
    
    
    
    }catch(e) {alert("error in parsing XML." + "\n" + e.description );jserror(5, e.number + " " + e.description);CurrentError = 1;}  //+ "\n" + e.description
    
        // display result list
        if(xmlAllManh) 
        listGarages(numAllManh);
        else
        listGarages();
        
  }
}


////     getXMLAttr
function getXMLAttr(oElem, strAttrName, def_val)
{ // to get attribute only if it listed
if(!oElem.getAttribute(strAttrName))
{if(typeof(def_val)=='undefined') return null; else return def_val;}

return oElem.getAttribute(strAttrName);
}


////     compareAvenues
function compareAvenues(g1, g2)
{  ///  used in listGarages for sorting

        // try to get avenue number
        var g1AvenueNum = parseInt(g1.avenueText);
        var g2AvenueNum = parseInt(g2.avenueText);
        
        if( isNaN(g1AvenueNum) || g1AvenueNum == 0 || isNaN(g2AvenueNum) || g2AvenueNum == 0 )
        { // one of number not accessble - compare by coordinates
        
          var g1Rotated = rotateLatLng(g1.primaryEntrance.latLng, CITY_ROTATE_ANGLE); // defined in index.php
          var g2Rotated = rotateLatLng(g2.primaryEntrance.latLng, CITY_ROTATE_ANGLE); 
          return g2Rotated.lng() - g1Rotated.lng();
        }
        else
        {
          if(g1AvenueNum == g2AvenueNum)// 2nd sort is by streets
          return compareStreets(g1, g2);
        
          return g1AvenueNum - g2AvenueNum;
        }
}

////     compareAvenues
function compareStreets(g1, g2)
{  ///  used in listGarages for sorting
        // try to get avenue number
        var g1StreetNum = parseInt(g1.streetText);
        var g2StreetNum = parseInt(g2.streetText);
        
        if( isNaN(g1StreetNum) || g1StreetNum == 0 || isNaN(g2StreetNum) || g2StreetNum == 0 )
        { // one of number not accessble - compare by coordinates
          
          var g1Rotated = rotateLatLng(g1.primaryEntrance.latLng, CITY_ROTATE_ANGLE);
          var g2Rotated = rotateLatLng(g2.primaryEntrance.latLng, CITY_ROTATE_ANGLE);
          return g1Rotated.lat() - g2Rotated.lat();          
          
        }
        else
        {
          if(g1StreetNum == g2StreetNum)
          {
          if(parseInt(g1.avenueText) == parseInt(g2.avenueText))return 0; // to avoid endless loop
          return compareAvenues(g1, g2); // 2nd sort is by avenues
          }
          else
          return g1StreetNum - g2StreetNum;
        }

}


/* *********************
     listGarages
********************* */
function listGarages(numManh)
{  // display garages on the map and in the result list

   // numManh - if set, All Manhattan view mode to be displayed
   // and numManh is index in arrays
   // alert("listGarages ");
  
   // hide all Exp Wins
   if(typeof(ClearAllExpWindows)=="function")
   ClearAllExpWindows();  
  
  bSpecialsMapView = false; // ExpWin
  
  var listedGarages = new Array();
 
  // used by Coupons & Specials window
  arrDisplayedGreenGarages = new Array();
  // used by Monthly Specs window
  arrAreaMonthSpecs = new Array();
  
  var bSpecLoad = false;
 
  var useRatesGradient = ( 
                         (RATES_GRADIENT_S2 && (parking_isCase && !parking_isMonthly)) //S2  
                          ||
                         (RATES_GRADIENT_MO && parking_isMonthly) // Monthly
                          ||
                         (parking_isCase && parking_isByColorRates) 
                         );
  
  // color_switch feature
  if(!parking_isMonthly && parking_isCase)
  {
  DisplayElem("color_switch", "visible");
  }
  
  if(useRatesGradient)
  { /// Gradient feature
  var lowestCharge = 9999999;
  var highestCharge = 0;
  cheapestGarage = null;
  cheapestGarCharge = null; 
  }

  // selecting garages into listedGarages
  
  if(numManh)
  {  // By All Manhattan 
 
  //DisplayElem("garage_list_div", "block");
  
  // select array of garages IDs
  if(parking_vehicle == VEHICLE_REGULAR) 
  var arrTempManh = arrAllManhattan[numManh];
  else if(parking_vehicle == VEHICLE_SUV)
  var arrTempManh = arrAllManhattanSUV[numManh];
  else if(parking_vehicle == VEHICLE_LUXURY)
  var arrTempManh = arrAllManhattanLUX[numManh];    
  else if(parking_vehicle == VEHICLE_MOTORCYCLE)
  var arrTempManh = arrAllManhattanMC[numManh];
  
  for(var n = 0; n<arrTempManh.length; n++)
  {  // go through IDs, adding them to listedGarages and selecting charge
   
   var g = garages[arrTempManh[n]];
   var charge = g.getMonthlyRate(parking_vehicle); // All Manhattan is only Monthly !!
   
   g.tempCharge = charge;
   
   listedGarages[listedGarages.length] = g;
   
  if(useRatesGradient)
  { /// Gradient feature
   if(charge != null && charge > 0 && charge < lowestCharge)
        {lowestCharge = charge;cheapestGarage = g;  }

   if(charge != null && charge > 0 && charge > highestCharge)
        highestCharge = charge;
  }
  
  }      
  
  }
  else
  {  // Regular (not All Manhattan)

  // Get garages in viewport and load their applicable charges

  // date for Excluded Dates
  var strCurrEDDate = currRequestDate.getMonth() + "-" + currRequestDate.getDate();
  
  //alert("strCurrEDDate: " + strCurrEDDate);
  
  var viewportBounds = gMap.getBounds();// map viewport
 
  // go through all garages
  for(var id in garages)
  {
    var g = garages[id];
    
    var isGarageInViewport = false;
    
    // whether garage coordinates within map viewport
    for(var n=0; n<g.entrances.length; n++)
    { 
      if( viewportBounds.contains(garages[id].entrances[n].latLng) )
      { 
        isGarageInViewport = true;
        break;
      }
    }
    
   
    if(isGarageInViewport)
    {
      
      listedGarages[listedGarages.length] = g;
      
      //// check Excluded dates
      
      if(g.exclDates.indexOf(strCurrEDDate) > -1)
      g.green = 0;
      else
      g.green = g.baseGreen;
      
       
      if(g.green > 0)
      { // for All Specs loading , C & S system
      arrDisplayedGreenGarages[arrDisplayedGreenGarages.length]=g.licenceNumber; 
      if(!g.spclsLoaded) bSpecLoad = true;
      }
      
      // Monthly Specs - select ids for the area
      if(g.monspec) // parking_isMonthly && 
      {
      var loc_monspec = g.monspec;
      var isInArr = false;
      for(var ms = 0; ms < arrAreaMonthSpecs.length; ms++)
      {
      if(arrAreaMonthSpecs[ms] == loc_monspec){isInArr = true;break;}
      }  
      
      if(!isInArr)arrAreaMonthSpecs[arrAreaMonthSpecs.length]=loc_monspec;
     
      }
      
      
      // select garage rate
      if(parking_isMonthly) // monthly 
      {
        charge = g.getMonthlyRate(parking_vehicle);
        //alert(charge); 
        
      }
      else if(parking_isCase) // daily
      {
        caseResult = g.getCaseResult(parking_arrival, parking_departure, parking_vehicle);
        if(!caseResult)    // error fetching garage data
          return;
        g.tempCaseResult = caseResult;
        charge = caseResult.charge;
      }

       g.tempCharge = charge;
      
      /// Gradient feature  
      if(useRatesGradient)
      { 
      
       // lowest
      if(                                                                   // -11 is 'Get Deal'
      (g.green == 0 || parking_isMonthly )&& charge != null && charge > 0 && charge < lowestCharge
      )
      {  
        lowestCharge = charge; // 'Get Deal' will be first
        cheapestGarage = g; 
      }
        // highest
      if(charge != null && charge > 0 && charge > highestCharge)
        highestCharge = charge;
      }  

    } 
     // display garage icon on the map
    for(var n=0; n<g.entrances.length; n++)
      g.entrances[n].requireDisplay(isGarageInViewport); 
   }

  }
  // end select garages into listedGarages

  
  // load All Specials
  if(!parking_isCase && bSpecLoad)
  if(typeof(LoadXML_AllSpecs)=='function')
  LoadXML_AllSpecs(currRequestDate);  // all_specials.js
  
 /// Gradient feature 
  //if(useRatesGradient && (parking_isCase || parking_isMonthly) && !numManh)
  if(useRatesGradient && !numManh)
  {
  cheapestGarCharge = lowestCharge;
  }

  //if(parking_isMonthly && !numManh)
  if(useRatesGradient && !numManh)
  {
  DisplayElem("rates_gradient", "visible");
  }
  else
  {
  DisplayElem("rates_gradient", "hidden");
  }  

  // SORT list South to North or by Rate
  
  listedGarages = SortGarages(listedGarages);
  
   
  // Output HTML of R E S U L T  list
  
  var GarListHTML = "";

  GarListHTML += '<center><table class="plain" cellspacing="0" style="color:#191919;font-size:17px;font-weight:bold;">';
  
  if(numManh)
  GarListHTML += '<tr class="do_not_print"><td><span style="/*color:#033859;*/">Click a Garage</span> in the list below to view its details</td>';
  else{
  GarListHTML += '<tr class="do_not_print"><td><span style="/*color:#033859;*/">Click a Garage</span> in the list below to highlight it in <span style="color:#033859;/*4b0082;*/">Blue</span>&nbsp;</td>';
  GarListHTML += '<td><img src="' + PATH_IMG + 'images/list_garage_icon21.gif"></td>';       
  GarListHTML += '<td>&nbsp;on the map</td>';
  }
  GarListHTML += '</table></center><br>';
  
  
  if(numManh)
  {  // "Previous 1-50 Next" links for All Manhattan mode 
  var start_num =  parseInt((numManh - 1)*50) +1;
  var end_num = parseInt(start_num) + 49; 
  
  if(numManh == 1)
  var strPrevious = 'Previous';
  else
  var strPrevious = '<a href="javascript:ByAllManhattan(' + (parseInt(numManh)-1)  + ')">Previous</a>';
  
  var nextNum = (parseInt(numManh)+1);

  var strNext = '<a href="javascript:ByAllManhattan(' + nextNum  + ')">Next</a>';
  
  GarListHTML += "<center><span class='manhdir'>" + strPrevious + 
  "&nbsp;&nbsp;&nbsp; " +  start_num + " - " + end_num  + 
  " &nbsp;&nbsp;&nbsp;" + strNext + "</span></center><br>";
 
  }
  
  var addManhNum = "";
  if(numManh)addManhNum = numManh;
  
  // result table header
  GarListHTML += "<table id='garage_table' cellspacing='0' width='100%'><tr>";

  
  if(sort_results == SORT_NAME)
    GarListHTML += "<th style='padding:0.75em;'><nobr>Name&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21_dis.gif'></nobr></th>";
  else
    GarListHTML += "<th style='padding:0.75em;'><a href='javascript:sort_results=SORT_NAME;listGarages(" + addManhNum + ");'>" + 
    "<nobr><span>Name&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21.gif'></span></nobr>" + "</a></th>";
  
  
  if(sort_results == SORT_STREET)
    GarListHTML += "<th><nobr>" + TABLE_HEAD_ST + "&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21_dis.gif'></nobr></th>";
  else
    GarListHTML += "<th><a href='javascript:sort_results=SORT_STREET;listGarages(" + addManhNum + ");'>" +
    "<nobr><span>" + TABLE_HEAD_ST + "&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21.gif'></span></nobr></a></th>";
  
  if(sort_results == SORT_AVENUE)                                               
    GarListHTML += "<th><nobr>" + TABLE_HEAD_AV + "&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21_dis.gif'></nobr></th>";
  else
    GarListHTML += "<th><a href='javascript:sort_results=SORT_AVENUE;listGarages(" + addManhNum + ");'>" +
    "<nobr><span>" + TABLE_HEAD_AV + "&nbsp;&nbsp;<img src='" + PATH_IMG + "images/sort_arrow21.gif'></span></nobr></a></th>";
  
  if(parking_isMonthly)
    rateName = "Monthly Rate" + TABLE_HEAD_TAX;
  else if(parking_isCase)    
    rateName = "Rate" + TABLE_HEAD_TAX;
  else
    rateName = null;
    
  if(rateName)
  {
     var loc_pad = '&nbsp;';
     if(TABLE_HEAD_TAX == '')loc_pad = '&nbsp;';
  
    if(sort_results == SORT_RATE)
      GarListHTML += "<th>" + 
      '<center><table class="rateth" cellspacing="0"><tr><th>' +
       rateName + '</th><th><nobr>' + loc_pad + 
       "<img src='" + PATH_IMG + "images/sort_arrow21_dis.gif'>&nbsp;</nobr></th></tr></table></center></th>";
    else
      GarListHTML += '<th><center>'
       + '<table  class="rateth" cellspacing="0"><tr><th><a href="javascript:sort_results=SORT_RATE;listGarages(' + addManhNum + ');">' +
       rateName + '</a></th><th><nobr>' + loc_pad + '<a href="javascript:sort_results=SORT_RATE;listGarages(' + addManhNum + ');">' + 
       "<img src='" + PATH_IMG + "images/sort_arrow21.gif'></a>&nbsp;</nobr></th></tr></table></center></th>";
  }
  else
  { // S1 last column
  GarListHTML += "<th id='charge_col' width='86'><center>Rate" + TABLE_HEAD_TAX + "</center></th>";
  }
  
  GarListHTML += "</tr>";

    
  // outputting garages into the result list
  
  for(var i=0; i<listedGarages.length; i++)
  {
    var g = listedGarages[i];
    
    g.spec_view = ""; // ExpWin
    
    var greenclass = "";
    
    if(!parking_isMonthly)
    {  // row background for RG & R garages
    if(g.green == 1)
    greenclass = " class='garrg'";
    else if(g.green == 2)
    greenclass = " class='garr'"; 
    }
    
    if(parking_isMonthly && TABLE_HIGH_RG && g.partner2 && (g.tempCharge > 0 || g.tempCharge==-11))
    greenclass = " class='garr'";
   
    if(num_currAllManh)
    { // Manh has special function to select garage - select_no_map
    GarListHTML += "<tr " + greenclass + " title='Click garage name to see details' align='left' ><td><a id='garage_link_" + g.licenceNumber + 
    "' href='javascript:garages[" + g.licenceNumber + "].select_no_map(false);'";
    }
    else
    {
    GarListHTML += "<tr " + greenclass + " title='Click garage name to see details' align='left' ><td><a id='garage_link_" + g.licenceNumber + 
    "' href='javascript:garages[" + g.licenceNumber + "].select(false);'";
    }
    
    // 1st, name/address cell
    if(g == lastSelectedGarage)
      GarListHTML += " class='selectedGarageName'";
    GarListHTML += ">" + g.name;
    
    if(!parking_isMonthly && parking_isCase)
    {
    if(g.green == 1)
    GarListHTML += '&nbsp;&nbsp;<span class="lnk_und">CLICK HERE FOR RATE GUARANTEE</span>';
    else if(g.green == 2)
    GarListHTML += '&nbsp;&nbsp;<span class="lnk_und">CLICK HERE FOR RESERVATION</span>';
    }
    
    if(numManh)
    GarListHTML += '&nbsp;&nbsp;<span class="lnk_und">CLICK FOR DETAILS/MAP</span>';
    
    GarListHTML += "<br>" + g.addressHTML + "</a></td>";
    
    // street, avenue cells 
    var loc_st = g.streetText; if(loc_st=="")loc_st="&nbsp;";
    var loc_av = g.avenueText; if(loc_av=="")loc_av="&nbsp;";
    GarListHTML += "<td>" + loc_st + "</td><td>" + loc_av + "</td>"; //  align='center'
   
    // charge cell for S1
    if(!(parking_isMonthly || parking_isCase))
    {
    GarListHTML += "<td align='center'>&nbsp;</td>";
    
    }    
    
    
    
    // charge cell for Monthly and S2
    if(parking_isMonthly || parking_isCase)
    { /////////// cases when rates displayed. calculates grades (for now disabled)
     
      var charge = g.tempCharge;
     
      var iconFile = ""; //image for icon on the map
      var iconColor = "";// color for the icon
      var iconCont = ""; // text for the icon 
      

     if(charge != null && charge >= 0)
     {
     
     var gradientStyles = "";
      ///  Gradient feature
     if(useRatesGradient)
     { 
      var value = Math.max(0,Math.min(1, 0.5 - ( charge - (lowestCharge+highestCharge)/2 ) / ( (lowestCharge+highestCharge)/2 ) ));
      gradientStyles = "color: #ffffff; background-color:rgb(192," + Math.floor(192*value) + ",0);";
       
      
        var imgRank = Math.floor(value*6.99);
        if(g.tempCharge == cheapestGarCharge)
          imgRank = 7;  
       
     }
      
      var fmtCharge = fmtCurrency(charge);
      
      GarListHTML += 
        "<td align='center' style='font-weight:bold;" + gradientStyles + "'>" + fmtCharge + "</td>";
      }
      else if(parking_isMonthly && charge == -11)  // 'Get Deal'
      {
      gradientStyles = "color: #000000; background-color:rgb(210,210,0);";
      
      if(TABLE_HIGH_RG)
      GarListHTML += "<td align='center' style='font-weight:bold;'>GET DEAL</td>";
      else
      GarListHTML += "<td align='center' style='font-weight:bold;" + gradientStyles + "'>GET DEAL</td>";
      
      //icon text
      iconCont = "<span class='iconpad2'>Get</span><span class='iconpad3'>Deal</span>";       

      if(ICON_MONTH_P2_GREEN)
      iconFile = ICON_IMG_R;
      else
      iconFile = PATH_IMG + "images/marker_garage_7.gif";
      
      iconColor = "black";       
      
      }      
      else if(parking_isMonthly && charge == -1)  // N/P
      {
      
      GarListHTML += "<td align='center'>NOT POSTED</td>";
      //icon text
      iconCont = "<span class='iconpad'></span><span></span>N/P";       
       
       // image and color for incon on the map
       if(!parking_isMonthly && g.green == 1) 
       {iconFile = ICON_IMG_RG;iconColor = "black";}
       else if(!parking_isMonthly && g.green == 2)
       {iconFile = ICON_IMG_R;iconColor = "black";}        
       else if(parking_isMonthly)
       {
       /* if(ICON_MONTH_P2_GREEN && g.partner2)
        {iconFile = ICON_IMG_RG; iconColor = "black";}
        else
        { */
        iconFile = PATH_IMG + "images/marker_garage_na.gif";iconColor = ICON_COLOR_NA;
       }       
       else
       {iconFile = PATH_IMG + "images/marker_garage_na.gif";iconColor = ICON_COLOR_NA;}      
      
      }
      else     // N/A
      {
      GarListHTML += "<td align='center'>N/A</td>";
      
      iconCont = "<span class='iconpad'></span><span></span>N/A";       
       
       // image and color for incon on the map
       if(!parking_isMonthly && g.green == 1) 
        {iconFile = ICON_IMG_RG;iconColor = "black";}
       else if(!parking_isMonthly && g.green == 2)
       {iconFile = ICON_IMG_R;iconColor = "black";}        
       else if(parking_isMonthly)
       {
       /* if(ICON_MONTH_P2_GREEN && g.partner2)
        {iconFile = ICON_IMG_RG; iconColor = "black";}
        else */
        iconFile = PATH_IMG + "images/marker_garage_na.gif";iconColor = ICON_COLOR_NA;
       }      
       else
       {iconFile = PATH_IMG + "images/marker_garage_na.gif";iconColor = ICON_COLOR_NA;}      
      
      }
     
     
       // set map icon (only for non All Manhattan
       if(!numManh)
        {
        
        if(charge != null && charge >= 0)
        {
        
        fmtCharge = fmtCharge.replace(/\..{1,2}$/, ""); // for gar icon (Central)
        
        fmtCharge = fmtCharge.replace(".","<wbr>.");
        
        if(g.green > 0 || parking_isMonthly)
        var loc_color = 'black';
        else
        var loc_color = 'white';  //  style='color:" + loc_color + "'
        
        //  
        if(fmtCharge.substring(1).length > 3)   // color:black (2 places) rates_away
        fmtCharge = "<span" + ICON_$_STYLE + ">$<br></span>" + fmtCharge.substring(1);
        else
        fmtCharge = "<span class='iconpad' ></span><span" + ICON_$_STYLE + ">$</span>" + fmtCharge.substring(1);

        iconCont = fmtCharge; // icon text      
        // icon image, color
        if(!parking_isMonthly && g.green == 1 && ICON_HIGH) 
        {iconFile = ICON_IMG_RG;iconColor = "black";}
        else if(!parking_isMonthly && g.green == 2 && ICON_HIGH)
        {iconFile = ICON_IMG_R;iconColor = "black";}
        else if(parking_isMonthly)
        {
             if(ICON_MONTH_P2_GREEN && g.partner2)
             {iconFile = ICON_IMG_R; iconColor = "black";} /*marker_garage_7.gif*/
             else
             {iconFile = PATH_IMG +"images/marker_garage_na.gif"; iconColor = ICON_COLOR_MO;}
        }          
        else
        {iconFile = PATH_IMG +"images/marker_garage_na.gif";iconColor = ICON_COLOR_PLAIN;}
         
        }
        
        if(!ICON_HIGH && charge != -11) {iconFile = PATH_IMG +"images/marker_garage_s2.gif";iconColor = "white";}
        
        // set icons on the map
        for(var n=0; n<g.entrances.length; n++)
        {
          if(
          useRatesGradient && charge >= 0 && (g.green==0 || parking_isMonthly)
          )// Gradient feature
          {
          iconColor = "white";                                                       
          if (imgRank==7)
          iconColor = "black";
          
          if(parking_isMonthly && g.blckTxt)
          iconColor = "black";
          
          g.entrances[n].garageLabel.setImage(PATH_IMG + "images/marker_garage_" + imgRank + ".gif", iconColor);
          }
          else
        g.entrances[n].garageLabel.setImage(iconFile, iconColor);
        
      
        g.entrances[n].garageLabel.setHTML(iconCont);
        }
        
        
     }
        
    } 
    else  // NOT (parking_isMonthly || parking_isCase)
    {  // last cell is not added, only map icons set
    
      if(!numManh)
      {//numManh 
          for(var n=0; n<g.entrances.length; n++)
          {
            
            if(g.green == 1 && ICON_HIGH)         
            g.entrances[n].garageLabel.setImage(ICON_IMG_RG_S1, "black");
            else if(g.green == 2 && ICON_HIGH)
            g.entrances[n].garageLabel.setImage(ICON_IMG_R_S1, "black");
            else  
            g.entrances[n].garageLabel.setImage(ICON_IMG_PLAIN, "blue"); 
            
            g.entrances[n].garageLabel.clearHTML();
          } 
       }
      
    } // end last (charge) cell
    
    
    if(!numManh)
    { // 'R' icons are above 'RG' and they are above all other on map
    if(g.green == 1)
    g.entrances[0].garageLabel.layer.style.zIndex = 3;
    else if(g.green == 2)
    g.entrances[0].garageLabel.layer.style.zIndex = 4;
    }
    
    
    GarListHTML += "</tr>";
  } // END through listedGarages

  GarListHTML += "</table>";
  
  
  if(lastSelectedGarage)
  {
          // set icon for selected garage  
          for(var n=0; n<lastSelectedGarage.entrances.length; n++)
          {
            if(lastSelectedGarage.entrances[n].garageLabel != null)
              lastSelectedGarage.entrances[n].garageLabel.setTempImage(PATH_IMG + "images/marker_selected21.gif", "white");
              
              lastSelectedGarage.entrances[n].garageLabel.layer.style.zIndex = 5;
          }
  }
  
  
  
  // set result table contents
  if(document.getElementById("garage_list"))
  document.getElementById("garage_list").innerHTML = GarListHTML;
  DisplayElem("garage_list_div", "block");
  
   
  if(parking_isCase && typeof(HideCalcHelp)=='function')
  CalcHelpTimer = window.setTimeout("HideCalcHelp()", 5000);  
  
 /* if(!parking_isMonthly && !parking_isCase)
  {
  DisplayElem("charge_float", "block"); 
  SetChargeFloatPos();
  }*/  
   
  // No Parking Facilities ...
  if(listedGarages.length==0)
  {
 /* DisplayElem("charge_float", "none"); */ 
  if(CurrentError == 0)
  DisplayElem("no_result", "visible");
  }
  
   
     /// display Monthly Spec window // ExpWin
     if(typeof(DisplayMonSpec)=="function")
     if(!numManh)DisplayMonSpec();  
  
     /// Weekly ExpWin
     if(typeof(DisplayWeekExpWins)=="function")
     DisplayWeekExpWins();

     /// Daily ExpWin
     if(typeof(DisplayDailyExpWins)=="function")
     DisplayDailyExpWins();
     
     if(typeof(MaximizeCurrentExpWin)=="function")
     MaximizeCurrentExpWin();
     
  
if(globJSBrowser != "Safari")
{  
if(numManh) document.getElementsByName("#level2")[0].scrollIntoView();
}

  DisplayElem("list_detail_label", "none");
  DisplayElem("map_pop", "hidden");

// garage View: show popup
if(typeof(garageViewLic)!= 'undefined')
{
if(garageViewLic != 0){
try{
garages[garageViewLic].entrances[0].onMouseOver();
garages[garageViewLic].select(true);

if(globJSBrowser != "Safari")
document.getElementById("map_green_detail_label").scrollIntoView(false);

}catch(e) {alert("error" + "\n" + e.description );jserror(8, garageViewLic  + " " + e.number + " " + e.description);}  //+ "\n" + e.description
garageViewLic = 0;
}
}

  // get today date
  var todayDate = new Date();
  
  strTodayDate = String("0" + (todayDate.getMonth()+1)).slice(-2) + 
                  "/" +  String("0" + todayDate.getDate()).slice(-2) +
                  "/" +  String(todayDate.getFullYear()).slice(-2);

  // TIMER
  var PerformEnd = new Date();

   window.status = "TIME: PHP: " + PerfPHPTime + 
   "; Total: " + ((PerformEnd.valueOf() - PerformTimer.valueOf())/1000 );
   PerfPHPTime = 0;


}  // END listGarages

////     SortGarages
function SortGarages(listedGarages)
{ // 
  
  //alert("SortGarages");
  
  // SORT list South to North or by Rate
      
  if(sort_results == SORT_RATE)
    listedGarages = listedGarages.sort(
      function (g1, g2)
      {
        var g1Value = g1.tempCharge;
        var g2Value = g2.tempCharge;
        if(g1Value == null)
          g1Value = 9999992; 
        else if(g1Value == -1) // N/P
          g1Value = 9999991;        
        else if(((g1Value <= 0) && (g1Value > - 10))||  g1Value == "undefined")
	          g1Value = 9999992; // negative it to the end, except for those that < -10 ('Get Deal')
        
        if(g2Value == null)
          g2Value = 9999992;  
        else if(g2Value == -1) // N/P
          g2Value = 9999991; 
        else if(((g2Value <= 0) && (g2Value > - 10))||  g2Value == "undefined")
	          g2Value = 9999992;
          
        if(g1Value == g2Value)return compareStreets(g1, g2);
        return g1Value - g2Value;
      });
  else if(sort_results == SORT_STREET)  // from South to North
    listedGarages = listedGarages.sort(
      function (g1, g2)
      {
      return compareStreets(g1, g2);
      });
  else if(sort_results == SORT_AVENUE)  // from East to West
    listedGarages = listedGarages.sort(
      function (g1, g2)
      {
      return compareAvenues(g1, g2);
      });
  else if(sort_results == SORT_NAME)  // ascending alphabetical
    listedGarages = listedGarages.sort(
      function (g1, g2)
      {
        var str1 = g1.company;
        if(str1 == "" )str1 = g1.name;
      
        var str2 = g2.company;
        if(str2 == "" )str2 = g2.name;
        
        if(str1 == str2)return compareStreets(g1, g2);
        return ( (str1 == str2) ? 0 : ((str1 > str2)?1:-1) );
      });

return listedGarages;
}


////     HideAllGarages
function HideAllGarages()
{ // to hide all garages icon before new search
  
  if(lastSelectedGarage != null)
   lastSelectedGarage.deselect();
  lastSelectedGarage = null;
   
  for(var id in garages)
  {
      
    var g = garages[id];
    if(!g.entrances)continue;
    for(var n=0; n<g.entrances.length; n++)
      {
      var curr_entr = g.entrances[n];
      g.entrances[n].requireDisplay(0);// hide garage
     } 
      
  }  
}



/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 C L A S S E S   functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
////     CaseResult
function CaseResult(charge, comments, SUVperirp, charges, arrCompCoupon)
{
  this.charge = charge;
  this.comments = comments;
  this.SUVperirp = SUVperirp;
  this.charges = charges;
  this.arrCompCoupon = arrCompCoupon; 
}

/* *********************
     Entrance
********************* */
function Entrance(garage, latLng)
{ /// subclass of Garage class
  /// object contains data and functions for displaying as icons on the map.
// It was originally implemented that any garage can have more that one entrance
// Currently only single the 1st one entrance is in use.

  this.garage = garage; // parent garage
  this.latLng = latLng;
  this.garageLabel = null;
  this.showingMapDetailLabel = false;

  //// Entrance::onClick
  this.onClick =
    function()
    { // clcikimg garage icon on the map
      this.garage.select(true);
      
      // Exp Wins
      if(typeof(setWindowHeight)=="function")setWindowHeight(this.garage, "clickopen");
      
      var month_day = parking_isMonthly?"monthly":"daily";
      SendTracker('/' + month_day +'/iconclick');
    }
  //// Entrance::onMouseOver
  this.onMouseOver =
    function()
    {  // mouse move over garage icon on the map
      
      //if(this.garage.licenceNumber==429204)alert("onMouseOver " + this.garage.licenceNumber);
      
      HideMapDetailLabel(this.garage); // hide for last gar

      // if dialog open for this green gar
      if(lastSelectedGarage == this.garage && 
      document.getElementById("map_green_detail_label").style.display == "block")
      return;
      
      if(!this.showingMapDetailLabel)
      {
        if(this.garage.green > 0 && !parking_isMonthly)
        document.getElementById("map_detail_label_top").style.width = "492px";// green
        else
        document.getElementById("map_detail_label_top").style.width = "492px"; // 422px plain
        
        this.showingMapDetailLabel = true;
        var mapDetailLabel = document.getElementById("map_detail_label");
        // get contain
       this.garage.setDetailHTML("map_detail_label", false, 1);
       DisplayElem("map_detail_label", "block");
        
        // position
        yPos = moveDetailLabelToLatLng(mapDetailLabel, this);
        //mapDetailLabel.style.visibility = "visible"; // show  
        
      // Exp Wins
      if(typeof(setWindowHeight)=="function")setWindowHeight(this.garage, "overopen");
        
       }
       
      if(this.garageLabel != null && lastSelectedGarage != this.garage)
        this.garageLabel.layer.style.zIndex = 6; // the icon goes in front
    };
  
  //// Entrance::onMouseOut  
  this.onMouseOut =
    function()
    {  // mouse move from garage map icon
      //if(this.garage.licenceNumber==429204)alert("onMouseOut " + this.garage.licenceNumber);
      
      // hiding is delayed
      MapDetailLabelGarage = this;
      timerMapDetailLabel = window.setTimeout("HideMapDetailLabel()", 50);
    
        // take away from front to usual place (for plain, RG or R garage)
      if(this.garageLabel != null && lastSelectedGarage != this.garage)
         {
         this.garageLabel.layer.style.zIndex = 1;
         //if(this.garage == cheapestGarage)this.garageLabel.layer.style.zIndex = 2;
        
         /*// few cheapest fix
         if(this.garage.tempCharge == cheapestGarCharge)
         this.garageLabel.layer.style.zIndex = 2;
         */
         if(this.garage.green == 1)this.garageLabel.layer.style.zIndex = 3;
         else if(this.garage.green == 2)this.garageLabel.layer.style.zIndex = 4;
         
         }
        
     };
   //// Entrance::requireDisplay
   this.requireDisplay =
    function(isRequired, mapOther)
    {  // display (isRequired = true) or hide (isRequired = true)
       // garage icon on the map
       // mapOther - is set, that means that icon to be displayed in 'All Manh' popup map
     
      //if(isRequired && (this.garageLabel == null || this.garage.baseGreen))
      if(isRequired && (this.garageLabel == null || this.garage.baseGreen || 
      (ICON_MONTH_P2_GREEN && this.garage.partner2) ))
      {
        
        if(this.garage.baseGreen && this.garageLabel && !mapOther)
        {// the problem that green garages icon should be re-created because of borders
        gMap.removeTLabel(this.garageLabel);
        }
        
        this.garageLabel = new TLabel();
        this.garageLabel.id = "label_garage_" + garage.licenceNumber;
        this.garageLabel.anchorLatLng = this.latLng;
        
        if(mapOther)
        mapOther.addTLabel(this.garageLabel); // 'All Manh' popup map
        else
        gMap.addTLabel(this.garageLabel); // main map
        
        this.garageLabel.layer.className = "garagelbl";
        this.garageLabel.icondiv = null;
        
        // for green garage in Daily
        //if((this.garage.green == 1 || this.garage.green == 2) && !parking_isMonthly) 
        
        // for green garage in Daily // partner in Monthly
        if(((this.garage.green == 1 || this.garage.green == 2) && !parking_isMonthly && ICON_HIGH)
        || 
        (parking_isMonthly && ICON_MONTH_P2_GREEN && this.garage.partner2
        && (this.garage.tempCharge > 0 || this.garage.tempCharge==-11 ) )
        ) 
        {
        
        var size = 31; // to hold borders
       
       /* if(this.garage.green == 1)*/
         this.garageLabel.layer.className = "borderbl"; // black borders
       /* else if(this.garage.green == 2)
         this.garageLabel.layer.className = "bordertr"; */
        
        this.garageLabel.layer.style.width = 
        this.garageLabel.layer.style.height = size + "px";
        
        // to draw boders, black DIV of 31x31 with black icon as background
        // contains other DIV with green(turquois) icon 
        var icon_div = document.createElement('div');
        icon_div.className = "icon";
        this.garageLabel.layer.appendChild(icon_div);
        
        icon_div.style.width = 
        icon_div.style.height = size + "px";
        
        this.garageLabel.icondiv =  icon_div;
        
        this.garageLabel.w = this.garageLabel.h = size;
        
             if(parking_isMonthly) // Partner 2 case
             {
             this.garageLabel.green = this.garage.partner2;
             this.garageLabel.setImage(ICON_IMG_RG, "black");
             }
             else
             {
             this.garageLabel.green = this.garage.green;
             if(this.garage.green == 1)         
             this.garageLabel.setImage(ICON_IMG_RG, "black");
             else if(this.garage.green == 2)
             this.garageLabel.setImage(ICON_IMG_R, "black");
             }
        
        }
        else // plain gar icon
        this.garageLabel.setImage(PATH_IMG + "images/marker_garage.gif", "blue");
        
        
                
        this.garageLabel.layer.entrance = this;
        this.garageLabel.layer.onmouseover = function(){ this.entrance.onMouseOver(); };
        this.garageLabel.layer.onmouseout = function(){ this.entrance.onMouseOut(); };
        this.garageLabel.layer.onclick = function(){ this.entrance.onClick(); };
      }
      
      // remove garage icon
      if(!isRequired && this.garageLabel != null &&
         this.garage != lastSelectedGarage && this.garageLabel)
      {
        if(mapOther)
        mapOther.removeTLabel(this.garageLabel);
        else
        gMap.removeTLabel(this.garageLabel);
        
        this.garageLabel = null;
      }
    };
}

/* *********************
     Garage
********************* */
function Garage()
{
  this.licenceNumber = null;  // Unique garage licence number
  this.company = null;
  this.name = null;
  this.openingHours = null;
  this.capacity = null;
  this.phone = null;
  this.phoneday = null;
  this.entranceNotes = null;
  
  this.partner2 = 0; // partners : list 2 - used for Get Deal form

  this.addressHTML = null;    // concatenation of entrances' descriptions
  this.streetText = null;     // of primary entrance (used for sorting)
  this.avenueText = null;     // of primary entrance (used for sorting)

  this.noDPS = false;
  this.dailyComments = null;
  this.monthlyComments = null;
  
  this.dailyTopAttr = null;
  this.monthlyTopAttr = null;
  this.dailyEventAttr = null;

  this.entrances = new Array();    // An array of Entrance objects
  this.primaryEntrance = null   // The first street address

  //this.cacheDetailHTML = null;

  this.monthlyRates = new Array(); // monthly rates with applyed Manhattan tax
  this.monthlyRatesNM = new Array(); // with Non-Manhattan tax
  
  this.caseCharges = new Array();
  this.dailyLoaded = 0;
  this.strSUV = "$0.00"; // default

  // for green garages , keeps excluded dates, space devided, in format "(M)M-(D)D" 
  // months are in JavaScript style
  this.exclDates = ""; 
  
  // keeps whether the garage is from Monthly Specs and if so value is monthly spec id 
  this.monspec = null;
  
  this.contact = null; // last contact date 

// this.green
   // green is other name (older) for 'RG' (Rate Guarantee) and 'R'(Reservation)
   // garages green == 1 if the garage is 'RG' and green == 2 if 'R'
  
  
  this.arrAllSpecNew = new Array();
  // arrAllSpec is 2-dimensional array that contains all specalls of the garage:
  // arrAllSpec[<day of week>][< n - just index >] = Array(specStr, id, carr, clarr, cdep, stay)
  
  this.arrAllCoupNew = new Array();
  // quite analogy to arrAllSpec, but for Coupons  
  
  this.spclsLoaded = 0; // 0 - not loaded ; 1 - loaded; -1 - is loading
  
  this.arrSpecialsMonth = new Array();
  // arrSpecialsMonth multi-dimensional array;
  // index of the array is certain month designation in format "20079" 
  //( September 2007)
  // arrSpecialsMonth[<month>][0] contains info on whether particular day contains specials 
  //(in this case to be enabled in the popup calendar) or doesn't do any 
  //(to be disabled)the meaning is line of "1" of "0" for each day of the month. 1 - enable ; 0 - disable
  // arrSpecialsMonth[<month>][1][<day>] contains exclusions for particular <month>
  // and particular <day> of month, format is string of specs(coups) ids devided by " "
  
  this.arrCouponsMonth = new Array(); 
  // analog of arrSpecialsMonth for coupons
   
  //this.specMonthLoaded = 0; // 0 - not loaded ; -1 - is loading

  // -1 if Not Posted; -2 or null if N/A
  //// Garage::getMonthlyRate
  this.getMonthlyRate =
    function(veh, bManh)
    { 
      if(bManh)
      return this.monthlyRates[veh]; //Non-Manhattan tax applyed
      else
      return this.monthlyRatesNM[veh];
    };
  //// Garage::setMonthlyRate
  this.setMonthlyRate =
    function(veh, rates)
    { 
      this.monthlyRates[veh] = parseFloat(rates[0]);
      
      if(!rates[1])
      this.monthlyRatesNM[veh] = parseFloat(rates[0]);
      else
      this.monthlyRatesNM[veh] = parseFloat(rates[1]);
      
    };
  //// Garage::hasCaseResult  
  this.hasCaseResult = 
    function(arr, dep, veh)
    {
      return (this.caseCharges["" + getGMTTime(arr) + "-" + getGMTTime(dep) + "/" + veh] != null);
    };
    
  // < 0 if N/A
  //// Garage::getCaseResult
  this.getCaseResult = 
    function(arr, dep, veh)
    {
      return this.caseCharges["" + getGMTTime(arr) + "-" + getGMTTime(dep) + "/" + veh];
    };
  //// Garage::addCaseResult
  this.addCaseResult = 
    function(arrGMT, depGMT, veh, charge, comments, SUVperirp, charges, arrCompCoupon)
    {
      this.caseCharges["" + arrGMT.getTime() + "-" + depGMT.getTime() + "/" + veh] = new CaseResult(charge, comments, SUVperirp, charges, arrCompCoupon);
    };
  //// Garage::select
  this.select =
    function(isMap)
    { // garage map icon clicked (isMap=true) or result list link(isMap=false)
    
     /* if(!isMap){ // select popup on the map
      this.primaryEntrance.onMouseOver();
      this.select(true); return;
      } */
       
      //alert("select " + this.licenceNumber); 
            
      // clear previous green popup
      HideGreenDetails();
      
      currSpclsDate = currRequestDate;

      // display Green detail popup

      var entr0 = this.entrances[0];
      
         if(this.green > 0 && !parking_isMonthly) // green
         var loc_pop_width = 492; /*510*/
         else // plain
         var loc_pop_width = 492; /* 422 440*/

         // popup on the result list
         if(document.getElementById("list_detail_label"))
         document.getElementById("list_detail_label_top").style.width = loc_pop_width + "px";
       
        
        if(isMap)
        {
        
        // popup on the map
        document.getElementById("map_green_detail_label_top").style.width = loc_pop_width + "px";
        
        var mapDetailLabel = document.getElementById("map_green_detail_label");
        
        // get HTML contains 
        this.setDetailHTML("map_green_detail_label", true, 2);
        
        // the Green detail popup is positioned by just detail popup,
        // as it opened always after it and in the same location
        mapDetailLabel.style.left = 
        document.getElementById("map_detail_label").style.left;
        mapDetailLabel.style.top = 
        document.getElementById("map_detail_label").style.top;        
        
        
        DisplayElem("map_green_detail_label", "block");
        entr0.showingMapDetailLabel = true;
        DisplayElem("list_detail_label", "none");
        DisplayElem("map_detail_label", "none");
        }
        else
        {
        DisplayElem("map_green_detail_label", "none");
        entr0.showingMapDetailLabel = false;
        DisplayElem("list_detail_label", "block");
        }
        
        HideMapDetailLabel(this); 
       
        

       // end Map detail lable    
         
      // display list detail popup
     
      
      if(lastSelectedGarage != this)
      {
          if(lastSelectedGarage != null)
            lastSelectedGarage.deselect();
           
          // set icon for selected garage  
          for(var n=0; n<this.entrances.length; n++)
          {
            if(this.entrances[n].garageLabel != null)
              this.entrances[n].garageLabel.setTempImage(PATH_IMG + "images/marker_selected21.gif", "white");
              
              this.entrances[n].garageLabel.layer.style.zIndex = 5;
          } 
          
      }
      
      // display list detail popup
      var link = document.getElementById("garage_link_" + this.licenceNumber);
      // link is one in the garage row in result list
      
      if(link)
      {
        link.className = "selectedGarageName";
        
       if(!isMap) // display list popup (only if list clicked)
       { 
        var listDetailLabel = document.getElementById("list_detail_label");
        // get HTML 
        this.setDetailHTML("list_detail_label", true, 3);
        listDetailLabel.style.display = "block";
        
        // position below the link
        var absPos = getAbsolutePositionOf(link);
        listDetailLabel.style.left = absPos[0] + 50;
        listDetailLabel.style.top = absPos[1] + 5;
        
        
        // the popup map also displayed below the list detail popup
        
        document.getElementById("map_pop").style.top = 
        parseInt(listDetailLabel.style.top) + parseInt(listDetailLabel.offsetHeight) + 2;
        
        document.getElementById("map_pop").style.left =
        listDetailLabel.style.left; 
        
        var loc_pop_width2 = GetElement("list_detail_label").offsetWidth;
        
        if(globJSBrowser=="IE")loc_pop_width2 += 0; else loc_pop_width2 -= 4;
        document.getElementById("map_pop").style.width = loc_pop_width2 + "px";
        
        document.getElementById("map_pop").style.visibility = "visible";
        
      /* if(globJSBrowser != "Safari")
        document.getElementById("map_pop").scrollIntoView(false); */

       // move the popup map to location of the garage
       var latLng = this.primaryEntrance.latLng;
       
       InitPopMap();
       gPopMap.setCenter(latLng, defaultPointZoom);
       
       // display icon on the popup map 
       if(popMapIcon!=null)
       gPopMap.removeTLabel(popMapIcon);
       
       // create and add garage icon to the map 
       popMapIcon = AddGarageIcon(gPopMap, this, "pop_icon");
       
       } // END display list popup
      }
      
      lastSelectedGarage = this;
      
     /* if(this.green > 0)
      GetGarageSpecials(this, 3, "current"); */
      
    };
    
    //// Garage::select_no_map
    this.select_no_map  = function(isMap)
    {// 'All Manh' result list link clicked (isMap always false)
    
      var link = document.getElementById("garage_link_" + this.licenceNumber);
      // link is one in the garage row in result list
      if(link)
      {
        link.className = "selectedGarageName";
        var listDetailLabel = document.getElementById("list_detail_label");
        listDetailLabel.style.display = "none"; // hide previous
        // get HTML contains
        this.setDetailHTML("list_detail_label", true, 3);
        
        // position list popup
        var absPos = getAbsolutePositionOf(link);
        listDetailLabel.style.left = absPos[0] + 50;
        listDetailLabel.style.top = absPos[1] + 5;
        listDetailLabel.style.width = "420px";
        listDetailLabel.style.display = "block";
        
        // For 'All Manh', the popup map also displayed below the detail popup
        
        document.getElementById("map_pop").style.top = 
        parseInt(listDetailLabel.style.top) + parseInt(listDetailLabel.offsetHeight) + 2;
        
        document.getElementById("map_pop").style.left =
        listDetailLabel.style.left; 
        
        document.getElementById("map_pop").style.width = "414px";
        
        document.getElementById("map_pop").style.visibility = "visible";
        
       if(globJSBrowser != "Safari")
        document.getElementById("map_pop").scrollIntoView(false);

       // move the popup map to location of the garage
       var latLng = this.primaryEntrance.latLng;
       gPopMap.setCenter(latLng, defaultPointZoom);
       
       // display icon on the popup map 
       if(popMapIcon!=null)
       gPopMap.removeTLabel(popMapIcon);
       
       popMapIcon = new TLabel();
       popMapIcon.id = "pop_icon";
       popMapIcon.anchorLatLng = latLng;
       gPopMap.addTLabel(popMapIcon);
       popMapIcon.setImage(PATH_IMG + "images/marker_garage.gif", "blue");
 
      }
    
    
    }
     
  //// Garage::deselect
  this.deselect =
    function()
    { // deselect garage
    
      // take away select image in the map icon
      for(var n=0; n<this.entrances.length; n++)
      {
        if(this.entrances[n].garageLabel != null)
          this.entrances[n].garageLabel.clearTempImage();
      
      // set usual zIndex for map icon
      this.entrances[n].garageLabel.layer.style.zIndex = 1;

      /*// few cheapest fix
      if(this.tempCharge == cheapestGarCharge)
      this.entrances[n].garageLabel.layer.style.zIndex = 2;
      */
      
      if(this.green == 1)this.entrances[n].garageLabel.layer.style.zIndex = 3;
      else if(this.green == 2)this.entrances[n].garageLabel.layer.style.zIndex = 4;
    
      }
      // hide list detail popup 

      DisplayElem("list_detail_label", "none");

      var link = document.getElementById("garage_link_"+this.licenceNumber);
      if(link)
        link.className = "";
        
        
    };
  //// Garage::setDetailHTML
    this.setDetailHTML =
    function(idDetailLabel, isClick, place)
    { /// combines HTML contents for 3 kind of places
      // 
      // isClick - if true it's called by clicking (map icon or list link), 
      // otherwise by mouse moving over map icon
      
     // place: 1 - map_detail_label (garage detail map popup)
     //        2 - map_green_detail_label (green garage detail map popup)
     //        3 - list_detail_label (garage detail list popup)
      
      //if(this.licenceNumber==429204)alert("setDetailHTML " + this.licenceNumber);
      
      var detailHTML = "";
      
      //alert(idDetailLabel);
     
      var strTaxIncl = '<br><span class="txi"><nobr>(tax incl.)</nobr></span>';
     
      var flashTxt = "";
      
      if(parking_isMonthly)
      var chrg = this.getMonthlyRate(parking_vehicle);
      
      var bGetDealCase = false; // when charge == -11
      var bDisplayMonthForm = (this.partner2 && parking_isMonthly && chrg != -2 && chrg != 0 && chrg != null);
      
      var bDisplayMonthFormNonPartner = false;
      
      //alert(bDisplayMonthForm + "\n chrg" + chrg);
      
      if(MS_NONPARTNER_FORM && parking_isMonthly && !bDisplayMonthForm)
      {
      if(chrg != -2 && chrg != 0 && chrg != null)bDisplayMonthFormNonPartner = true;
      }
     
      if(typeof(OutputMonthlyForm)!="function"){bDisplayMonthForm = bDisplayMonthFormNonPartner = false;}
      
      
      // GREEN

       var loc_arrSpec = new Array(); // will take spec & coup to display
       var loc_arrCoup = new Array();
       
       // date string in "Your Search for ...", "SPECIALS Ofered ..."
       // and "COUPONS Offered ..." in S2
       var strDateSearch = arrDaysFull[currRequestDate.getDay()] + ", "
        +  arrMonths[currRequestDate.getMonth()] + " " + currRequestDate.getDate();

       
       if(this.green > 0 && !parking_isMonthly)
       { // RG & R garage
      
      
       if(isClick)
        tmpDateSpec = currSpclsDate; // date set by calendar
       else  // mousemove popup displays always current request date
        tmpDateSpec = currRequestDate; 
      
       var currWD = tmpDateSpec.getDay();
       
       // date string for "SPECIALS Ofered ..."
       // and "COUPONS Offered ..." in S1
       var strDateSpec = arrDaysFull[currWD] + ", "
        +  arrMonths[tmpDateSpec.getMonth()] + " " + tmpDateSpec.getDate();
       
       // get spec & coup to display (from tmpDateSpec)
       var indx = tmpDateSpec.getFullYear() + "" + tmpDateSpec.getMonth(); // format: "YYYMM"
       var day = tmpDateSpec.getDate();       
        
        if(this.arrAllSpecNew[currWD])loc_arrSpec = selectSpecsShow(this.arrAllSpecNew[currWD],"s" ,this, indx, day, 1);
        if(this.arrAllCoupNew[currWD])loc_arrCoup = selectSpecsShow(this.arrAllCoupNew[currWD],"c" ,this, indx, day, 1);
        // put into calendar input
        var dateCalendar = tmpDateSpec.getFullYear()  + "-" + tmpDateSpec.getMonth()  + "-" + tmpDateSpec.getDate(); 

        }
       
      ///// FLASHING TEXT ON THE TOP  : daily
           
      if(!parking_isMonthly)
        {
        
        var addStyle = "";
        
        if(!parking_isCase)flashTxt = "<u>Enter</u> ARRIVAL and DEPARTURE Times <u>Above Map</u> To CALCULATE RATES";
        
        // for S1 with spec or coup
        if(!parking_isCase && (loc_arrSpec.length > 0 || loc_arrCoup.length > 0))
        {
        flashTxt = "(1) <u>Enter</u> ARRIVAL and DEPARTURE Times <u>Above Map</u> To CALCULATE RATES, <u>or</u><br>";
        
        var article = "the";
        if((loc_arrSpec.length + loc_arrCoup.length) > 1)article = "a";
        
        var loc_Sp_Co = "a SPECIAL or COUPON";
        
        if(loc_arrCoup.length == 0)
          loc_Sp_Co = article + " SPECIAL";
        else if(loc_arrSpec.length == 0)
          loc_Sp_Co = article + " COUPON";        
        
        if(isClick)
        flashTxt += '(2) <u>Click</u> ' + article + ' "Get..." Button Below'; 
        else
        flashTxt += "(2) <u>Click</u> Garage Image on Map To Get " + loc_Sp_Co + " Below";
        
        addStyle = "text-align:left;";
        }
        
        // for S2
        if(parking_isCase && this.green > 0) //&& place!=3
        {
        var article = "the";
        if((loc_arrSpec.length + loc_arrCoup.length) > 0)article = "a";
        
        var strRRG = ' Rate';
        
        if(POP_S2_FLASH_TYPE==0){ // only for type 0 (NYC)
        if(this.green==1) strRRG = ' Rate Guarantee';
        if(this.green==2) strRRG = ' Reservation';
        if(this.green==2 && loc_arrCoup.length > 0) strRRG = ' Reservation or Rate Guarantee';
        }
        
        if(isClick)
        flashTxt = '<u>Click</u> ' + article + ' "Get..." Button Below or Run New Search';
        else
        flashTxt = '<u>Click</u> Garage Image on Map To Get ' + article + strRRG + ' Below';
        }
        
        ///   flash for Non-Partners
        if(POP_SEARCH_TYPE == 1 && parking_isCase && this.green == 0)
        {
        if(isClick)
        flashTxt = '<u>Click</u> the "Print..." Button Below or Run New Search';
        else
        flashTxt = '<u>Click</u> Garage Image on Map To Print Rate Summary';
        }
                
        }

         
        ///// FLASHING TEXT : monthly
      if(parking_isMonthly)
        {  
         var loc_app = 'Deals';
         if(POP_MO_MONTH_FRM) loc_app = 'Listed Rate(s)';

        if(bDisplayMonthForm)
        { //for partners
             if(isClick)
             flashTxt = '<u>Complete</u> Form Below To Get ' + loc_app;
             else
             flashTxt = '<u>Click</u> Garage Image on Map To Get ' + loc_app;
        }
        else if (bDisplayMonthFormNonPartner)
        { //for NOT-partners
             if(isClick)
             flashTxt = '<u>Complete</u> Form Below To Get Competitive Bids';
             else
             flashTxt = '<u>Click</u> Garage Image on Map To Get Competitive Bids';
        }
        
        } 
 
 
        // form flashing borders
        
        var inx = place;
        /*if(
        isClick && ((loc_arrSpec.length > 0 || loc_arrCoup.length > 0)
        || (parking_isCase) || parking_isMonthly)
        )inx =""; 
        */
        // if inx =="" flick DIV id will not meet format ("flick<NUMBER>")
        // in FlickText() function and the DIV will not be flicking
        
        var fntSize = 13; // 12
        if(!parking_isCase && (loc_arrSpec.length > 0 || loc_arrCoup.length > 0))
         fntSize = 12;
        if(parking_isMonthly)fntSize = 14;
        
        //if(this.green == 0 && !parking_isCase && !parking_isMonthly)fntSize = 11;

        //window.status = "fntSize " + fntSize;
        
        if(flashTxt != "") // add flashing text
        { 
        var loc_class = "flickon2";
        if(inx =="")loc_class = "flickon02"; // if not flicking, it has borders
        flashTxt = 
        "<center style='margin-bottom:4px;'><div id='flick" + inx + "' class='" + loc_class +
        "' style='font-size:" + fntSize + "px;" + addStyle + "'><b>" + flashTxt + "</b></div></center>";
        } 
 
     
      // insert flash text
      detailHTML += flashTxt;      
      
      
      ///// E N D  FLASHING TEXT ON THE TOP      
      
      if(!parking_isMonthly && parking_isCase)
      { // S2

      var caseRslt = this.caseCharges["" + getGMTTime(parking_arrival) + "-" + getGMTTime(parking_departure) + "/" + parking_vehicle];
      var loc_suvRerIrp = caseRslt.SUVperirp;

      }


       ///// G E N E R A L  garage INFO
       detailHTML += this.GetGeneralInfoHTML();

      
      //var GetRateStrAdd = ""; 
      
      var detailHTML_SS = ""; // for Search and Specials table 
      var detailHTML_SS2 = "";
     
      ///// COMMENTS (attributes)
      // Daily
      var detailHTML_Daily_Comm = "";
      var Daily_Comm_rates = false; // for tax included
      
      if(!parking_isMonthly && this.dailyComments != null)  
        {  // only S2
        
        // comments are in string consisting of 3 parts ( designating by "<br>$$<br>" )
        // 1st part is common comments, 2nd is for regular vehicle and 3rd is for SUV
        var arrComm = this.dailyComments.split("<br>$$<br>"); 
        
        if(arrComm[0] != undefined) strCommon = arrComm[0];
        
        if((parking_vehicle == 2) && arrComm[2] != undefined )
        { // SUV 
        detailHTML_Daily_Comm += '<div class="popattr">' + strCommon + arrComm[2] + '</div>';
        }
        else if(arrComm[1] != undefined)
        { // not SUV
        detailHTML_Daily_Comm += '<div class="popattr">' + strCommon  + arrComm[1] + '</div>';
        }
        
        Daily_Comm_rates = (detailHTML_Daily_Comm.indexOf('$')>-1);
        }     
        // end daily comm
     
     
//////// Tax / SUV line
   // TYPE 1 
   if(POP_SUVTAX_TYPE==1)
   {
       
       if(parking_vehicle == 2)
       var strSUV = "SUV/Oversize Vehicle Charge ("
       + this.strSUV +  ") Incl."; /*Included*/
       else
       var strSUV =  "Add " + this.strSUV + " for SUV/Oversize Vehicles";
     
       /// freeSUVspec
       if(this.freeSUVspec) strSUV =  "";     
       
       // if SUV and Per IRP
       if(parking_isCase && loc_suvRerIrp)
       var strSUV = "SUV/Oversize Vehicle Charge ($"
       + loc_suvRerIrp +  ") Incl.";  /*Included*/
     
      var strTax = DTax + "% Tax Incl. ";                                                                                                                          
     
      var strTaxSUV = "<div class='dotted_blue_dark' style='margin-top:3px;'></div><div class='gentax' style='/*margin-bottom:4px;margin-top:4px;*/'>" + strTax; /*Included*/
      if(strSUV != "") strTaxSUV += " - " + strSUV; 
      strTaxSUV += "</div>";
      
      if(CITY_NAME == "New York" && this.licenceNumber==99999964)
      strTaxSUV = "<div class='dotted_blue_dark' style='margin-top:3px;'></div><div class='gentax' style='/*margin-bottom:4px;margin-top:4px;*/'>Tax Included";
      
      
   }
   // TYPE 2
   if(POP_SUVTAX_TYPE==2)
   {      
       var strTaxSUV = "";
       
       strTaxSUV += "<div class='dotted_blue_dark' style='margin-top:3px;'></div>";
       
       strTaxSUV += "<div class='gentax'><b>" + DTax + "% Tax Included</b></div>";
       
       if(parking_vehicle == VEHICLE_SUV && !parking_isMonthly && caseRslt.charge > 0)
        strTaxSUV += "<span class='gentax' style='margin-bottom:6px;'>SUV/Oversize Vehicle Charge Included</span>";
      
   }
   // TYPE 3 
   if(POP_SUVTAX_TYPE==3)
   { 
    if(this.strSUV.indexOf("$0")==-1) // default
    {  
    if(parking_vehicle == 2)
       var strSUV = "SUV/Oversize Vehicle Charge ("
       + this.strSUV +  ") Included";
       else
       var strSUV =  "Add " + this.strSUV + " for SUV/Oversize Vehicles";
     
       // if SUV and Per IRP
       if(parking_isCase && loc_suvRerIrp)
       var strSUV = "SUV/Oversize Vehicle Charge ($"
       + loc_suvRerIrp +  ") Included";   
      
      var strTaxSUV = "<div class='dotted_blue_dark' style='margin-top:3px;'></div>";
      
      strTaxSUV += "<div  class='gentax'>" + strSUV  + "</div>";
    }  
    else
     var strTaxSUV = "<div style='height:5px;font-size:1px'>&nbsp;</div>";
   }   
   // TYPE 4
   if(POP_SUVTAX_TYPE==4)// airports
   {
   var strTaxSUV = "";
   
   var strSUV = ""; 
   if(this.suvType == 4 && this.strSUV != "") // absolute type
   strSUV = " - SUV/Oversize Vehicle Charge = Flat " + this.strSUV;
   
   strTaxSUV += "<div class='dotted_blue_dark' style='margin-top:3px;'></div>";
   strTaxSUV += "<div class='gentax'>Tax Included" + strSUV + "</div>";
   
   }
//////// END Tax / SUV line     
     
     var bTaxSuvAdded = false;
     
     if(Daily_Comm_rates)
     {detailHTML_SS2 += strTaxSUV; bTaxSuvAdded = true;}

     //// padding for Search, Spec, Coup area 
     var spec_pad_all = 5;
     var spec_pad_last = ""; // for Coupon button TD
     //var spec_add_td = ""; // add to head of Search, Coup
     
     if(POP_SPEC_FULL){spec_pad_all = 6;
          spec_pad_last = " colspan='2' ";}

     var dividing_band = '<tr style="height:10px;font-size:1px;"><td></td><td style="padding:0" colspan="' + spec_pad_all + '">&nbsp;</td><td></td></tr>';


     if(!parking_isMonthly && parking_isCase && 
     POP_SUVTAX_TYPE==2 && caseRslt.charge < 0 && !bTaxSuvAdded)
     { detailHTML_SS2 += "<br>"; bTaxSuvAdded = true;} // not display tax/suv for N/A (S2, type 2) 
      
     
     // Your  S E A R C H   S1
     if(!parking_isMonthly && !parking_isCase)
     {      
     
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';       

       detailHTML_SS += 
       '<tr class="titlesrch"><td></td><td colspan="' + spec_pad_all + '">Your Search</td><td></td></tr>';
       
      detailHTML_SS +=  '<tr class="srch"><td></td><td colspan="' + spec_pad_all + '">'
      detailHTML_SS +=  '<center><span style="color:#fd1310;font-size:18px;"><center><b>Enter ARRIVAL and DEPARTURE Times<br>';
      detailHTML_SS +=  '<u>Above Map</u> To CALCULATE RATES</b></center></span></center>';
      detailHTML_SS +=  '<td></td></tr>';
       
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';        
      
      detailHTML_SS += dividing_band;
     
     }
     
     // Your  S E A R C H   output - yellow backgrnd
     
     if(!parking_isMonthly && parking_isCase)
        { // S2

     if(!bTaxSuvAdded)
     {detailHTML_SS2 += strTaxSUV; bTaxSuvAdded = true;}

      // 'Get RG/R' system: add 'Get RG/R' button
                          
      if(this.green == 1)
      var loc_Btn = 'Get Free RATE GUARANTEE'; // &#13;&#10;
      else if(this.green == 2)
      var loc_Btn = 'Get Free RESERVATION';
      else
      var loc_Btn = 'Print This Rate Summary'; 
     
if(POP_SEARCH_TYPE == 1)
{ 

     var GetRateStr = '<table class="btn_get_free_rrg plain" cellspacing="0" ' +
                      'onClick="OpenGetGuarantee(-1, ' + this.licenceNumber + ', \'\');">' +
                      '<tr><td>' + loc_Btn + '</td></tr></table>';      
     
}
          
     
     if(POP_SEARCH_TYPE == 2)
     { // no grid, the button is in one line

      
     var GetRateStr = '<table class="btn_get_free_rrg plain" cellspacing="0" ' +
                      'onClick="OpenGetGuarantee(-1, ' + this.licenceNumber + ', \'\');">' +
                      '<tr><td>' + loc_Btn + '</td></tr></table>';       
      
      if(this.green == 0)GetRateStr = '';      
     }
      
     //   Non partner text 
     
     var loc_indx = (parseInt(place) + 6);
     var loc_class = "flickon7";
      
     if(!isClick){ loc_indx = "00"; loc_class = "flickoff7"; }
    
     var loc_com_name = this.company.toUpperCase();
     if(loc_com_name == "")loc_com_name = 'This Facility';
     

   if(GREEN){
     
     var not_partner_txt1 = 
     '<center><table class="plain" cellspacing="0"><tr><td>' +
     'Select a&nbsp;' +
     '</td><td><img src="' + ICON_IMG_RG_SMALL + '" style="border:1px solid #000; background:#000;">';
     
     if(GREEN_R)
     not_partner_txt1 +='</td><td>&nbsp;or&nbsp;' +
     '</td><td><img src="' + ICON_IMG_R_SMALL + '" style="border:1px solid #000; background:#000;">';
     
     not_partner_txt1 +='</td><td>&nbsp;Garage ';
     
     if(GREEN_R)
     not_partner_txt1 +='To Get a Rate Guarantee or Reservation';
     else
     not_partner_txt1 +='To Get a Rate Guarantee'; 
     not_partner_txt1 +='</td></tr></table></center>';
     
    
     //'<table cellspacing="2" width="100%"><tr><td style="font-size:1px;height:1px;padding:0;">&nbsp;</td></tr></table>' +
      var not_partner_txt2 = 'Check Rates Before Parking!<br>' + loc_com_name + ' Does Not Guarantee Its Rates';
     // "</div>";
 
     var not_partner_txt = 
     '<table class="nonpart" cellspacing="0" width="100%">' + 
     '<tr><td class="tl_mb"></td><td class="bar_mb" rowspan="2">' +
     not_partner_txt1 +
     '</td><td class="tr_mb"></td></tr>' +  
     '<tr class="bar_mb" style="height:20px;"><td></td><td></td></tr>' +
     '<tr class="bar_mb"><td colspan="3" style="padding:0px 6px;"><div class="dotted_blue"></div></td></tr>' +
     '<tr class="bar_mb" style="height:30px;"><td>' +
     '</td><td rowspan="2">' +
     not_partner_txt2 +
     '</td><td></td></tr>' +
     '<tr><td class="bl_mb"></td><td class="br_mb"></td></tr>' +
     '</table>';     
     

   }
   else
   {
   var not_partner_txt1 = 'Check Rates Before Parking!' +
   '<br>This Facility Does Not Guarantee Its Rates';
   
   var not_partner_txt = 
     '<table class="nonpart" cellspacing="0" width="100%">' + 
     '<tr><td class="tl_mb"></td><td class="bar_mb"></td><td class="tr_mb"></td></tr>' +  
     '<tr class="bar_mb" style="height:30px;"><td>' +
     '</td><td>' +
     not_partner_txt1 +
     '</td><td></td></tr>' + 
     '<tr><td class="bl_mb"></td><td class="bar_mb"></td><td class="br_mb"></td></tr>' +
     '</table>';
   }

     
      var loc_rate = new String(fmtCurrency(caseRslt.charge));
      
      if(CENTRAL_APPLY)if(this.company.toLowerCase().indexOf("central") > -1)
      {
       if(loc_rate.indexOf(".") == -1)loc_rate += ".00";
       loc_rate += strTaxIncl;
      }
      
      // Your search line
       if(caseRslt.charge < 0)
       {// charge is N/A
       var na_charge =  parseInt(-caseRslt.charge);
       var textNA = arrNAresults[(na_charge)];
      
       if(na_charge == 3) 
       { //Daily maximum stay
       var str = new String(caseRslt.charge);
       var b = str.split(".");
       textNA = textNA.replace("___", b[1]);
       }
       
       if(textNA != "")textNA = "(" + textNA + ")";
       
       
       
       if(POP_SEARCH_TYPE == 2)
       {
       
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';       

       detailHTML_SS += 
       '<tr class="titlesrch"><td></td><td colspan="' + spec_pad_all + '">Your Search: NOT APPLICABLE <br><span style="font-weight:normal;">' + textNA  + '</span></td><td></td></tr>';
       
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';        
       
       }
       else
       {
       var detailHTML_search = 
      '<tr class="titlesrch"><td></td><td colspan="' + spec_pad_all + '">Your Search: NOT APPLICABLE <br><span style="font-weight:normal;">' + textNA  + '</span></td><td></td></tr>';
       
       }
       
       }
       else
       {

       /// POP_SEARCH_TYPE == 2
      if(POP_SEARCH_TYPE == 2) // older, not grid
      { 
      
      var strAddTD = '<td>&nbsp;</td>'; // 
      var colsp = '7';
      if(this.green > 0){var strAddTD = ''; colsp = '6'; }            
      
      
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
      for(n=0; n<parseInt(colsp); n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';      
      
      detailHTML_SS += '<tr class="titlesrch"><td></td><td colspan="' + colsp + '">Your Search for ' + strDateSearch + '</td><td></td></tr>'; 

            
      if(this.green > 0)
      detailHTML_SS += '<tr class="srch"><td></td><td class="head">Arrive</td><td class="head">Depart</td><td class="head">Hrs</td><td class="head">Rate</td><td width="65%" ' + spec_pad_last + '></td>';
      else
      detailHTML_SS += '<tr class="srch"><td></td><th width="25%">&nbsp;</th><td class="head">Arrive</td><td class="head">Depart</td><td class="head">Hrs</td><td class="head">Rate</td><th width="25%"></th>';

      detailHTML_SS += '<td></td><td></td></tr>';
      
      // combine SEARCH area (yellow)
      detailHTML_SS += '<tr class="srch"><td>&nbsp;</td>' + strAddTD + '<td  class="srchinfo">' +
      jsFormatTime(parking_arrival) +
       '</td><td class="srchinfo">' + 
      jsFormatTime(parking_departure) +
      jsWeekdayFix(parking_arrival, parking_departure) + 
      '</td><td class="srchinfo">' +
      jsSearchHours(parking_arrival, parking_departure) +
      '</td><td class="srchinfo">' +
      loc_rate + '</td>' + strAddTD;
      
      if(this.green > 0) detailHTML_SS += '<td style="text-align:center;" ' + spec_pad_last + '><center>' + GetRateStr + '</center></td>';
      detailHTML_SS += '<td></td>';
      
      detailHTML_SS += '<td></td></tr>'; 
      
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
      for(n=0; n<parseInt(colsp); n++) detailHTML_SS += '<td></td>'; 
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';        
                  
       }
       /// END  POP_SEARCH_TYPE == 2 
       
       }


var loc_compCoupon = caseRslt.arrCompCoupon;

//if(loc_compCoupon != "")alert(loc_compCoupon);

if(POP_SEARCH_TYPE == 1 && loc_compCoupon != null) // NYC currently, grid
{
      var loc_rate = caseRslt.charge;
      
      var loc_id = loc_compCoupon[0];
      var loc_specStr = loc_compCoupon[1];
    
      
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';
     
     
    detailHTML_SS += '<tr class="titlesrch"><td></td><td colspan="' + spec_pad_all + '">Your Search for ' + strDateSearch + '</td><td></td></tr>'; 

     var URL = XML_GET_COUPON_URL + "?v=" + VERSION + "&id=" + this.licenceNumber + 
     "&coup=" + loc_id + '&arr=' + (getGMTTime(parking_arrival)/1000) + "&redir" + "&compare";

     var GetRateStr = '<table class="btn_get_free_rrg plain" cellspacing="0" ' +
                      'onClick="window.open(\'' + URL + '\');">' +
                      '<tr><td style="font-weight:bold;"><nobr>Get Free RATE GUARANTEE</nobr></td></tr></table>';  

      // heading
      detailHTML_SS +='<tr class="srch"><td class="srch"></td><td class="head">Arrive</td><td class="head">Depart&nbsp;by</td><td class="head">Max&nbsp;Hrs</td><td class="head">Rate</td>' +
      '<td ' + spec_pad_last + '></td><td></td></tr>';
       
      detailHTML_SS += '<tr class="srchinfo"><td  class="srch">&nbsp;</td><td>' + loc_specStr + 
      '<td>$' + loc_rate + '</td>' +
      '<td  class="srch btntd" ' + spec_pad_last + '><center>'
       + GetRateStr + '</center></td>' +
       '<td class="srch">&nbsp;</td></tr>';


      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';       


}


/// POP_SEARCH_TYPE == 1
if(POP_SEARCH_TYPE == 1 && loc_compCoupon == null) // NYC currently, grid
{
     var detailHTML_search = '';
     
     var na_charge = caseRslt.charge;
    
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';
     
     
      detailHTML_SS += '<tr class="titlesrch"><td></td><td colspan="' + spec_pad_all + '">Your Search for ' + strDateSearch + '</td><td></td></tr>'; 
     
      //// GRID
       var detailHTML_grid = '';
       var str_sharges = caseRslt.charges;
       var arr_sharges = str_sharges.split(" ");
      
       detailHTML_grid += '<table class="grid" cellspacing="0">';

       if(this.green > 0)
       detailHTML_grid += '<tr><td colspan="3" rowspan="3">Rates<br>Guaranteed</td>';
       else
       detailHTML_grid += '<tr><td colspan="3" rowspan="3"><b>Rates<br><span style="color:#ed1c24;">NOT</span><br>Guaranteed</b></td>';
       
       
       detailHTML_grid += '<td class="arrdeptd" colspan="3" style="border-bottom:0;padding-bottom:0;"><nobr>DEPART ' +
       arrWeekDay[parking_departure.getDay()] + ", " +  
       arrMonthAbbr[parking_departure.getMonth()] + " " +
       parking_departure.getDate() +
       '</nobr></td></tr>'; 
       
       detailHTML_grid += '<tr colspan="3" class="toparrow"><td style="border-right:0;">&nbsp;</td><td class="bb" style="border-left:0;border-right:0;"><center><img src="' + PATH_IMG + 'images/arrow_grid_top.gif" alt="v"></center></td><td style="border-left:0;">&nbsp;</td></tr>';
       
       // Depart
       detailHTML_grid += 
       '<tr><td class="rb">' + jsFormatTime(parking_departure, -60) + '</td>' +
       '<td class="currtimecell">' + jsFormatTime(parking_departure) + '</td>' +
       '<td class="lb">' + jsFormatTime(parking_departure, 60) + '</td></tr>';
       
       detailHTML_grid += '<tr><td class="arrdeptd" rowspan="3" style="text-align:center;border-right:0px;padding-right:0;">ARRIVE<br>';
       
       detailHTML_grid += arrWeekDay[parking_arrival.getDay()] + "<br>" +  
                          arrMonthAbbr[parking_arrival.getMonth()] + " " +
                          parking_arrival.getDate();       
                      
       detailHTML_grid += '</td>';
       
       detailHTML_grid += '<td  class="leftarrow" rowspan="3" style="border-left:0;"><img src="' + PATH_IMG + 'images/arrow_grid_left.gif" alt=">"></td>';
       
       
       for(var r=0; r<3; r++)
       {
       if(r!=0)detailHTML_grid += '<tr>';
       detailHTML_grid += '<td';
       if(r==1)detailHTML_grid += ' class="currtimecell"';
       detailHTML_grid += '>' + jsFormatTime(parking_arrival, (r-1)*60 ) + '</td>' ;
       
       for(var c=0; c<3; c++)
       {
       if(arr_sharges[r*3 + c] < 0)
       {var loc_chrg = "N/A";  if(na_charge>0) na_charge = arr_sharges[r*3 + c];}
       else
       var loc_chrg = "$" + arr_sharges[r*3 + c];
       
       detailHTML_grid += '<td';
       if(r==1 && c==1)detailHTML_grid += ' class="mainchrg"';
       detailHTML_grid += '>' + loc_chrg + '</td>' ;
       }
       detailHTML_grid += '</tr>';
       }
       
       detailHTML_grid += '</table>';

      
       detailHTML_SS += '<tr class="srch"><td></td><td colspan="' + spec_pad_all + '" style="vertical-align:middle;">';
       detailHTML_SS += '<center><table cellspacing="0">';
       detailHTML_SS += detailHTML_search;
       detailHTML_SS += '<tr><td><center>' 
       
       detailHTML_SS += detailHTML_grid;
       
       detailHTML_SS += '</center></td>'
       detailHTML_SS += '<td style="vertical-align:middle;padding-left:30px"><center>';
       detailHTML_SS += GetRateStr; 
       detailHTML_SS += '</center></td></tr>';
       
       if(this.lst7)
       {
       if(this.green == 1)
       {var loc_str = 'Rate Guarantee';}
        else if(this.green == 2)
       {var loc_str = 'Reservation';}
      
       if(this.green == 1 || this.green == 2)
       detailHTML_SS += '<tr><td colspan="2" style="letter-spacing:-1px;font-size:14px;color:#811010;padding-top:4px;">' +
      '<b>You MUST Print This Free "' + loc_str + '" To Get the Rates Shown Above</b></td></tr>';
       
       }
       
       if(this.dailyEventAttr != null)
       detailHTML_SS += '<tr><td colspan="2" style="letter-spacing:-1px;font-size:14px;color:#811010;padding-top:4px;">' +
      '<b>' + this.dailyEventAttr + '</b></td></tr>';
      
       
       
       //// N/A charge
       if(parseInt(na_charge) < 0)
       {// charge is N/A
       na_charge = -na_charge;
       na_charge2 =  parseInt(na_charge);
       var textNA = arrNAresults[(na_charge2)];
      
       if(na_charge2 == 3) 
       { //Daily maximum stay
       var str = new String(na_charge);
       var b = str.split(".");
       textNA = textNA.replace("___", b[1]);
       }     
       
      detailHTML_SS += '<tr><td colspan="2" style="font-size:14px;color:#811010;padding-top:4px;">' +
      '<b>N/A = ' + textNA + '</b></td></tr>'; 
       
       }       
       
       
       detailHTML_SS += '</table></center>';
      
       detailHTML_SS += '</td><td></td></tr>';
       
      
      
      
       
       
      // rounded corners
      detailHTML_SS += '<tr class="srch"><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';       
       
       
       if(!this.partner && this.green==0)
       {
       detailHTML_SS += dividing_band;
       detailHTML_SS += '<tr><td colspan="' + ( parseInt(spec_pad_all) + 2) + '"><center>' + not_partner_txt  + '</center></td></tr>'; 
       }      
       
       
       

} // NYC currently, grid
       
      detailHTML_SS += dividing_band;
      
       }
      
      
      // S P E C I A L S output  - pink backgrnd
      // 
           
      if(!parking_isMonthly && this.green > 0 && loc_arrSpec.length > 0)
      {  

     if(!bTaxSuvAdded)
     {detailHTML_SS2 += strTaxSUV; bTaxSuvAdded = true;}
      
      //// freeSUVspec
      
      var str_freeSUV ='';
      var loc_add_style = '';
      
      if(this.freeSUVspec)
      {
       str_freeSUV = '<tr class="spcl descr"><td></td><td colspan="' + spec_pad_all + '" style="padding-top:0px;"><b>(There Is <u>No</u> SUV Charge)</b></td><td></td></tr>'; 
       loc_add_style = ' style="padding-bottom:0px;"';
      }
      
      // rounded corners
      detailHTML_SS += '<tr class="spcl"><td><img src="' + PATH_IMG + 'images/pop_purp_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td><img src="' + PATH_IMG + 'images/pop_purp_tr.gif"></td></tr>';
      
                                                                                                                                                                             
      detailHTML_SS += 
      '<tr class="title spcl"><td></td><td width="100%" colspan="' + spec_pad_all + '"' + loc_add_style + '>'
      
      if(loc_arrSpec.length > 1)
      detailHTML_SS += 'SPECIALS Offered';
      else
      detailHTML_SS += 'SPECIAL Offered';
       
      detailHTML_SS += " for"; 
      
      if(!parking_isCase)
      { // calendar - hidden input
      detailHTML_SS += 
      '<input id="popDateTemp' + place + '" type="text" value="' + dateCalendar + '" style="visibility:hidden;width:4px;height:1px;">';
      }     
      else
      detailHTML_SS += "&nbsp;";
      
      detailHTML_SS += strDateSpec;
      
      if(!parking_isCase)
      { // calendar - link
      detailHTML_SS += ' or ' + 
      '&nbsp;<a href="javascript:;" class="cal" onClick="calendPlace=' + place + ';InitCal();DisplayCal(document.getElementById(\'popDateTemp' + place + '\'), ChangeSpec);">calendar</a>';
      }
     
      detailHTML_SS += '</td><td></td></tr>';
       

      detailHTML_SS += str_freeSUV;
     
      
      var detailHTML_SS_specs = "";
      var addList = ""; // if place is result list
      if(place == 3) addList = "l"; 

      
      // 'Get RG/R' system
      for(var s in loc_arrSpec) // output all Specs
      {
      // 'Get RG/R' buttons
                                               ///  freeSUVspec
      if(parking_vehicle == VEHICLE_REGULAR || this.freeSUVspec)
      var loc_rate = loc_arrSpec[s].rate;
      else if(parking_vehicle == VEHICLE_SUV)
      var loc_rate = loc_arrSpec[s].rateSUV;
     
     
     // Central
     if(CENTRAL_APPLY)if(this.company.toLowerCase().indexOf("central") > -1) loc_rate += strTaxIncl;

      if(this.green == 1)
      var loc_Btn_s = 'Get Free RATE GUARANTEE'; // &#13;&#10;
      else if(this.green == 2)
      var loc_Btn_s = 'Get Free RESERVATION';      
      
      if(this.dps2nd)loc_Btn_s = 'Get Free RESERVATION';

     var GetRateStr = '<table class="btn_get_free_rrg plain" cellspacing="0" ' +
                      'onClick="OpenGetGuarantee(' + s +  ', ' + this.licenceNumber + ', \'s' + addList + '\');">' +
                      '<tr><td>' + loc_Btn_s + '</td></tr></table>';  
      
    
         var id = '';
         if(place == 2)id = 'id="s' + s +  '" ';
         if(place == 3)id = 'id="sl' + s +  '" ';

      /// Special descriptions
      var loc_descr_digits = loc_arrSpec[s].description; // string of digits 1,2,3
      // to combine all descriptions
      
      if(loc_descr_digits == "1 2 3")
      {
      loc_descr_digits = "ALL-DAY Special";
      }
      else
      {
      loc_descr_digits = loc_descr_digits.replace(/ /g, ", ");
      
      for(var d = 1; d < 4; d++) 
      loc_descr_digits = loc_descr_digits.replace(d, arrSpecialsDescriptions[d]);
      
      loc_descr_digits = loc_descr_digits.replace(/Specials/g, "Special");
      }
     
      var loc_descr = loc_descr_digits;

      var addPadd = "";
      if(detailHTML_SS_specs=="")addPadd = "padding-top:0;";
      
      detailHTML_SS_specs += 
      '<tr class="spcl descr"><td></td><td colspan="' + spec_pad_all + '" style="/*padding-bottom:0px;*/' + addPadd + '"><b>' + loc_descr + '</b></td><td></td></tr>'; 
     
      var maxmin_head = "Max&nbsp;Hrs";    
      if(parseInt(loc_arrSpec[s].stay) < 0)maxmin_head = "Min&nbsp;Hrs";   
      
      if(POP_SPEC_FULL)
      detailHTML_SS_specs += '<tr class="spcl"><td></td><td class="head">Arrive</td><td class="head twolns">Depart<br>after</td><td class="head twolns">Depart<br>before</td><td class="head">' + maxmin_head + '</td><td class="head">Rate</td>' +
      '<td width="100%"></td><td></td></tr>';
      else      
      detailHTML_SS_specs += '<tr class="spcl"><td></td><td class="head">Arrive</td><td class="head">' + loc_arrSpec[s].headDep +'</td><td class="head">' + maxmin_head + '</td><td class="head">Rate</td>' +
      '<td></td><td></td></tr>';

      
      // combine SPECIALS area 
      detailHTML_SS_specs += '<tr class="spclinfo"><td class="spcl">&nbsp;</td><td>' + loc_arrSpec[s].specStr + 
      '<td>$' + loc_rate +
      '</td>' +
      '<td  '
       + id + ' class="spcl btntd"><center>'
       + GetRateStr + 
       '</center></td>' +
      '<td class="spcl">&nbsp;</td></tr>';
       
       
      
       }
       detailHTML_SS += detailHTML_SS_specs;
      
      // rounded corners
      detailHTML_SS += '<tr class="spcl"><td><img src="' + PATH_IMG + 'images/pop_purp_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td><img src="' + PATH_IMG + 'images/pop_purp_br.gif"></td></tr>';
      
      detailHTML_SS += dividing_band;
            
      }
       // end Specs output
       
      
      ////////////////////////
      //  C O U P O N S  output
      
      if(!parking_isMonthly && this.green > 0 && loc_arrCoup.length > 0)
      {  

      if(!bTaxSuvAdded)
      {detailHTML_SS2 += strTaxSUV; bTaxSuvAdded = true;}

      // rounded corners
      detailHTML_SS += '<tr class="coupon"><td><img src="' + PATH_IMG + 'images/pop_red_tl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td><img src="' + PATH_IMG + 'images/pop_red_tr.gif"></td></tr>'; 

      detailHTML_SS += 
      '<tr class="title coupon"><td></td><td colspan="' + spec_pad_all + '" style="/*padding-bottom:0;*/">'
      
      if(loc_arrCoup.length > 1)
      detailHTML_SS += 'COUPONS Offered';
      else
      detailHTML_SS += 'COUPON Offered'; 

      detailHTML_SS += " for"; 
      
      if(!parking_isCase)
      { // calendar coup - hidden input
      var coup_place = parseInt(place) + 10;
      detailHTML_SS += 
      '<input id="popDateTemp' + coup_place + '" type="text" value="' + dateCalendar + '" style="visibility:hidden;width:4px;height:1px;">';
      } 
      else
      detailHTML_SS += "&nbsp;";
      
      detailHTML_SS += strDateSpec;
      
      if(!parking_isCase)
      { // calendar coup - link
      detailHTML_SS += ' or ' + 
      '&nbsp;<a href="javascript:;" class="cal" onClick="calendPlace=' + coup_place + ';InitCal();DisplayCal(document.getElementById(\'popDateTemp' + coup_place + '\'), ChangeSpec);">calendar</a>';
      }
      
      detailHTML_SS += '</td><td></td></tr>';
      
      var addList = "";
      if(place == 3) addList = "l";
      
      var detailHTML_SS_coups = ""; // all coupons rows
      var allCoupsRules = ""; // all rules to be added to "Note:"
      
     
      if(this.green == 1)
      var loc_Btn_c = 'Get Free RATE GUARANTEE'; // &#13;&#10;
      else if(this.green == 2)
      var loc_Btn_c = 'Get Free RESERVATION';
     
      if(CITY_NAME == "Boston" && this.company.toLowerCase() == "icon")
      loc_Btn_c = 'Get Free RESERVATION';
                                      
      
      // 'Get RG/R' system
      for(var s in loc_arrCoup) // output all coupons
      {

      // 'Get RG/R' buttons
     var GetRateStr = '<table class="btn_get_free_rrg plain" cellspacing="0" ' +
                      'onClick="OpenGetGuarantee(' + s +  ', ' + this.licenceNumber + ', \'c' + addList + '\');">' +
                      '<tr><td>' + loc_Btn_c + '</td></tr></table>';  
      
         var id = '';
         if(place == 2)id = 'id="c' + s +  '" ';
         if(place == 3)id = 'id="cl' + s +  '" ';    
                               
      if(parking_vehicle == VEHICLE_REGULAR)
      var loc_rate = loc_arrCoup[s].rate;
      else if(parking_vehicle == VEHICLE_SUV)
      var loc_rate = loc_arrCoup[s].rateSUV;
      
      // Central
      if(CENTRAL_APPLY)if(this.company.toLowerCase().indexOf("central") > -1) loc_rate += strTaxIncl;
      
      var loc_descr = loc_arrCoup[s].description;
      if(loc_arrCoup[s].rules!="")
      loc_descr +=  " (" + loc_arrCoup[s].rules + ")";/* Note:&nbsp; */
      
      var addPadd = "";
      if(detailHTML_SS_coups=="")addPadd = "padding-top:0;";
      
      detailHTML_SS_coups += 
      '<tr class="coupon descr"><td></td><td colspan="' + spec_pad_all + '" style="/*padding-bottom:0px;*/' +addPadd  + '"><b>' + loc_descr + '</b></td><td></td></tr>'; 
      
      // heading
      detailHTML_SS_coups +='<tr class="coupon"><td class="coupon"></td><td class="head">Arrive</td><td class="head">Depart&nbsp;by</td><td class="head">Max&nbsp;Hrs</td><td class="head">Rate</td>' +
      '<td ' + spec_pad_last + '></td><td></td></tr>';
       
      detailHTML_SS_coups += '<tr class="coupinfo"><td  class="coupon">&nbsp;</td><td>' + loc_arrCoup[s].specStr + 
      '<td>$' + loc_rate + '</td>' +
      '<td  class="coupon btntd" ' + id + ' ' + spec_pad_last + '><center>'
       + GetRateStr + '</center></td>' +
       '<td class="coupon">&nbsp;</td></tr>';
     
      
      }
      
      detailHTML_SS += '';
      detailHTML_SS += detailHTML_SS_coups;
      
      // rounded corners
      detailHTML_SS += '<tr class="coupon"><td><img src="' + PATH_IMG + 'images/pop_red_bl.gif"></td>';
      for(n=0; n<spec_pad_all; n++) detailHTML_SS += '<td></td>';
      detailHTML_SS += '<td><img src="' + PATH_IMG + 'images/pop_red_br.gif"></td></tr>';      
      
      detailHTML_SS += dividing_band;
      
      }
       // end Coupons output       
      
    
      if(detailHTML_SS != "")
      detailHTML_SS = detailHTML_SS2 + '<table class="spectbl" border="0" cellspacing="0" width="100%">' +
      detailHTML_SS + '</table>';
      
      detailHTML += detailHTML_SS;
      
      // add daily comments
      detailHTML += detailHTML_Daily_Comm;
        
        // Monthly 
        if(parking_isMonthly)
        {
        var loc_POP_MO_SEARCH_TYPE = POP_MO_SEARCH_TYPE;
        
        if(CITY_NAME == "New York" && this.licenceNumber==99999964)
          loc_POP_MO_SEARCH_TYPE = 3;
       
       
        //Your  S E A R C H for Monthly popup
        var chrg = this.getMonthlyRate(parking_vehicle);
       
       if(loc_POP_MO_SEARCH_TYPE == 3 && chrg>0)
       {detailHTML += "<div class='dotted_blue_dark' style='margin-top:3px;'></div>" +
                     "<div class='gentax'>Tax Included</div>";bTaxSuvAdded = true;}
       
        var chrgReg = chrg; 
        var chrgSUV = this.getMonthlyRate(VEHICLE_SUV); 
        
        var surchrgSUV = 0;
        if(POP_MO_SUV_SURCHRG && chrg > 0) surchrgSUV = chrgSUV - chrg;
        
        var strTaxSUVmo = '';

        if(chrg == -11)bGetDealCase = true;

        if(chrg <= 0)
        {
          
        if(chrg == -1)chrg = " &nbsp;Not Posted";
        
        if(chrg == 0 || chrg == -2)
        { // N/A
        chrg = " &nbsp;Not Applicable"; 
        
        if(parking_vehicle==VEHICLE_MOTORCYCLE)
        chrg += "<br>(Facility May Not Accept Motorcycles)";
        else if(parking_vehicle==VEHICLE_REGULAR)
        chrg += "<br>(No Monthly Parking)";
        else
        chrg += "<br>(Facility May Not Accept Your Vehicle Type)";
        }
        
        }
        else if(chrg == null)
        chrg = " &nbsp;Not Applicable<br>(No Monthly Parking)";
        else
        {
        
        if(loc_POP_MO_SEARCH_TYPE==1)  // NYC
        chrg = 
        '<center><table class="nyc"><tr><td><nobr>$' +
        chrg  + 
        ' <span class="incl">(Incl. 18.375% Tax - Non-Manhattan Registration)</span><br>' +
        '$' + (this.getMonthlyRate(parking_vehicle, true))  + 
        ' <span class="incl">(Incl. 10.375% Tax - Manhattan Registration)</span></nobr></td><tr></table></center>';
        
        if(loc_POP_MO_SEARCH_TYPE != 1)chrg = " &nbsp;$" + chrg;
        if(POP_SUVTAX_TYPE==2)strTaxSUVmo = strTaxSUV;
        
        }
        
        
        // array of add strings, array offset is equal to parking_vehicle value
        var arrAddStr = Array("", "", " - SUV", " - Luxury", " - Motorcycle");
        var addVeh = arrAddStr[parking_vehicle];

         var loc_str = 'Deals'; var loc_com = (this.company.toUpperCase());
         if(POP_MO_MONTH_FRM){ loc_str = 'The Above Rate(s)'; loc_com = ""}

        
        if(bDisplayMonthForm && bGetDealCase) // 'Get Deal' case
        {var chargeLine = 'To Get ' + loc_str  + ' at This ' + 
        loc_com + 
        ' Location<br>Enter Contact Information and Click "Send"'
        + OutputMonthlyForm(this.licenceNumber, isClick, place);  // monthly_specs.js
        
        var loc_str_img  = 'mon_frm_yel_'; // define background
        var loc_str_class  = 'yellowff5';       
        }
        else
        {
        var chargeLine = 'Monthly 24-Hr Rate' + addVeh + ': ' + chrg;
        
        var loc_str_img  = 'pop_yellow_';
        var loc_str_class  = 'srch';       
        }
        

        var addClass = "srch"; // " srch"
        if(loc_POP_MO_SEARCH_TYPE == 1 && (bDisplayMonthForm && !bGetDealCase) || bDisplayMonthFormNonPartner)addClass = "";

        if(surchrgSUV > 0) // Bo SUV
        {
        chargeLine = '<center><table class="popmonthsrch" cellspacing=0><tr><td>Monthly 24-Hr Rate:&nbsp;</td><td>$' + chrgReg + 
        '</td></tr><tr><td class="suv">SUV Surcharge: </td><td class="suv">$' + surchrgSUV +  '</td></tr></table></center>';
        }       

      
      var monthSearch = '';
     
      top_margn = 7;
      if(bTaxSuvAdded)top_margn = 0;
      
      monthSearch += '<table class="popmonthsrch ' + loc_str_class + '" cellspacing="0" border="0" width="100%" style="margin-top:' + top_margn + 'px;">' +
      
      '<tr><td><img src="' + PATH_IMG + 'images/' + loc_str_img + 'tl.gif"></td>' +
      
      '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/' + loc_str_img + 'tr.gif"></td></tr>' +
      
      '<tr><td></td><td>' + chargeLine + '</td><td></td></tr>' +
      
      '<tr><td><img src="' + PATH_IMG + 'images/' + loc_str_img + 'bl.gif"></td>' +
      '<td></td><td width="8"><img src="' + PATH_IMG + 'images/' + loc_str_img + 'br.gif"></td></tr>' +
      
      '</table>';
       
       
        // Mo SUV/Tax
        monthSearch = strTaxSUVmo + monthSearch;
        
        // Monthly comments
        if(this.monthlyComments != null)
        {
        var arrComm = this.monthlyComments.split("<br>$$<br>");
        // comments are in string consisting of 3 parts ( designating by "<br>$$<br>" )
        // 1st part is tax line (if needed), 2nd is for non motorcycle
        //  and 3rd is for motorcycle
        
        monthSearch = arrComm[0] + monthSearch; 
       
        
        if(parking_vehicle != VEHICLE_MOTORCYCLE)
        detailHTML += "<b>" + monthSearch + '</b><div class="popattr">' +arrComm[1] + '</div>';
        else if(arrComm[2] != undefined)
        detailHTML += "<b>" + monthSearch + '</b><div class="popattr">' + arrComm[2] + '</div>';
        else
        detailHTML += monthSearch;
        
        }
        else
        detailHTML += monthSearch;
        
        }
        
      detailHTML += "</span>";  
      
     
      // Close button and contact (Last visited, '')
      var contact_txt = "&nbsp;";
      
      // contact
      
      if ((parking_isCase && caseRslt.charge > 0 ) || (parking_isMonthly && this.getMonthlyRate(parking_vehicle) > 0 )
      || loc_arrSpec.length > 0 || loc_arrCoup.length > 0
      )
      {
      if(this.contact)
      {
     // detailHTML += "<div style='margin-bottom:-8px;text-align:right;font-weight:normal;font-size:11px;'>Last visited on " + this.contact + "</div>";
      contact_txt = "Last visited on <br>" + this.contact;
      }
      else if(this.baseGreen > 0 || this.partner)
      {
      contact_txt = "Rates current as of <br>" + strTodayDate;
      }
      
      }
      
      
      
      //// display Monthly Form below rates, only for NOT GetDeal(charge == -11)
      if((parking_isMonthly && bDisplayMonthForm && !bGetDealCase) || bDisplayMonthFormNonPartner)
      {
        /* ......contact_txt ......*/
        
        if(bDisplayMonthForm)
        {
        var chargeLine = 'To Get ' + loc_str + ' at This ' + 
        loc_com + 
        ' Location<br>Enter Contact Information and Click "Send"'
        + OutputMonthlyForm(this.licenceNumber, isClick, place);  // monthly_specs.js
        }
        else if(bDisplayMonthFormNonPartner)
        {
        var chargeLine = 'To Get Competitive Bids <br>Enter Contact Information and Click "Send"'
        + OutputMonthlyForm(this.licenceNumber, isClick, place);  // monthly_specs.js
        }        
        
       /* detailHTML += '<table border="0" width="100%" style="margin-top:7px">' +
        '<tr class="titlesrch"><td>' + chargeLine + '</td></tr></table>'; */
      
      detailHTML += '<table class="popmonthsrch yellowff5" cellspacing="0" border="0" width="100%" style="margin-top:7px;">' +
      
      '<tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_tl.gif"></td>' +
      
      '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_tr.gif"></td></tr>' +
      
      '<tr><td></td><td>' + chargeLine + '</td><td></td></tr>' +
      
      '<tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_bl.gif"></td>' +
      '<td></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_br.gif"></td></tr>' +
      
      '</table>';

      }


      if(bDisplayMonthForm || bDisplayMonthFormNonPartner)
      {
      var strAddId = "";
      if(!isClick)strAddId = "f";
      if(place==3)strAddId  = strAddId + "l";

                      
 var strSendBtn ='<div id="sendms_btn_pop' + strAddId + '" class="mb_btn"  onClick="SendMonSpecPop(' + place + ');" style="margin-right:20px;">' +
                 '<div class="c"><div class="l"><div class="r" id="sendms_btn_pop' + strAddId + '_inner">' +
                 'Send' +
                 '</div></div></div></div>';                     
                          
      }
      else
      {
      var strSendBtn ='';

      }

     
      //DisplayElem(idDetailLabel, "block"); 
     
      var locClass = GetElement(idDetailLabel).className;
      GetElement(idDetailLabel).className = locClass.replace(/ graypop/, "");
     
      var bGray = false;
      
      if(!parking_isMonthly)
      {
      if(GREEN)if(this.green == 0)bGray = true;
      if(!GREEN)if(this.noDPS)bGray = true;
      }
      
      if(parking_isMonthly)
      {
      
      //
      if(MON_PARTNERS)
      {if(!this.partner2 || loc_chrg==-1)bGray = true;}
      else
      {var loc_chrg = this.getMonthlyRate(parking_vehicle);
      if(loc_chrg==-2 || typeof(this.getMonthlyRate(parking_vehicle))=='undefined' )bGray = true;}
      }      

      
      if(bGray)
      GetElement(idDetailLabel).className += " graypop";
      
      
      GetElement(idDetailLabel + "_head").innerHTML = '<center>' + this.name + '</center>';
      GetElement(idDetailLabel + "_cont").innerHTML = detailHTML;
      GetElement(idDetailLabel + "_visit").innerHTML = contact_txt;
      GetElement(idDetailLabel + "_sendtd").innerHTML = strSendBtn;
      
     /* if(isClick)
      {
      detailHTML = detailHTML.replace(/</g, "&lt;");
      detailHTML = detailHTML.replace(/>/g, "&gt;");
      detailHTML = detailHTML.replace(/<br>/g, "\n");
      document.write(detailHTML); 
      } 
      */
      if(isClick)
      GetElement(idDetailLabel + "_close").className = 'mb_btn';
      else
      GetElement(idDetailLabel + "_close").className = 'mb_btn_dis';
 
      
      
     // return detailHTML;
    };
    //// Garage::GetGeneralInfoHTML
    this.GetGeneralInfoHTML =
    function(param)
    { // the function returns general info HTML, used in all popups
    
    if(typeof param == 'undefined')param = '';
    
   // Garage general info 
      var detailHTML = '';
        
      detailHTML += '<span class="name">' + this.name + '<br></span>';
        
      detailHTML += '<span class="addr">' + this.addressHTML;
   
      if(this.entranceNotes != null)
        detailHTML += '(entrance ' + this.entranceNotes + ')<br>';
      detailHTML +=   '</span>';
      
      if(POP_SHOW_CAP){
      if(this.capacity == null || this.capacity == 0)
        {
        if(!AIRPORT)
        detailHTML += '<span class="gencat">Capacity: </span><span class="gendat">Not Posted<br></span>';
        }
      else
        detailHTML += '<span class="gencat">Capacity: </span><span class="gendat">' + this.capacity + '<br></span>';
      }
        
      if(this.openingHours != null)
        detailHTML += '<span class="hours">' + this.openingHours + '<br></span>';


       if((parking_isMonthly || param =='phn_mon') &&  this.phone != null)
        {
       /* if(this.company.toLowerCase() == "icon")
        detailHTML += '<span class="gencat">SPACE AVAILABLE &#8212; Call ' + this.phone + ' for Discounted Rates<br></span>';
        else if(this.phone != null)*/
        detailHTML += /*'<span class="gencat">Phone: </span>*/ '<span class="gendat">' + this.phone + '<br></span>';
        }
      else if(!parking_isMonthly && this.phoneday != null) 
        detailHTML += /*'<span class="gencat">Phone: </span>*/ '<span class="gendat">' + this.phoneday + '<br></span>'; 
        
       //  TOP ATTRIBURES
       var top_attr = '';
       
       // daily
       if(!parking_isMonthly && this.dailyTopAttr != null)  
       {        
       var arrAttr = this.dailyTopAttr.split("<br>$$<br>"); 
        
        if((parking_vehicle == 2) && arrAttr[1] != undefined ) // SUV 
         top_attr = arrAttr[1];
        else if(arrAttr[0] != undefined) // not SUV
         top_attr = arrAttr[0];
       }
       // monthly
       if(parking_isMonthly && this.monthlyTopAttr != null)  
       {        
       var arrAttr = this.monthlyTopAttr.split("<br>$$<br>");
       
       if(parking_vehicle != VEHICLE_MOTORCYCLE)
        top_attr = arrAttr[0];
       else if(arrAttr[1] != undefined)
        top_attr = arrAttr[1];
       }        
        
       if(top_attr != '')
       detailHTML += '<span class="gentop">' + top_attr + '<br></span>'; ;
        
    return detailHTML;        
    
    }
    
    //// Garage::GetGarageAttributesHTML
    this.GetGarageAttributesHTML =
    function()
    { /// not in use
      // for getting comments ( implemented above in setDetailHTML)
    
      var detailHTML = "";
      
      if(!parking_isMonthly && this.dailyComments != null)
        {
        
        var arrComm = this.dailyComments.split("<br>$$<br>"); 
        
        if(arrComm[0] != undefined) strCommon = arrComm[0];
        
        if((parking_vehicle == 2) && arrComm[2] != undefined )
        {
        detailHTML += '<div class="popattr">' + strCommon + arrComm[2] + '</div>';
        }
        else if(arrComm[1] != undefined)
        {
        detailHTML += '<div class="popattr">' + strCommon  + arrComm[1] + '</div>';
        }
        
        
        }
      if(parking_isMonthly && this.monthlyComments != null)
        {
        // 
        var arrComm = this.monthlyComments.split("<br>$$<br>");
        if(parking_vehicle != VEHICLE_MOTORCYCLE)
        detailHTML += '<div class="popattr">' + arrComm[0] + arrComm[1] +'</div>';
        else if(arrComm[2] != undefined)
        detailHTML += '<div class="popattr">' + arrComm[2] + '</div>';
        
      
        }

     return detailHTML;
    }    
     
}    // END Garage class

/// Gradient feature
///      HighlightByRates
function HighlightByRates(boolByRates)
{

var btnDis = document.getElementById("colorSwitch" + boolByRates);
var btnEn = document.getElementById("colorSwitch" + !boolByRates);

btnDis.className = "dis";
btnDis.onmouseover = null;
btnDis.onmouseout = null;

btnEn.className = "en";
btnEn.onmouseover = function() {setBackgrnd(this, 'color_switch_over.gif');};
btnEn.onmouseout = function() {setBackgrnd(this, 'color_switch_btn.gif')};


parking_isByColorRates = boolByRates;

if(boolByRates)
sort_results = SORT_RATE;
else
sort_results = SORT_STREET;

listGarages();

}


////     AddGarageIcon
function AddGarageIcon(objMap, garage, strID)
{ // creates map garage incon (with borders for green garages)
  // for pop map and add them to the pop map
  // called from Garare's select funtion
  ////
  //  objMap  - map to add icon. object
  //  garage  - garage of the icon, object
  // the function returns created icon - loc_popMapIcon

       var latLng = garage.primaryEntrance.latLng;

       var loc_popMapIcon = new TLabel();
       loc_popMapIcon.id = strID;
       loc_popMapIcon.anchorLatLng = latLng;
       objMap.addTLabel(loc_popMapIcon);
       
       if(garage.green > 0 && !parking_isMonthly)
       { // if green, draw borders and icons are of green garage
       
       loc_popMapIcon.layer.className = "borderbl"; // black borders 
       loc_popMapIcon.layer.style.width = 
       loc_popMapIcon.layer.style.height = "31px";
       
        var icon_div = document.createElement('div');
        icon_div.className = "icon";
        loc_popMapIcon.layer.appendChild(icon_div);
        
        icon_div.style.width = 
        icon_div.style.height = "31px";
        
        loc_popMapIcon.icondiv =  icon_div;
        
        loc_popMapIcon.w = loc_popMapIcon.h = 31;
        loc_popMapIcon.green = garage.green; 
        
       if(garage.green == 1)         
        loc_popMapIcon.setImage(ICON_IMG_RG_S1, "black");
       else if(garage.green == 2)
        loc_popMapIcon.setImage(ICON_IMG_R_S1, "black");
       }
       else
       { // if not green garage
        loc_popMapIcon.setImage(PATH_IMG + "images/marker_garage.gif", "blue");
       }


     return loc_popMapIcon;
}

/* *********************
    HideGreenDetails
********************* */
function HideGreenDetails()
{ // the function hide green garage detail popups
 // (those that appear on clicking icon or result list and stay until close)
 // it hides them both on map and list and all popups that connected with them 

lastHourFld = null;

DisplayElem("flick6", "none");
DisplayElem('pophour', 'none');
DisplayElem("map_green_detail_label", "none");
DisplayElem("detwait", "none");
DisplayElem("list_detail_label", "none");
DisplayElem("map_pop", "hidden"); 
 
// Exp Wins
if(typeof(setWindowHeight)=="function")setWindowHeight("clickclose");      

if(typeof(CloseCal)=="function")
CloseCal(); // hide calendar (calendar.js)

DisplayElem("no_result", "hidden");

}

/* *********************
    CreateDetailLabel
********************* */
function CreateDetailLabel(idDetailLabel)
{

var zIndex = '';
if(idDetailLabel=='map_detail_label')zIndex = 'z-index:3015;';
if(idDetailLabel=='map_green_detail_label')zIndex = 'z-index:3009;';

document.write('<table id="' + idDetailLabel + '" class="garpop plain do_not_print_imp" cellspacing="0" style="width:510px;display:none;' + zIndex + '">' +
'<tr><td class="tl_mb"></td>' +
'<td  id="' + idDetailLabel + '_top" class="bar_mb" rowspan="2" width="100%">' +

'<table cellspacing="0" width="100%">' +
'<tr><td id="' + idDetailLabel + '_head" width="100%" style="padding-left:23px;font-weight:600;"></td>' +
'<td class="X_btn_td2" onClick="HideGreenDetails();"><img src="' + PATH_IMG + 'images/blank.gif" width="23" height="22"></td></tr></table>' +

'</td><td class="tr_mb"></td></tr>' +
'<tr class="bar_mb" style="height:25px;"><td></td><td></td></tr>' +
'<tr><td class="left">&nbsp;</td><td id="' + idDetailLabel + '_cont" class="center">' +

'</td><td class="right">&nbsp;</td></tr>' +
'<tr class="bar_mb" style="height:25px;"><td></td><td rowspan="2">' +

'<table cellspacing="0" width="100%">' +
'<tr><td width="50%"></td>' +

'<td id="' + idDetailLabel + '_sendtd" >' +
'</td>' +
 
'<td>' +
'<div id="' + idDetailLabel + '_close" class="mb_btn_dis" onClick="HideGreenDetails();">' +
'<div class="c"><div class="l"><div class="r" id="' + idDetailLabel + '_close_inner">' +
'Close' +
'</div></div></div></div>' +

'</td>' +
'<td width="50%" class="visit" id="' + idDetailLabel + '_visit"></td></tr>' +
'</table>' +

'</td><td></td></tr>' +
'<tr><td class="bl_mb"></td><td class="br_mb"></td></tr>' +
'</table>'); 

}

CreateDetailLabel("map_detail_label");
CreateDetailLabel("map_green_detail_label");
CreateDetailLabel("list_detail_label");



///      CreateStandardPopup
function CreateStandardPopup(strID, strCloseFunc, intWidth, strSendFunc)
{

var bSendBtn = 0;
if(strSendFunc) bSendBtn = 1;


var  strAddFunc = '';
if(strID=='week_sp' || strID=='day_sp' || strID=='month_sp')
strAddFunc = ' onClick="HideGreenDetails();return true;"';

intWidth += 18;


var strSendBtn = '';
var strBtnsWidth = '';

if(bSendBtn)
{
strSendBtn = 
'<td  style="padding-right:20px;">' +

'<div  id="' + strID + '_sendbtn" class="mb_btn" onClick="' + strSendFunc + '" style="/*width:117px;*/">' +
'<div class="c"><div class="l"><div class="r" id="' + strID + '_sendbtn_inner">' +
'Send' +
'</div></div></div></div>' +
'</td>';
//strBtnsWidth = 'width:117px;';
}


document.write('<table id="' + strID + '" class="garpop plain do_not_print_imp" cellspacing="0" style="display:none;width:' + intWidth + 'px;z-index:3000;" ' + strAddFunc + '>' +
'<tr><td><img src="' + PATH_IMG + 'images/tl_mb.gif"></td>' +
'<td  class="bar_mb" rowspan="2" width="100%">' + /* style="width:' + intWidth + 'px;"*/

'<table cellspacing="0" width="100%">' +
'<tr><td width="100%" id="' + strID + '_head" style="padding-left:23px;text-align:center;"></td>' +
'<td class="X_btn_td" onClick="' + strCloseFunc + '"><img src="' + PATH_IMG + 'images/X_btn.gif"></td></tr></table>' +

'</td><td><img src="' + PATH_IMG + 'images/tr_mb.gif"></td></tr>' +
'<tr class="bar_mb" style="height:25px;"><td></td><td></td></tr>' +
'<tr><td class="left">&nbsp;</td><td id="' + strID + '_cont" class="center">' +

'</td><td class="right">&nbsp;</td></tr>' +
'<tr class="bar_mb" style="height:25px;"><td></td><td rowspan="2"><center>' +

'<table cellspacing="0"><tr>' +

strSendBtn + 

'<td>' +
'<div  id="' + strID + '_closebtn" class="mb_btn" onClick="' + strCloseFunc + '" style="' + strBtnsWidth + '">' +
'<div class="c"><div class="l"><div class="r" id="' + strID + '_closebtn_inner">' +
'Close' +
'</div></div></div></div>' +

'</td></tr>' +
'</table>' +

'</center></td><td></td></tr>' +
'<tr><td class="bl_mb"></td><td class="br_mb"></td></tr>' +
'</table>'); 

}




