//*****************************************************************************************//
/* 
Other map JS files will be removed. This file will be converted into a class that will 
feed map data to pages that use maps 
*/
//******************************************************************************************//
var _map;

//var _mgr;
var olay=0;
var ngbhMarkers=new Array();
var _set=0;
var pic_count=0;
var st_p=0;
var trafficInfo;

function load() {
	_map = new GMap2(document.getElementById("map"));
	if (GBrowserIsCompatible()) {
		trafficInfo = new GTrafficOverlay();
		AddTrafficInfo();
		if(_page=="ohplanner")ChangeDateFormat();
		MapByGeocode("-73.970757","40.764472","660 Madison Ave");
	
	}		
	//var _mgr = new GMarkerManager(_map);	
}

function AddTrafficInfo(){
	_map.addOverlay(trafficInfo);
}
//this function will be deprecated soon
function SearchByMap(listingData){
	var aryListingData=new Array();
	aryListingData=listingData.split(',');
	if(aryListingData[15]!="" && aryListingData[15]!=null && aryListingData[15]!="undefined" && aryListingData[15]!=" ")
		SBMGeocode(aryListingData);
	else
		SBMAddress(aryListingData);
}

function ShowListingsOnMap(aryListings){
	SBMGeocode2(aryListings);
}
function ShowNeighborhoodInfoOnMap(ngbhD){
	ngbhMarkers[_set]=new Array();
	ngbhMarkers[_set]['type']=ngbhInfoType;
	ngbhMarkers[_set]['marker']=new Array();
	var locAdr="";
	var marker="";
	var geocoder;
	for (var i=0;i<ngbhD.length;i++){
		if(ngbhD[i][5]!="" && ngbhD[i][5]!=null && ngbhD[i][5]!="undefined" && ngbhD[i][5]!=" " && ngbhD[i][6]!=40.9371){
			var point = new GLatLng(ngbhD[i][6],ngbhD[i][5]);	
			marker=createNgbhInfoMarker(point,ngbhD[i]);
			_map.addOverlay(marker);
			ngbhMarkers[_set]['marker'][i]=marker;
			//_map.panTo((point), SetZoomLevel());
		}
		else{		
			locAdr=ngbhD[i][1]+" "+ngbhD[i][2]+", "+ngbhD[i][3]+" "+ngbhD[i][4];
			geocoder = new GClientGeocoder();
			geocoder.getLatLng(locAdr,
			function(point) {
			  if (!point) {
				alert(locAdr + " not found");
			  } else {
				marker=createNgbhInfoMarker(point,ngbhD[i]);
				//ngbhMarkers[_set]['marker'][i]=marker;
				_map.addOverlay(marker);
			  }
			}
		  );
		}
	}
	_set++;
}
function PlotItineraryOnMap(){
	document.getElementById("divLoading").style.display="block";
	document.getElementById("divMapLoading").style.display="block";
	for (var i=0;i<itinerary_items.length;i++){
		if(itinerary_items[i][15]!="" && itinerary_items[i][15]!=null && itinerary_items[i][15]!="undefined" && itinerary_items[i][15]!=" "){
			var point = new GLatLng(itinerary_items[i][16],itinerary_items[i][15]);
			marker=createItineraryMarker(point,itinerary_items[i]);
			_map.addOverlay(marker);
			if(i==0){
				_map.panTo((point),13)
				marker.openInfoWindowHtml(ListingOpenHtml(itinerary_items[i]));
			}
		}
	}
	PrepareHopStopData(itinerary_items);
}
function PrepareHopStopData(s2){
	document.getElementById("divMapLoading").style.display="none";
	var d= new Array();
	for(var i=0;i<s2.length;i++){
		d[i]=unescape(s2[i][11])+'%'+GetHopStopRegion()+'%'+s2[i][19]+'%'+s2[i][0]+'%'+s2[i][1];
	}
	var end=d;
	SendXmlHttpHopStopRequest(end);
}
function StartDirectionsFromEnd(){
	var d= new Array();
	var s2= new Array();
	s2=itinerary_items;
	s2.reverse();	
	for(var i=0;i<s2.length;i++){
		d[i]=unescape(s2[i][11])+'%'+GetHopStopRegion()+'%'+s2[i][19]+'%'+s2[i][0]+'%'+s2[i][1];
	}
	var end=d;
	document.getElementById("divLoading").style.display="block";
	document.getElementById('TblSearchResults_div').innerHTML="";
	SendXmlHttpHopStopRequest(end);
	var b=document.getElementById("StartLocationImg");
	if(b.getAttribute("key")=="on"){
		b.setAttribute("key","off");
		b.setAttribute("src","/gfx/btn_start_nearest.gif");	
	}
	else{
		b.setAttribute("key","on");
		b.setAttribute("src","/gfx/btn_start_far_away.gif");
	}
}
function DetermineDistance(){
	var x=st_p-itinerary_items[0][20];
	var y=st_p-itinerary_items[itinerary_items.length-1][20];
	if(x>y)itinerary_items.sort(SortByPointDesc);
	return true;
}
function SortByPointAsc(a, b) {
	var x = a[20];
	var y = b[20];
	return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function SortByPointDesc(a, b) {
	var x = a[20];
	var y = b[20];
	return ((x < y) ? 1 : ((x > y) ? -1 : 0));
}
function OfficeMap(Adr,Img,OffName) {
	MapCorcoranOffice(Adr,Img,OffName);
}

function OfficeGroupMap(Adr,city,state,zip,pic,name,long,lat,oid,brgh) {
	var AdrAdr=Adr.split(',');
	var Adrcity=city.split(',');
	var Adrstate=state.split(',');
	var Adrzip=zip.split(',');
	var Adrpict=pic.split(',');
	var AryOffName=name.split('-');
	var AryLong=long.split(',');
	var AryLat=lat.split(',');
	var AryOid=oid.split(',');
	var AryBrgh=brgh.split(',');
	document.getElementById("TblFeatured").style.display='none';
	document.getElementById("TblOfficeLocations").style.display='block';
	//document.write(AryLong.length+' : '+AryLat.length+' : '+Adrcity.length+' : '+Adrstate.length+' : '+Adrzip.length+' : '+Adrpict.length+' : '+AryOffName.length+' : '+AryOid.length+' : '+AryBrgh.length);
	MapByGeocodeb(AryLong,AryLat,AdrAdr,Adrcity,Adrstate,Adrzip,Adrpict,AryOffName,AryOid,AryBrgh);
}
function OfficeGroupMapLI(Adr,city,state,zip,pic,name,long,lat,oid,brgh) {
	var AdrAdr=Adr.split('%47%');
	var Adrcity=city.split('%47%');
	var Adrstate=state.split('%47%');
	var Adrzip=zip.split('%47%');
	var Adrpict=pic.split('%47%');
	var AryOffName=name.split('%47%');
	var AryLong=long.split('%47%');
	var AryLat=lat.split('%47%');
	var AryOid=oid.split('%47%');
	var AryBrgh=brgh.split('%47%');
	document.getElementById("TblFeatured").style.display='none';
	document.getElementById("TblOfficeLocations").style.display='block';
	MapByGeocodeb(AryLong,AryLat,AdrAdr,Adrcity,Adrstate,Adrzip,Adrpict,AryOffName,AryOid,AryBrgh);
}

//Map by Geocode
function MapByGeocode(Long,Lat,Adr) {
	 if (GBrowserIsCompatible()) {
		var point = new GLatLng(Lat, Long);
		_map.addControl(new GOverviewMapControl());
		_map.addControl(new GLargeMapControl());
		_map.addControl(new GMapTypeControl());       		
		_map.setCenter((point), 13);
      }
   }
   
   
 //Map by Geocode
 function MapByGeocodeb(AryLong,AryLat,AdrAdr,Adrcity,Adrstate,Adrzip,Adrpict,AryOffName,AryOid,AryBrgh) {
	var map = new GMap2(document.getElementById("map"));
	var mainpoint = new GLatLng(AryLat[2], AryLong[2]);
	if (GBrowserIsCompatible()) {
		map.addControl(new GOverviewMapControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl()); 
		map.setCenter((mainpoint), 10);
		trafficInfo = new GTrafficOverlay();
		map.addOverlay(trafficInfo);
		
		for (var i = 0; i < AdrAdr.length; i++) {
			if(AryLat[i]!=undefined)			{
				var point = new GLatLng(AryLat[i],AryLong[i]);		 
			 	map.addOverlay(createOfficeGroupMarker(point,AdrAdr[i],Adrcity[i],Adrstate[i],Adrzip[i],AryOffName[i],Adrpict[i],AryOid[i],AryBrgh[i]));
			}				
		}
	}
  }
  
function createOfficeGroupMarker(point,Adr,city,state,zip,name,pic,oid,brgh) {
	//document.write(Adr);
	var icon = new GIcon();
	var mainicon = new GIcon();
	icon.image = "/gfx/map_icon.png";
	mainicon.image = "/gfx/map_icon_20px.png";
	mainicon.shadow = "/gfx/map_icon_20px_shadow.png";
	mainicon.iconSize = new GSize(12, 20);
	mainicon.iconAnchor = new GPoint(8, 8);
	mainicon.infoWindowAnchor = new GPoint(8, 1);
	icon.iconSize = new GSize(14, 14);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
	//document.write(AdrAdr[5]);
	//marker.openInfoWindowHtml("dfsdfsd");
    marker.openInfoWindowHtml(OfficeAddrHtmlGroup(Adr,city,state,zip,name,pic,oid,brgh));
  });
  return marker;
}

