if (GBrowserIsCompatible()) {
var Icon = new GIcon(G_DEFAULT_ICON);
Icon.image = "blue-pushpin.png";
Icon.shadow = "pushpin_shadow.png";
var side_bar_html = "";
var gmarkers = [];
var htmls = [];
var i = 0;
// A function to create the marker and set up the event window
function createMarker(point,name,html,bedrooms,bathrooms,footage,acreage,listing,price,tag,image,status,type,street,city,display) {
var marker = new GMarker(point,Icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
// Switch icon on marker mouseover and mouseout
GEvent.addListener(marker, "mouseover", function() {
  marker.setImage("red-pushpin.png");
});
GEvent.addListener(marker, "mouseout", function() {
  marker.setImage("blue-pushpin.png");
});
gmarkers[i] = marker;
htmls[i] = html;
// add a line to the side_bar html, with click, mouseover and mouseout event handlers
side_bar_html += '<div class="listing_info" id="listing' + listing + '">';
side_bar_html += '<h6 style="color:#000;">';
if( status  != "Available"){
side_bar_html +=  '<span style="color:red;">' + status + '</span><br />';
}
side_bar_html +=  tag + '</h6>';
side_bar_html += '<p ><a href="real-estate-for-sale-vt.asp?property=' + listing + '">Tour &amp; Details</a>&nbsp;&nbsp;<a href="school-list.asp?property=' + listing + '" target="_blank">Schools</a>&nbsp;&nbsp;';
side_bar_html += '<a href="mailto:?subject=' + city + '  Real Estate For Sale &amp;body=I located an interesting real estate listing from Pat Avila and Stacey Bernd and wanted to share it with you. To view it please visit http://www.thewinecountrydream.com/real-estate-for-sale-vt.asp?property=' + listing + '">Email</a>&nbsp;&nbsp;<a href="javascript:myclick(' + i + ')" onmouseover="gmarkers['+i+'].setImage(\'red-pushpin.png\')" onmouseout="gmarkers['+i+'].setImage(\'blue-pushpin.png\')">Map</a>&nbsp;&nbsp;<a href="javascript:inquire(\'' + listing + '\');">Appointment</a></p>';
side_bar_html += '<img src="' + image + '" title="" alt="" />';
side_bar_html += '<ul style="float:left;">';
side_bar_html += '<li><strong>' + price + '</strong></li>';
if(display != 0){
side_bar_html +=  '<li>' + street;
}
else{
side_bar_html +=  '<li>Call For Address';
}
side_bar_html +=  '<br />' + city + ' , CA</li>';
if( type == "Residential"){
side_bar_html +=  '<li>' + bedrooms + ' bd / ' + bathrooms + ' ba&nbsp;&nbsp;' + footage + ' sqft</li>';
}
side_bar_html += '<li>' + acreage + ' acres</li>';
side_bar_html += '</ul>';
side_bar_html += '</div>'
i++;
return marker;
}
// This function picks up the click and opens the corresponding info window
function myclick(i) {
gmarkers[i].openInfoWindowHtml(htmls[i]);
}
// create the map
var map = new GMap2(document.getElementById("map2"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(38.38017290162773,-122.73762702941895),10);
// Read the data from example.xml
var request = GXmlHttp.create();
request.open("GET", "office/scripts/listings.xml", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = GXml.parse(request.responseText);
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var html = markers[i].getAttribute("html");
var label = markers[i].getAttribute("label");
var bedrooms = markers[i].getAttribute("bedrooms"); 
var bathrooms = markers[i].getAttribute("bath"); 
var footage = markers[i].getAttribute("sqft");
var acreage = markers[i].getAttribute("lot");  
var listing = markers[i].getAttribute("property");
var price = markers[i].getAttribute("price");
var tag = markers[i].getAttribute("tag"); 
var image = markers[i].getAttribute("image"); 
var status = markers[i].getAttribute("status"); 
var type = markers[i].getAttribute("type");                                 
var street = markers[i].getAttribute("street");
var city = markers[i].getAttribute("city");
var display = markers[i].getAttribute("display");
var marker = createMarker(point,label,html,bedrooms,bathrooms,footage,acreage,listing,price,tag,image,status,type,street,city,display);
map.addOverlay(marker);
}
// put the assembled side_bar_html contents into the side_bar div
document.getElementById("side_bar").innerHTML = side_bar_html;
}
}
request.send(null);
}
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
function inquire(listing){
var tom;
tom = "inquire.asp?listing=" + listing;
window.open(tom,'specials','height=450,width=300,status=no,menubar=no,scrollbars=no');
}