function MapByAddress(Adr,ngbh) {
	var map = new GMap2(document.getElementById("map"));
	var geocoder = new GClientGeocoder();
  geocoder.getLatLng(Adr,
    function(point) {
      if (!point) {
        alert(unescape(Adr) + " not found");
      } else {
        map.setCenter(point, 15);
        map.addControl(new GOverviewMapControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());       		
		map.setCenter((point), 15);
  		map.addOverlay(new GMarker(point));
		map.openInfoWindowHtml(map.getCenter(),ngbh);
      }
    }
  );
}

function SBMGeocode(aryListingData){	
	var point = new GLatLng(aryListingData[16], aryListingData[15]);
	//browser compatibility has already been checked
	_map.panTo((point), 13);
	//_map.addOverlay(createSBMMarker(point,aryListingData));	//all markers already created
	_map.openInfoWindowHtml(point,DefaultListingHtml(aryListingData));
}

function CRemoveOverlays()
{
	for (var i=0;i<_map.overlays.length;i++)
	{
		_map.removeOverlay(_map.overlays[i]);
	}
}
function clearMap()
{
    if(_map != null){
	_map.clearOverlays();
	AddTrafficInfo();
	}
}
function SBMGeocode2(aryListingsData){	
	for (var i=0;i<aryListingsData.length;i++){
		if(aryListingsData[i][15]!="" && aryListingsData[i][15]!=null && aryListingsData[i][15]!="undefined" && aryListingsData[i][15]!=" ")
		{
			var point = new GLatLng(aryListingsData[i][16],aryListingsData[i][15]);	
			_map.addOverlay(createSBMMarker(point,aryListingsData[i]));
			_map.panTo((point), SetZoomLevel());
		}
		else{			
			SBMAddress2(aryListingsData[i]);
		}
	}
	AddTrafficInfo();
}

function SetZoomLevel()
{
	var zLevel;
	switch (subRequest)
	{
		case "manhattan":////starting point: 660 madison ave office
			zLevel=(_page="ohplanner")?4:9;
			break;
		case "NYC":////starting point: 660 madison ave office
			zLevel=(_page="ohplanner")?4:9;
			break;
		case "brooklyn"://starting point: the 125 Seventh Avenue office
			zLevel=9;
			break;
		case "queens"://starting point: some point in the middle of queens
			zLevel=9;
			break;
		case "palmbeach"://starting point: the 340 Royal Poinciana Plaza office
			zLevel=8;
			break;
		case "FL"://starting point: the 340 Royal Poinciana Plaza office
			zLevel=8;
			break;
		case "hamptons":// starting point: the 78 Main Street office
			zLevel=6;
			break;
		case "LI":// starting point: the 78 Main Street office
			zLevel=6;
			break;
	}
	return zLevel;
}

function SBMAddress(aryListingData){
	var geocoder = new GClientGeocoder();
	var adr=(aryListingData[11]!=aryListingData[17])?aryListingData[11]+", "+aryListingData[17]+", "+GetAdrRegion()+" "+aryListingData[19]:aryListingData[17]+", "+GetAdrRegion()+" "+aryListingData[19];
	
  geocoder.getLatLng(adr,
    function(point) {
      if (!point) {
        alert(unescape(adr) + " not found");
      } else {
        _map.panTo(point, 13);
        _map.addControl(new GOverviewMapControl());
		_map.addControl(new GLargeMapControl());
		_map.addControl(new GMapTypeControl());       		
		_map.addOverlay(createSBMMarker(point,aryListingData));	//markers
		_map.openInfoWindowHtml(point,DefaultListingHtml(aryListingData));
      }
    }
  );
}

function SBMAddress2(aryListingData){
	var geocoder = new GClientGeocoder();
	var adr=(aryListingData[11]!=aryListingData[17])?aryListingData[11]+", "+aryListingData[17]+", "+GetAdrRegion()+" "+aryListingData[19]:aryListingData[17]+", "+GetAdrRegion()+" "+aryListingData[19];
	//alert(adr);
  geocoder.getLatLng(adr,
    function(point) {
      if (!point) {
        alert(unescape(adr) + " not found");
      } else {
		_map.addOverlay(createSBMMarker(point,aryListingData));	//markers
      }
    }
  );
}

// Creates Search By Map marker at the given point 
function createSBMMarker(point,aryListingData){
	var icon = new GIcon();
	var mainicon = new GIcon();
  	icon.image = "/gfx/map_icon.png";
	mainicon.image = "/gfx/map_icon_20px.png";
	mainicon.shadow = "/gfx/map_icon_20px_shadow.png";
	mainicon.iconSize = new GSize(12, 20);
	mainicon.iconAnchor = new GPoint(8, 8);
	mainicon.infoWindowAnchor = new GPoint(8, 1);
	icon.iconSize = new GSize(14, 14);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(DefaultListingHtml(aryListingData));
  });
  return marker;
}
function createStartMarker(point,stAdr){
	var icon = new GIcon();
	var mainicon = new GIcon();
  	icon.image = "/gfx/map_icons/start.png";
	icon.shadow = "/gfx/map_icon_20px_shadow.png";
	icon.iconSize = new GSize(20, 34);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	/*
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(DefaultListingHtml(aryListingData));
  });
	*/
  return marker;
}
// Creates Search By Map marker at the given point 
function createNgbhInfoMarker(point,ngbhD){
	var icon = new GIcon();
	icon.image = LocateOnIcon(ngbhInfoType);
	icon.iconSize = new GSize(14, 14);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(NgbhInfoMrkHtml(ngbhD));
  });
  return marker;
}
function createItineraryMarker(point,it_item){
	var icon = new GIcon();
  	icon.image = "/gfx/map_icons/iconb"+(pic_count+1)+".png";
	icon.shadow = "/gfx/map_icon_20px_shadow.png";
	icon.iconSize = new GSize(20, 34);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	pic_count++;
	
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(ListingOpenHtml(it_item));
 	});
	
	return marker;
}
function StartAddress(response){

	var icon = new GIcon();
	var mainicon = new GIcon();
  	icon.image = "/gfx/map_icons/start.png";
	icon.shadow = "/gfx/map_icon_20px_shadow.png";
	icon.iconSize = new GSize(20, 34);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	clearMap();
	if (!response || response.Status.code != 200) {
        //alert("Address not found.\nPlease check the address and try again.");
      } else {
        place = response.Placemark[0];
        
        point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
       	marker = new GMarker(point,icon);
		_map.addOverlay(marker);
		st_p=place.Point.coordinates[0]+place.Point.coordinates[1];
		itinerary_items.sort(SortByPointAsc);		
		
        //marker.openInfoWindowHtml(place.address + '<br>' +
         // '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
      }
	  if(DetermineDistance())PlotItineraryOnMap();
}

function GetStartPoint() {
	var geocoder = new GClientGeocoder();
    geocoder.getLocations(startingAdr, StartAddress);
 }
function RemoveMarker(id){
	document.getElementById("divMapLoading").style.display="block";
	for(var i=0;i<ngbhMarkers.length;i++){
		if(ngbhMarkers[i]['type']==id){
			for(var j=0;j<ngbhMarkers[i]['marker'].length;j++){
				 _map.removeOverlay(ngbhMarkers[i]['marker'][j]);
			}
		}
	}
	document.getElementById("divMapLoading").style.display="none";
}
function LocateOnIcon(imgTag)
{
	var imagePath="";
	switch(imgTag)
	{
		case "Bars":
			imagePath="/gfx/map_icons/Icon_Bar.gif";
			break;
		case "Banks":
			imagePath="/gfx/map_icons/Icon_Bank.gif";
			break;
		case "book":
			imagePath="/gfx/map_icons/Icon_Bookstore.gif";
			break;
		case "Delicatessens":
			imagePath="/gfx/map_icons/Icon_GroceryStore.gif";
			break;
		case "Laundries":
			imagePath="/gfx/map_icons/Icon_Laundry.gif";
			break;
		case "Pharmacies":
			imagePath="/gfx/map_icons/Icon_Pharmacy.gif";
			break;
		case "Post Offices":
			imagePath="/gfx/map_icons/Icon_PostOffice.gif";
			break;
		case "Restaurants":
			imagePath="/gfx/map_icons/Icon_Restaurants.gif";
			break;
		case "theatres":
			imagePath="/gfx/map_icons/Icon_Movies.gif";
			break;
		case "Health Clubs":
			imagePath="/gfx/map_icons/Icon_HealthClub.gif";
			break;
		default:
			imagePath="/gfx/map_icon.png";
			break;
	}
	return imagePath;
}
function LocateOffIcon(imgTag)
{
	var imagePath="";
	switch(imgTag)
	{
		case "Bars":
			imagePath="/gfx/map_icons/Icon_BarOff.gif";
			break;
		case "Banks":
			imagePath="/gfx/map_icons/Icon_BankOff.gif";
			break;
		case "book":
			imagePath="/gfx/map_icons/Icon_BooksOff.gif";
			break;
		case "Delicatessens":
			imagePath="/gfx/map_icons/Icon_GroceryOff.gif";
			break;
		case "Laundries":
			imagePath="/gfx/map_icons/Icon_LaundryOff.gif";
			break;
		case "Pharmacies":
			imagePath="/gfx/map_icons/Icon_PharmacyOff.gif";
			break;
		case "Post Offices":
			imagePath="/gfx/map_icons/Icon_PostOff.gif";
			break;
		case "Restaurants":
			imagePath="/gfx/map_icons/Icon_RestaurantsOff.gif";
			break;
		case "theatres":
			imagePath="/gfx/map_icons/Icon_MoviesOff.gif";
			break;
		case "Health Clubs":
			imagePath="/gfx/map_icons/Icon_HealthOff.gif";
			break;
		default:
			imagePath="/gfx/map_icon.png";
			break;
	}
	return imagePath;
}
// Creates office marker at the given point 
function createOfficeMarker(point,strAddr,strCity,strState,strZip,OffName1,OffName2,strPict) {
	var icon = new GIcon();
	var mainicon = new GIcon();
  	icon.image = "/gfx/map_icon.png";
	mainicon.image = "/gfx/map_icon_20px.png";
	mainicon.shadow = "/gfx/map_icon_20px_shadow.png";
	mainicon.iconSize = new GSize(12, 20);
	mainicon.iconAnchor = new GPoint(8, 8);
	mainicon.infoWindowAnchor = new GPoint(8, 1);
	icon.iconSize = new GSize(14, 14);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(OfficeAddrHtml(strAddr,strCity,strState,strZip,OffName1,OffName2,strPict));
  });
  return marker;
}

function createSchoolMarker(point,innertext)
{
	var icon = new GIcon();
	var mainicon = new GIcon();
  	icon.image = "/gfx/map_icon.png";
	mainicon.image = "/gfx/map_icon_20px.png";
	mainicon.shadow = "/gfx/map_icon_20px_shadow.png";
	mainicon.iconSize = new GSize(12, 20);
	mainicon.iconAnchor = new GPoint(8, 8);
	mainicon.infoWindowAnchor = new GPoint(8, 1);
	icon.iconSize = new GSize(14, 14);
	icon.iconAnchor = new GPoint(8, 8);
	icon.infoWindowAnchor = new GPoint(8, 1);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowHtml(innertext);
   
  });
  return marker;
}
function MapSchoolByZip(zip,innertext,zoom) {
	var gt=zoom+"";
      if (GBrowserIsCompatible() ){
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
        //alert(zip+','+gt);
		showSchoolInfo(zip,innertext,zoom)
      }
    }
	
function showSchoolInfo(zip,innertext,zoom) {
     var zm;//=parseInt(zoom); 
    
	 if(!isNaN(zoom)){zm=zoom;}
	 if (geocoder) {
        geocoder.getLatLng(
          zip,
          function(point) {
            if (!point) {
              //alert(zip + " not found");
            } else {
           // alert(zip + " is ME");				
              map.setCenter(point, zm);
			   map.addControl(new GOverviewMapControl(new GSize(100,100)));
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());  
              var marker = new GMarker(point);
              map.addOverlay(createSchoolMarker(point,innertext));
              //map.addOverlay(tf);
			 map.openInfoWindowHtml(map.getCenter(),innertext);
            }
          }
        );
      }
	 //var tf=new GTrafficOverlay(); 
	//map.addOverlay(tf);
 }
	
function showLocation(addr) {
	var address = addr;
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	geocoder = new GClientGeocoder();     
    geocoder.getLocations(address, addAddressToMap);
 }
	
function addAddressToMap(response) {
	map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
        marker = new GMarker(point);
		map.setCenter((point), 13);
		map.addOverlay(createSchoolMarker(point));
		map.addTLabel(CustomLabel(innertext,place.Point.coordinates[1],place.Point.coordinates[0]));
      }
    }
function CustomLabel(innertext,lat,long)
{
	var contentDiv = '<div style="padding: 0px 0px 8px 8px; no-repeat bottom left;border:1px; background-color:#ffffff;border-style:solid;border-color:#3a3a3a">';
	contentDiv +='<div class="text11px" style="background-color: #ffffff; padding: 2px; font-size: 0.7em;">';
	contentDiv +='<nobr>'+innertext+'<br><a onclick="removeT()">close</a></nobr>';
	contentDiv +='</div></div>';
	var label = new TLabel();
	label.id = 'Details';
	label.anchorLatLng = new GLatLng (lat,long);
	label.anchorPoint = 'bottomLeft';
	label.content = contentDiv;
	label.percentOpacity = 60;
	return label;
}
function removeT()
{
	map.removeTLabel(label);
}

function ChangeMapLocation(type)
{
	//set default locations for each regions
	var long;
	var lat;
	var zLevel=SetZoomLevel();
	switch (type)
	{
		case "manhattan":////starting point: 660 madison ave office
			long="-73.970757";
			lat="40.764472";		
			zLevel;
			break;
		case "NYC":////starting point: 660 madison ave office
			long="-73.970757";
			lat="40.764472";
			zLevel;
			break;
		case "brooklyn"://starting point: the 125 Seventh Avenue office
			long="-73.976014";
			lat="40.673323";
			zLevel;
			break;
		case "queens"://starting point: some point in the middle of queens
			long="-73.820571";
			lat="40.7787216";
			zLevel;
			break;
		case "palmbeach"://starting point: the 340 Royal Poinciana Plaza office
			long="-80.041148";
			lat="26.717063";
			zLevel;
			break;
		case "FL"://starting point: the 340 Royal Poinciana Plaza office
			long="-80.041148";
			lat="26.717063";	
			zLevel;
			break;
		case "hamptons":// starting point: the 78 Main Street office
			long="-72.186653";
			lat="40.962062";	
			zLevel;
			break;
		case "LI":// starting point: the 78 Main Street office
			long="-72.186653";
			lat="40.962062";	
			zLevel;
			break;
	}
	_map.panTo(new GLatLng(lat, long), zLevel);
}
function MapSchoolSmall(zip,innertext,zoom) {
	 
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
		showSchoolSmall(zip,innertext,zoom)
      }
    }
	
function showSchoolSmall(zip,innertext,zoom) {
     var zm;//=parseInt(zoom);
	 var bounds = new GLatLngBounds();
	 var offst=new GSize(25,-20);
	 if(!isNaN(zoom))
	 {
		zm=zoom;
	}
	 if (geocoder) {
        geocoder.getLatLng(
          zip,
          function(point) {
            if (!point) {
              alert(zip + " not found");
            } else {			
			 //place = response.Placemark[0];
			 bounds.extend(point);
              map.setCenter(point, zm);
			  map.addControl(new GSmallMapControl());
			  var marker = new GMarker(point);
              map.addOverlay(createSchoolMarker(point,innertext));
              map.openInfoWindowHtml(map.getCenter(),innertext,offst);
            }
          }
        );
      }
	//var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
	//var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
	//map.setCenter(new GLatLng(clat+40,clng-75),zm);
	  //geocoder2 = new GClientGeocoder();
	  // geocoder2.getLocations(zip, addAddressToMap2);
    }
/*
function addAddressToMap2(response) {
	map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
		var clat = place.Point.coordinates[1];
		var clng = (place.Point.coordinates[0])-.05;
		map.setCenter(new GLatLng(clat,clng),13);
        //marker = new GMarker(point);
		//map.setCenter((point), 13);
		//map.addOverlay(createSchoolMarker(point));
		//map.addTLabel(CustomLabel(innertext,place.Point.coordinates[1],place.Point.coordinates[0]));
      }
    }
*/
function schoolwindow(innertext)
{
	var t=innertext.split('And');
	var h=t[0]+"<br>"+t[1];
	return h;
}

function MapCorcoranOffice(Adr,Pict,OffName) {
	var map = new GMap2(document.getElementById("map"));
	var geocoder = new GClientGeocoder();
	var AdrAry=Adr.split(',');//AdrAry[0]=address//AdrAry[1]=city//AdrAry[2]=state//AdrAry[3]=zip
	var AryOffName=OffName.split('-');//AryOffName[0]='Title'//AryOffName[1]=ngbh
	var newAdr=AdrAry[0]+", "+AdrAry[2]+", "+AdrAry[3];
	AryOffName[1]=(AryOffName[1]==undefined)?"":"<br>"+AryOffName[1];
	Adr=Adr.replace('Main Street,Amagansett',"Montauk Highway,Amagansett");
	Adr=Adr.replace('14 East Main Street',"14 East Montauk Highway");
	//document.write(Adr);
	geocoder.getLatLng(Adr,
    function(point) {
      if (!point) {
        //alert(Adr + " not found");
      } else {
        map.setCenter(point, 14);
        map.addControl(new GOverviewMapControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());       		
		map.setCenter((point), 14);
		map.addOverlay(createOfficeMarker(point,AdrAry[0],AdrAry[1],AdrAry[2],AdrAry[3],AryOffName[0],AryOffName[1],Pict));
		trafficInfo = new GTrafficOverlay();
		map.addOverlay(trafficInfo);
		map.openInfoWindowHtml(map.getCenter(),OfficeAddrHtml(AdrAry[0],AdrAry[1],AdrAry[2],AdrAry[3],AryOffName[0],AryOffName[1],Pict));
      }
    }
  );		
}

function MapCorcoranOfficeGroup(Adr,city,state,zip,pic,name) {

	
	//createOfficeMarker(point,strAddr,strCity,strState,strZip,OffName1,OffName2,strPict)
	var map = new GMap2(document.getElementById("map"));
	
	var geocoder;
	map.addControl(new GOverviewMapControl());
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());	
	for(var i=0;i<AdrAdr.length;i++)
	{
		//document.write(AdrAdr[1]+", "+Adrcity[1]+", "+Adrstate[1]+", "+Adrzip[1]+", "+AryOffName[1]+", "+AryOffName[1]+", "+Adrpict[1]);
		geocoder = new GClientGeocoder();
		geocoder.getLatLng(AdrAdr[i]+", "+Adrcity[i]+", "+Adrstate[i]+" "+Adrzip[i],
			function(point) {
			  if (!point) {
				  if(AdrAdr[i]!=undefined){
						alert(AdrAdr[i] + " not found");	  
				  }				
			  } else {
				map.setCenter((point), 10);
				map.addOverlay(createOfficeGroupMarker(point,Adr,city,state,zip,name,'',pic,i));
				map.openInfoWindowHtml(map.getCenter(),AryOffName[2]);
			  }
			}
		 );	
	}
 }


function OfficeAddrHtml(strAddr,strCity,strState,strZip,OffName1,OffName2,strPict)
{
	//document.write(strAddr);
	var modifiedAdr=strAddr+" "+strCity+", "+strState+" "+strZip;//will be sent to google to get directions
	var ns="";
	if(strPict!="")
	{
		ns='<img src=/aboutus/gfx/'+strPict+' width=90 height=67 border="0" OnError="ImageLoadFailedSm()">';
	}
	var AddrHtml;
	AddrHtml='<div id=divListing style="padding-right:11px;"><table><tr><td>';
	AddrHtml+='';
	AddrHtml+=ns+'</td>';
	AddrHtml+='<td vAlign=top class=text11px>';
	AddrHtml+='<b>'+OffName1+'</b>';
	AddrHtml+='<b>'+OffName2+'</b>';
	AddrHtml+='<br>'+strAddr;
	AddrHtml+='<br>'+strCity+'';
	AddrHtml+='<br>'+strState+', '+strZip;
	AddrHtml+='<br></td>';
	AddrHtml+='</tr><tr><td colspan=2 class=text10px>';
	AddrHtml+='Get Directions: <a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'to\',\''+modifiedAdr+'\')">To Here</a> | ';
	AddrHtml+='<a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'from\',\''+modifiedAdr+'\')">From Here</a></td>';
	AddrHtml+='</tr>';
	AddrHtml+='<table><tr height="1"><td height="5" id="srch_td1" vAlign="top">';
	AddrHtml+='</td><td height="1" id="srch_td2" vAlign="top"></td></tr></table>';
	AddrHtml+='</tr></table></div>';
	return AddrHtml;
}

function OfficeAddrHtmlGroup(strAddr,strCity,strState,strZip,OffName,strPict,strOid,strBrgh)
{
	var AddrHtml;
	var modifiedAdr=strAddr+" "+strCity+", "+strState+" "+strZip;//will be sent to google to get directions
	var ns="";
	if(strPict!="")	{
		ns='<a class="graylink" href="/aboutus/index.aspx?page=OfficeLocations&b='+strBrgh+'&OID='+strOid+'"><img src=/aboutus/gfx/'+strPict+' width=90 height=67 border="0" OnError="ImageLoadFailedSm()"></a>';
	}
	
	AddrHtml='<div id=divListing style="padding-right:11px;"><table><tr><td>';
	AddrHtml+='';
	AddrHtml+=ns+'</td>';
	AddrHtml+='<td vAlign=top class=text11px>';
	AddrHtml+='<b><a class="graylink" href="/aboutus/index.aspx?page=OfficeLocations&b='+strBrgh+'&OID='+strOid+'">The Corcoran Group</a><br></b>';
	AddrHtml+='<b><a class="graylink" href="/aboutus/index.aspx?page=OfficeLocations&b='+strBrgh+'&OID='+strOid+'">'+OffName+'</a></b>';
	AddrHtml+='<br>'+strAddr;
	AddrHtml+='<br>'+strCity+'';
	AddrHtml+='<br>'+strState+', '+strZip;
	AddrHtml+='<br></td>';
	AddrHtml+='</tr><tr><td colspan=2 class=text10px>';
	AddrHtml+='Get Directions: <a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'to\',\''+modifiedAdr+'\')">To Here</a> | ';
	AddrHtml+='<a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'from\',\''+modifiedAdr+'\')">From Here</a></td>';
	AddrHtml+='</tr>';
	AddrHtml+='<table><tr height="1"><td height="5" id="srch_td1" vAlign="top">';
	AddrHtml+='</td><td height="1" id="srch_td2" vAlign="top"></td></tr></table>';
	AddrHtml+='</tr></table></div>';
	return AddrHtml;
}
function NgbhInfoMrkHtml(ngbhD){
	var html="<div><table><tr><td class='text11px'>";	
	html+="<b>"+changeCase(ngbhD[0])+"</b><br>"+changeCase(ngbhD[1])+"<br>"+changeCase(ngbhD[2])+", "+changeCase(ngbhD[3])+" "+ngbhD[4];
	html+="</td></tr></table></div>"; 
	return html;
}
function DefaultListingHtml(aryListingData)
{
	//alert('HTML');
	
	//alert(aryListingData[20]);
	//alert(aryListingData[23]);
	
	var var1="",var2="",var3="",var4="";
	
	var VOhDate="";
	if(aryListingData[23].toString() != ""){
	if(aryListingData[23].toString() != " "){
	var1 = aryListingData[23].toString().substring(0,4);
	var2 = aryListingData[23].toString().substring(5,7);
	var3 = aryListingData[23].toString().substring(8,10);
	//alert(var1);
	//alert(var2);
	//alert(var3);
	VOhDate = var2 + '/' +var3+'/'+ var1 + ' 12:00:00 AM';
	}
	}
	//alert(VOhDate);
	
	var flg = 0;
	var LHtml;
	var pic="";
	var opnhse="";
	var infoRow1="";//rooms
	var infoRow2="";//beds//units
	var infoRow3="";//baths
	var infoRow4="";//floors
	var infoRow5="";//property type
	var OhItLink="";
	var modifiedAdr=(GetRegion()=="FL")?aryListingData[11]+", "+aryListingData[17]+", "+GetAdrRegion():aryListingData[11]+" "+aryListingData[19];
	//var modifiedAdr=aryListingData[11]+" "+aryListingData[8]+", "+aryListingData[8]+" "+aryListingData[8];//will be sent to google to get directions
	//'&nbsp;&nbsp;&nbsp;'+
	if(document.URL.toLowerCase().match("openhouseplanner")){
	infoRow1=(aryListingData[8]!=undefined && aryListingData[8]!=" ")?'<br>&nbsp;&nbsp;'+aryListingData[8]+' Rooms':"";	//first row	
	}
	else
	{
	infoRow1=(aryListingData[8]!=undefined && aryListingData[8]!=" ")?'<br>'+aryListingData[8]+' Rooms':"";	//first row	
	}
	if(aryListingData[3]!=undefined && aryListingData[3]!=" "){//second row
		//infoRow2='<br>'+aryListingData[3]+' Beds';
		if(document.URL.toLowerCase().match("openhouseplanner")){
		infoRow2='<br>'+'&nbsp;&nbsp;'+aryListingData[3]+' Beds';
		}
		else
		{
		infoRow2=aryListingData[3]+' Beds';
		}
		
	}else if(aryListingData[5]!=undefined && aryListingData[5]!=" "){
		//infoRow2='<br>'+aryListingData[5]+' Units';
		if(aryListingData[3]!=undefined || aryListingData[3]!=" "){
		    if(document.URL.toLowerCase().match("openhouseplanner"))
    		    infoRow2='<br>'+'&nbsp;'+aryListingData[5]+' Units';
		    else
		    infoRow2=aryListingData[5]+' Units';
		        
		}
		else
		{
		
		       if(document.URL.toLowerCase().match("openhouseplanner"))
		            {
		                
		                if((aryListingData[8]!=undefined && aryListingData[8]!=" "))
                            infoRow2='<br>'+'&nbsp;&nbsp;'+aryListingData[5]+' Units';
                        else
    		                infoRow2='&nbsp;&nbsp;'+aryListingData[5]+' Units';

		   //else
		   //{
		    //if((aryListingData[8]==undefined && aryListingData[8]==" "))
		     //infoRow2=aryListingData[5]+' Units';
		   //}
	                }
	                else
		            {
		                if((aryListingData[8]!=undefined && aryListingData[8]!=" "))
		                     infoRow2='<br>'+aryListingData[5]+' Units';
		                else
		                   infoRow2=aryListingData[5]+' Units';
		            }
		//else{
		//infoRow2=aryListingData[5]+' Units';
		  //  }
		}

      }
	 else
	    infoRow2="";
	    
	if(document.URL.toLowerCase().match("openhouseplanner")){
	infoRow3=(aryListingData[4]!=undefined && aryListingData[4]!=" ")?'<br>&nbsp;&nbsp;'+aryListingData[4]+' Baths':"";	//baths	
	}
	else
	{
	infoRow3=(aryListingData[4]!=undefined && aryListingData[4]!=" ")?'<br>'+aryListingData[4]+' Baths':"";	//baths	
	}
	
	if(document.URL.toLowerCase().match("openhouseplanner")){
	infoRow4=(aryListingData[6]!=undefined && aryListingData[6]!=" ")?'<br>&nbsp;&nbsp;'+aryListingData[6]+' Floors':"";	//floors	
	}
    else
	{
	infoRow4=(aryListingData[6]!=undefined && aryListingData[6]!=" ")?'<br>'+aryListingData[6]+' Floors':"";	//floors	
    }
	if(document.URL.toLowerCase().match("openhouseplanner")){
	infoRow5=(aryListingData[7]!=undefined && aryListingData[7]!=" ")?'<br>&nbsp;&nbsp;'+aryListingData[7]:"";//property type	
	}
	else
	{
		infoRow5=(aryListingData[7]!=undefined && aryListingData[7]!=" ")?'<br>'+aryListingData[7]:"";//property type	
	}
	
	if(aryListingData[18]!=undefined && aryListingData[18]!=null && aryListingData[18]!="" && aryListingData[18]!=" ")	{
		var opnhse_t=new Array();
		opnhse_t=aryListingData[18].split('<br>');
		opnhse='<font color="#FF0000"><b>Openhouse:</b>';
		opnhse+='<br>'+opnhse_t[0]+'</font>';
	}	
	if(aryListingData[1]!=" " && aryListingData[1]!=undefined)	{
		pic='<img src='+aryListingData[1]+' style="border-style:solid;border-width:1px;border-color:#666666;" width="140" height="98" border="0" OnError="ImageLoadFailedSm()">';
	}
	OhItLink=(document.URL.toLowerCase().match("openhouseplanner"))?"<div style=\"height:2px;line-height:2px;\"></div><div class='text10px' id='div_itMap_"+aryListingData[0]+"'>"+MapItineraryDivDisplay(aryListingData,'div_itMap_'+aryListingData[0])+"</div>":"";
	
	if(aryListingData[20])
	{
	if(aryListingData[21])
	{
	if(aryListingData[22])
	{
	flg = 1;
	}
	else
	flg = 0;
	}
	else
	 flg = 0;
	
	}
	else
	  flg = 0;
	//if(document.URL.toLowerCase().match("openhouseplanner"))
	
	LHtml='<div id=divListing style="padding-right:1px;"><table cellspacing="0" cellpadding="0"><tr><td>';
	LHtml+='<table border="0" cellspacing="0" cellpadding="0"><tr class=text11px><td vAlign=top>';
	LHtml+='<a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'&OhDat='+VOhDate+';">'+unescape(aryListingData[11])+'</a>';
	LHtml+='<br><strong>'+aryListingData[17]+'</strong>';
	//LHtml+='</td><td vAlign=top><table class=text11px cellspacing="0" cellpadding="0" border="1"><tr><td vAlign=top><b>'+FormatPrice(aryListingData[9])+'</td></tr><tr><td vAlign=top>'+infoRow1+'</td></tr></table></td></tr>';//<tr><td>'+infoRow2+'</td></tr><tr><td>'+infoRow3+'</td></tr><tr><td>'+infoRow4+'</td></tr><tr><td>'+infoRow5+'</td></tr></table></td></tr>';
	if(document.URL.toLowerCase().match("openhouseplanner")){

	LHtml+='</td><td class=text11px><a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'&OhDat='+VOhDate+';">&nbsp;&nbsp;View Listing</a>';
    LHtml+='<br><a style="cursor:pointer;" class="graylink" onclick="SearchForSimilarListings('+aryListingData[0]+');">&nbsp;&nbsp;View Similar</a></td></tr>';
    }
    if(!document.URL.toLowerCase().match("openhouseplanner")){

    LHtml+='<td vAlign=top><b>'+FormatPrice(aryListingData[9])+'</b>'+infoRow1+'</td></tr>';//<tr><td>'+infoRow2+'</td></tr><tr><td>'+infoRow3+'</td></tr><tr><td>'+infoRow4+'</td></tr><tr><td>'+infoRow5+'</td></tr></table></td></tr>';
	}
	LHtml+='<tr class=text11px><td vAlign=top>';
	LHtml+='<a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'&OhDat='+VOhDate+';">'+pic+'</a>';
	LHtml+=OhItLink;
	LHtml+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
	if(document.URL.toLowerCase().match("openhouseplanner")){

	LHtml+='<td vAlign=top><br>';
	LHtml+='&nbsp;&nbsp;<b>'+FormatPrice(aryListingData[9])+'</b>';
	LHtml+=infoRow1;//rooms
	LHtml+=infoRow2;//beds//units
	LHtml+=infoRow3;//baths
	LHtml+=infoRow4;//floors
	LHtml+=infoRow5;
	LHtml+='</td>';
	}
	if(!document.URL.toLowerCase().match("openhouseplanner")){

	LHtml+='<td vAlign="top"><table border="0" cellpadding="2" cellspacing="0"><tr class=text11px><td vAlign="top">';
	//LHtml+='<b>'+FormatPrice(aryListingData[9])+'</b>';
	//LHtml+=infoRow1;//rooms
	
	LHtml+=infoRow2;//beds//units
	//LHtml+='</td></tr><tr class=text11px><td vAlign=top>';
	LHtml+=infoRow3;//baths
	//LHtml+='</td></tr><tr class=text11px><td vAlign=top>';
	//if(infoRow4 != " "){
	LHtml+=infoRow4;//floors
	//LHtml+='</td></tr><tr class=text11px><td vAlign=top>';
	//LHtml+='</td><tr><td>';
	//}

	LHtml+=infoRow5;	//proptype
	LHtml+='</td></tr><tr class=text11px><td vAlign=top>';

	if(aryListingData[20] != " " && aryListingData[21]!=" " && aryListingData[22] != " ")
	{
	if(flg == 1){
	
	var weathDesc = getDesc(aryListingData[22]);
	
	LHtml+='<table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="/property/new_icons/blnk.jpg" width="40" height="10"></td></tr><tr class=text11px><td rowspan="3" vAlign=top><img src="/property/new_icons/'+aryListingData[22]+'.jpg" width="40" height="40"></td>';
	LHtml+= '<td vAlign=top rowspan="3"><img src="/property/new_icons/blnk1.jpg" height="20" width="10" border="0"></td>';
	LHtml+= '<td vAlign=top>'+ aryListingData[20] + '&#176;';
	LHtml+='&nbsp;|&nbsp;';
	LHtml+= aryListingData[21] + "&#176;"+' &nbsp; </td></tr>';
	LHtml+='<tr class=text11px><td vAlign=top><b>'+weathDesc+'</b></td></tr><tr><td><img src="/property/new_icons/blnk.jpg" width="40" height="20"></td></tr></table>';
	}
	}
	LHtml+='</td></tr></table></td></tr>';
	LHtml+='<tr><td class=text11px><a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'&OhDat='+VOhDate+';">View Listing</a>&nbsp; | &nbsp;';
    LHtml+='<a style="cursor:pointer;" class="graylink" onclick="SearchForSimilarListings('+aryListingData[0]+');">View Similar</a></td></tr>';
	}

	LHtml+='<tr style="height:1px;" class=text10px><td colspan="2">';
	LHtml+=opnhse;
	LHtml+='</td></tr>';
	LHtml+='<tr><td colspan=2 class=text10px>';
	LHtml+='Get Directions: <a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'to\',\''+modifiedAdr+'\')">To Here</a> | ';
	LHtml+='<a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'from\',\''+modifiedAdr+'\')">From Here</a></td>';
	LHtml+='</tr>';
	LHtml+='<table><tr height="1"><td height="9" id="srch_td1" vAlign="top">';
	LHtml+='</td><td height="1" id="srch_td2" vAlign="top"></td></tr></table>';
	LHtml+='</td></tr></table></div>';
	return LHtml;
}

function getDesc(strDsc)
    {
        var strDescp = strDsc;
        var strRetDesc = "";

        switch (strDescp)
        {
            case "65":
                {
                    strRetDesc = "Mostly Sunny";
                }
                break;
            case "66":
                {
                    strRetDesc = "Partly Cloudy";
                }
                break;
            case "67":
                {
                    strRetDesc = "Cloudy";
                }
                break;
            case "68":
                {
                    strRetDesc = "Dust";
                }
                break;
            case "69":
                {
                    strRetDesc = "Most Cloudy";
                }
                break;
            case "70":
                {
                    strRetDesc = "Foggy";
                }
                break;
            case "71":
                {
                    strRetDesc = "Hot";
                }
                break;
            case "72":
                {
                    strRetDesc = "Hazy";
                }
                break;
            case "73":
                {
                    strRetDesc = "Very Cold";
                }
                break;
            case "74":
                {
                    strRetDesc = "Snow Shower";
                }
                break;
            case "75":
                {
                    strRetDesc = "Smoke";
                }
                break;
            case "76":
                {
                    strRetDesc = "Drizzle";
                }
                break;
            case "77":
                {
                    strRetDesc = "Flurries";
                }
                break;
            case "78":
                {
                    strRetDesc = "Windy";
                }
                break;
            case "79":
                {
                    strRetDesc = "Mixed";
                }
                break;
            case "80":
                {
                    strRetDesc = "Blizzard";
                }
                break;
            case "81":
                {
                    strRetDesc = "Blowing Snow";
                }
                break;
            case "82":
                {
                    strRetDesc = "Rain";
                }
                break;
            case "83":
                {
                    strRetDesc = "Snow";
                }
                break;
            case "84":
                {
                    strRetDesc = "Thunder Storm";
                }
                break;
            case "85":
                {
                    strRetDesc = "Sunny";
                }
                break;
            case "87":
                {
                    strRetDesc = "Showers";
                }
                break;
            case "88":
                {
                    strRetDesc = "Sleet";
                }
                break;
            case "89":
                {
                    strRetDesc = "Freezing Rain";
                }
                break;
            case "90":
                {
                    strRetDesc ="Freezing Drizzle";
                }
                break;
            case "91":
                {
                    strRetDesc = "Rain/Sun";
                }
                break;
            case "92":
                {
                    strRetDesc = "Sun/Rain";
                }
                break;
            case "93":
                {
                    strRetDesc = "Sun/Thunderstorm";
                }
                break;
            case "94":
                {
                    strRetDesc = "Thunderstorm/Sun";
                }
                break;
            default:
                break;

        }
        return strRetDesc;
    }
    
    
function ListingOpenHtml(aryListingData)
{
	var LHtml;
	var pic="";
	var opnhse="";
	var infoRow1="";//rooms
	var infoRow2="";//beds//units
	var infoRow3="";//baths
	var infoRow4="";//floors
	var infoRow5="";//property type
	var OhItLink="";
	var modifiedAdr=(GetRegion()=="FL")?aryListingData[11]+", "+aryListingData[17]+", "+GetAdrRegion():aryListingData[11]+" "+aryListingData[19];
	//var modifiedAdr=aryListingData[11]+" "+aryListingData[8]+", "+aryListingData[8]+" "+aryListingData[8];//will be sent to google to get directions
	
	infoRow1=(aryListingData[8]!=undefined && aryListingData[8]!=" ")?'<br>'+aryListingData[8]+' Rooms':"";	//first row	
	if(aryListingData[3]!=undefined && aryListingData[3]!=" "){//second row
		infoRow2='<br>'+aryListingData[3]+' Beds';
	}else if(aryListingData[5]!=undefined && aryListingData[5]!=" "){
		infoRow2='<br>'+aryListingData[5]+' Units';
	}else{
		infoRow2="";
	}	
	infoRow3=(aryListingData[4]!=undefined && aryListingData[4]!=" ")?'<br>'+aryListingData[4]+' Baths':"";	//baths	
	infoRow4=(aryListingData[6]!=undefined && aryListingData[6]!=" ")?'<br>'+aryListingData[6]+' Floors':"";	//floors	
	infoRow5=(aryListingData[7]!=undefined && aryListingData[7]!=" ")?'<br>'+aryListingData[7]:"";//property type	
	if(aryListingData[18]!=undefined && aryListingData[18]!=null && aryListingData[18]!="" && aryListingData[18]!=" ")	{
		var opnhse_t=new Array();
		opnhse_t=aryListingData[18].split('<br>');
		opnhse='<font color="#FF0000"><b>Openhouse:</b>';
		opnhse+='<br>'+opnhse_t[0]+'</font>';
	}	
	if(aryListingData[1]!=" " && aryListingData[1]!=undefined)	{
		pic='<img src='+aryListingData[1]+' style="border-style:solid;border-width:1px;border-color:#666666;" width="120" height="75" border="0" OnError="ImageLoadFailedSm()">';
	}
	
	var va1="",va2="",va3="";
	
	var VOphDate="";
	if(category1 != ""){
	if(category1 != " "){
	va1 = category1.toString().substring(0,4);
	va2 = category1.toString().substring(5,7);
	va3 = category1.toString().substring(8,10);
	//alert(var1);
	//alert(var2);
	//alert(var3);
	VOphDate = va2 + '/' +va3+'/'+ va1 + ' 12:00:00 AM';
	}
	}
	
	OhItLink="";//(document.URL.toLowerCase().match("openhouseplanner"))?"<div style=\"height:2px;line-height:2px;\"></div><div id='div_itMap_"+aryListingData[0]+"'>"+MapItineraryDivDisplay("'"+aryListingData+"'","'div_itMap_"+aryListingData[0]+"'")+"</div>":"";
	LHtml='<div id=divListing style="padding-right:1px;"><table><tr><td>';
	LHtml+='<table><tr class=text11px><td vAlign=top>';
	LHtml+='<a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'">'+unescape(aryListingData[11])+'</a>';
	LHtml+='<br><strong>'+aryListingData[17]+'</strong>';
	LHtml+='</td><td vAlign=top>';
	LHtml+='<a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'&ohDat='+VOphDate+';">View Listing</a>';
	LHtml+='<br><a style="cursor:pointer;" class="graylink" onclick="SearchForSimilarListings('+aryListingData[0]+');">View Similar</a></td></tr>';
	LHtml+='<tr class=text11px><td vAlign=top>';
	LHtml+='<a class="graylink" target="_blank" href="/property/listing.aspx?ListingID=' + aryListingData[0]+'&Region='+GetRegion()+'">'+pic+'</a>';
	LHtml+=OhItLink;
	LHtml+='</td>';
	LHtml+='<td vAlign=top>';
	LHtml+='<b>'+FormatPrice(aryListingData[9])+'</b>';
	LHtml+=infoRow1;//rooms
	LHtml+=infoRow2;//beds//units
	LHtml+=infoRow3;//baths
	LHtml+=infoRow4;//floors
	LHtml+=infoRow5;	//proptype
	LHtml+='</td>';
	LHtml+='<tr style="height:1px;" class=text10px><td colspan="2">';
	LHtml+=opnhse;
	LHtml+='</td></tr>';
	LHtml+='<tr><td colspan=2 class=text10px>';
	LHtml+='Get Directions: <a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'to\',\''+modifiedAdr+'\')">To Here</a> | ';
	LHtml+='<a class="graylink" style="cursor:pointer;" onclick="showOfficeDirectionHtml(\'from\',\''+modifiedAdr+'\')">From Here</a></td>';
	LHtml+='</tr>';
	LHtml+='<table><tr height="1"><td height="9" id="srch_td1" vAlign="top">';
	LHtml+='</td><td height="1" id="srch_td2" vAlign="top"></td></tr></table>';
	LHtml+='</td></tr></table></div>';
	return LHtml;
}

function GetRegion()
{
	switch(subRequest)
	{
		case "palmbeach":
			return "FL";
			break;
		case "FL":
			return "FL";
			break;
		case "hamptons":
			return "LI";
			break;		
		case "LI":
			return "LI";		
			break;
		default:
			return "NYC";
			break;
	}
}
function GetHopStopRegion()
{
	switch(subRequest)
	{
		case "palmbeach":
			return "Florida";
			break;
		case "FL":
			return "Florida";
			break;
		case "hamptons":
			return "New York";
			break;		
		case "LI":
			return "New York";		
			break;
		default:
			return "New York";
			break;
	}
}
function GetAdrRegion()
{
	switch(subRequest)
	{
		case "palmbeach":
			return "FL";
			break;
		case "FL":
			return "FL";
			break;
		default:
			return "NY";
			break;
	}
}

function sendDirectionsRequest(direction,defaultAdr)
{
	var newAddress=document.getElementById("sbox").value;
	var url;
	url=(direction=="to")?"http://maps.google.com/maps?saddr="+newAddress+"&daddr="+defaultAdr:"http://maps.google.com/maps?saddr="+defaultAdr+"&daddr="+newAddress;
	window.open(url);
}

function showOfficeDirectionHtml(d,adr)
{
	//document.write("tedt");
	var tkg=document.getElementById("srch_td1");
	var tkg2=document.getElementById("srch_td2");
	var html='<input class="quickSearchBox" value="Enter Your Address" onFocus="showIntroText()" onBlur="hideIntroText()" size="20" type="text" id="sbox">';
	var html2='<img src="/gfx/search_btn.gif" onclick="sendDirectionsRequest(\''+d+'\',\''+adr+'\')">';
	tkg.innerHTML=html;
	tkg2.innerHTML=html2;
}

function showIntroText(){
	var inp=document.getElementById("sbox");
	if(inp.value=="Enter Your Address")	{
		inp.value="";
	}
}

function hideIntroText(){
	var inp=document.getElementById("sbox");
	if(inp.value==""){
		inp.value="Enter Your Address"
	}
}
//format price
function FormatPrice(num){
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	num = Math.floor(num/100).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num);
}

function OpenParent(strLid,strReg)
{
	window.open("/property/listing.aspx?ListingID=" + strLid+"&Region="+strReg);
	//window.opener.location.href="/property/listing.aspx?ListingID=" + strLid+"&Region="+strReg;
}