// on load scale the content and start the map.
addLoadEvent(initialize);
// Bind resize event to the window
Event.observe(window, "resize", scaleContent);
// set all basic variables to default values
var madeMarkers = false;
var geocoded,map,geocoder,markerBounds,propertyCenter,showPropertyByDefault,PropertyMap,request = null;
var polyHash,encPoly,listingImageArray,markerHash,pts,eventHandlers = [];
var normalProj = G_NORMAL_MAP.getProjection();
var currentMarker,manager,polygonsCreated,clusterHash,cluster,created,localSearch,currentFocus,snappedTo;
var propertyLength,currentProperty,selectedProperty = '';
var zoom = null;
var altCount = 0;
var statisticsInformation = [];
var firstPropSel,firstGeocode = true;
var zoomLevelSnap,polygonInitialSnap,closedMapOverlay,loadedURLProperty,loadedDetailsPropertyIntoMap,loadingProperty,requestInProgress,changedSearchOption,enableTooltip,allowTooltip,pendingMapRefresh = false;
var shownPolygons,totalPolygons,allMatchListings,end,totalListings,begin,displayedResults,clusterCount,markerCount,minPrice,maxPrice = 0;
var currentTab = 'MapView';
var PropertyMapSelectedTab = "Map";
var timeouts = [];
var polyType = [{ id: 'City', type: "1", pluralTitle: 'Cities', title: 'City', showing: 0, count: "10", minZoom: "12", maxZoom: "5", color: '#339933', defaultChecked: '0', autoShow: '1'},{ id: 'GatedCommunity', type: "6", pluralTitle: 'Gated Communities', title: 'Gated Community', showing: 0, count: "315", minZoom: "18", maxZoom: "13", color: '#000099', defaultChecked: '1', autoShow: '1'},{ id: 'GatedGolfCommunity', type: "4", pluralTitle: 'Gated Golf Course Communities', title: 'Gated Golf Course Community', showing: 0, count: "108", minZoom: "18", maxZoom: "13", color: '#009900', defaultChecked: '1', autoShow: '1'},{ id: 'NonGatedCommunity', type: "2", pluralTitle: 'Non Gated Communities', title: 'Non Gated Community', showing: 0, count: "295", minZoom: "18", maxZoom: "13", color: '#207eb9', defaultChecked: '1', autoShow: '1'},{ id: 'NonGatedGolfCommunity', type: "5", pluralTitle: 'Non Gated Golf Course Communities', title: 'Non Gated Golf Course Community', showing: 0, count: "19", minZoom: "18", maxZoom: "13", color: '#68cc82', defaultChecked: '1', autoShow: '1'}];
// pages info
var pages,pageOffset,properties,offset,numResults;
// map bounds variables
var markersCreatedAtZoom,mapInitialBounds,mapInitialBoundsSW,mapInitialBoundsNE,mapInitialBoundsSWCoordinatesX,mapInitialBoundsSWCoordinatesY,mapInitialBoundsNECoordinatesX,mapInitialBoundsNECoordinatesY;
// the minimum zoom you have to be zoomed to for properties to be displayed
var minPropZoom = 15;
// the snap zoom levels for Cities and Communities
var snapZoomCity = 11;
var snapZoomCommunity = 15;
// property information
var managerOptions = { maxZoom:18 };
var minZoom = 5;
var maxZoom = 18;
function getURLVar(urlVarName) {
var urlHalves = String(document.location).toLowerCase().split('?');
var urlVarValue = '';
if(urlHalves[1]){
var urlVars = urlHalves[1].split('&');
for(var i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName.toLowerCase()) { urlVarValue = urlVarPair[1]; }
}
}
}
var urlVarValue = urlVarValue.split("#");
return urlVarValue[0];
}
// start everything going - mapping, bounds info, etc..
function initialize() {
if(navigator.appVersion.indexOf("Safari")!=-1) { scaleContent(); }
if(GBrowserIsCompatible()) {
// window.onunload=google.maps.Unload;
// if(getURLVar('zoom') == '' && ((getURLVar('mls') != '' && getURLVar('mls') != 'null') || (getURLVar('view') == "list+view" || getURLVar('view') == "list") || getURLVar('view') == 'detail')) { var mapDefaultZoom = minPropZoom; }
if(getURLVar('zoom') == '' && (getURLVar('mls') != '' && getURLVar('mls') != 'null')) { var mapDefaultZoom = minPropZoom; }
else if(getURLVar('zoom') == 'prop') { var mapDefaultZoom = minPropZoom; }
else if(getURLVar('zoom') == '') { var mapDefaultZoom = 11; }
else { var mapDefaultZoom = parseFloat(getURLVar('zoom')); }
//map = new GMap2(document.getElementById("MapView"),{mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP,G_HYBRID_MAP,G_PHYSICAL_MAP]});
map=new GMap2(document.getElementById("MapView"),{mapTypes: [G_NORMAL_MAP, G_HYBRID_MAP]});
if(getURLVar('center') != '') { var urlCenter = getURLVar('center').split(","); var mapCenter = new GLatLng(parseFloat(urlCenter[0]),parseFloat(urlCenter[1])); }
else {
var mapCenter = new GLatLng(33.7152, -116.32427); if((getURLVar('view') == '' || getURLVar('view') == "map+view" || getURLVar('view') == 'map') && getURLVar('mls') != '') { var mapDefaultZoom = 17; }
else if(getURLVar('subdiv') != '') { var mapDefaultZoom = snapZoomCommunity; }
}
map.setCenter(mapCenter, mapDefaultZoom);
// check all Default Checked area types
for(var i = 0; i < polyType.length; i++) {
if(document.getElementById(polyType[i].id + '-PolyRow') && polyType[i].minZoom >= map.getZoom() && polyType[i].maxZoom <= map.getZoom() && polyType[i].defaultChecked == '1') {
document.getElementById(polyType[i].id + '-PolySH').checked = true;
}
}
Event.observe('ListContent_Map', "scroll", loadListImages);
localSearch = new google.maps.LocalSearch(localSearchControlOptions);
geocoder = new GClientGeocoder();
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(localSearch);
localSearchExists = true;
map.enableScrollWheelZoom();
map.enableDoubleClickZoom();
GEvent.addListener(map, 'dblclick', cancelTimeouts);
GEvent.addListener(map, 'dragend', trackChanges);
GEvent.addListener(map, 'zoomend', trackChanges);
//G_PHYSICAL_MAP.getMinimumResolution = function () { return 5 };
G_NORMAL_MAP.getMinimumResolution = function () { return 5 };
//G_SATELLITE_MAP.getMinimumResolution = function () { return 5 };
G_HYBRID_MAP.getMinimumResolution = function () { return 5 };
manager = new MarkerManager(map, managerOptions);
if(getURLVar('city') != '' && (getURLVar('subdiv') == '' || getURLVar('subdiv') == 'undefined')) { filterDiv(true); polygonInitialSnap = false; trackChanges(); }
else if(getURLVar('city') != '' && getURLVar('subdiv') != '' && getURLVar('subdiv') != 'undefined') { filterDiv(getURLVar('subdiv')); polygonInitialSnap = false; }
else { trackChanges(); }
setBounds();
if(getURLVar('view') == "detail" && getURLVar('mls') != '' && getURLVar('mls') != 'null') { showDetails(parseFloat(getURLVar('mls')),true); currentProperty = parseFloat(getURLVar('mls')); }
else if(getURLVar('mls') != '' && getURLVar('mls') != 'null' && getURLVar('center') != '' ) { propertyCenter = getURLVar('center'); currentProperty = parseFloat(getURLVar('mls')); showProperty(parseFloat(getURLVar('mls'))); }
else if(getURLVar('view') == "list+view" || getURLVar('view') == "list") { switchMapTab('ListView'); }
}
}
function cancelTimeouts() {
allowTooltip = false;hidePolygonTooltip();
for(var i=0; i < timeouts.length;i++) {
clearTimeout(timeouts[i]);
}
}
function trackChanges(force) {
create = 'prop';
if(changedSearchOption == true) { force = true; changedSearchOption = false; }
if (currentMarker) { closeInfoWindowMarker(); }
var currentZoom = map.getZoom();
var mapBounds = map.getBounds();
var mapBoundsSW = mapBounds.getSouthWest();
var mapBoundsNE = mapBounds.getNorthEast();
if(force == true || zoom != map.getZoom()) { setBounds(); }
if(mapBoundsNE.lng() > mapBoundsSW.lng()) {
if(mapBoundsSW.lng() > mapInitialBoundsSW.lng() && mapBoundsSW.lng() < mapInitialBoundsNE.lng() && mapBoundsSW.lat() <= mapInitialBoundsNE.lat() && mapBoundsSW.lat() >= mapInitialBoundsSW.lat() && mapBoundsNE.lng() > mapInitialBoundsSW.lng() && mapBoundsNE.lng() < mapInitialBoundsNE.lng() && mapBoundsNE.lat() <= mapInitialBoundsNE.lat() && mapBoundsNE.lat() >= mapInitialBoundsSW.lat()) { inBounds = true; }
else { inBounds = false; }
}
else {
if(((mapBoundsSW.lng() >= mapInitialBoundsSW.lng() || mapBoundsSW.lng() < mapInitialBoundsNE.lng()) && mapBoundsSW.lat() <= mapInitialBoundsNE.lat() && mapBoundsSW.lat() >= mapInitialBoundsSW.lat()) && ((mapBoundsNE.lng() >= mapInitialBoundsSW.lng() || mapBoundsNE.lng() < mapInitialBoundsNE.lng()) && mapBoundsNE.lat() <= mapInitialBoundsNE.lat() && mapBoundsNE.lat() >= mapInitialBoundsSW.lat())) { inBounds = true; }
else { inBounds = false; }
}
if(force == true || zoom != map.getZoom()) {
allowTooltip = false;hidePolygonTooltip();
if(map.getZoom() != zoom) { force = true; }
zoom = map.getZoom();
if(polygonInitialSnap == false) { snappedTo = null; }
map.clearOverlays();
for(var i = 0; i < eventHandlers.length; i++) { GEvent.removeListener(eventHandlers[i]); }
eventHandlers.length = 0;
polyHash = [];
encPoly = [];
clusterHash = [];
markerHash = [];
manager.clearMarkers();
closedMapOverlay = false;
clusterCount = 0;
displayedResults = 0;
markerCount = 0;
if(localSearch) { localSearch.goIdle(); }
}
// loop through polygon types and hide or show checkboxes based on zoom level
checkedPolygonTypes = 0;
for(var i = 0; i < polyType.length; i++) {
if(document.getElementById(polyType[i].id + '-PolyRow') && polyType[i].minZoom >= zoom && polyType[i].maxZoom <= zoom) {
document.getElementById(polyType[i].id + 'Link').style.textDecoration = 'none';
document.getElementById(polyType[i].id + 'Link').style.color = '#000';
document.getElementById(polyType[i].id + '-Color').style.background = polyType[i].color;
document.getElementById(polyType[i].id + '-PolySH').checked = true;
}
else if(document.getElementById(polyType[i].id + '-PolyRow')) {
document.getElementById(polyType[i].id + '-PolySH').checked = false;
document.getElementById(polyType[i].id + 'Link').style.textDecoration = 'line-through';
document.getElementById(polyType[i].id + 'Link').style.color = '#ccc';
}
if(document.getElementById(polyType[i].id + '-PolyRow') && document.getElementById(polyType[i].id + '-PolySH').checked == true) { checkedPolygonTypes++; }
}
// loop through again if the zoom is out of the property zoom and there are no checked polygon types
if(zoom < minPropZoom && checkedPolygonTypes == 0) {
// if(checkedPolygonTypes == 0) {
for(var i = 0; i < polyType.length; i++) {
if(document.getElementById(polyType[i].id + '-PolyRow') && polyType[i].minZoom >= zoom && polyType[i].maxZoom <= zoom && polyType[i].autoShow == '1') {
document.getElementById(polyType[i].id + '-PolySH').checked = true;
}
}
}
if(inBounds == false || force == true) {
setBounds();
// if we are no longer within the bounds that the elements were intially created, we must recreate them.
document.getElementById('mapOverlay').style.display = '';
if(force == true) { document.getElementById('PropertyListPopulated_Map').value = '0'; }
Element.update('mapOverlay','
Processing Listings...
');
search();
}
// if we are creating or created anything other than properties and for some reason clustered markers are still appearing, remove them.
if(document.getElementById('ListView-Tab') && document.getElementById('DetailView-Tab')) {
if(map.getZoom() < minPropZoom) {
document.getElementById('DetailView-Tab').style.display = 'none';
selectedProperty = null;
currentProperty = null;
Element.update('ListContent_Map','Loading Property Listings...
');
}
else {
// if we created or are creating properties and the detail tab is hidden, unhide it, otherwise re-hide it.
if(document.getElementById('DetailView-Tab').style.display == 'none' && selectedProperty) {
document.getElementById('DetailView-Tab').style.display = '';
}
}
}
}
function clearValues() {
document.getElementById('PropertyListPopulated_Map').value = '0'
geocoded = null;
created = "changed";
}
// set the bounds of the map
// used when we-loading content from the database, if we have already loaded the content in these bounds then we don't need to reload
function setBounds() {
markersCreatedAtZoom = map.getZoom();
mapInitialBounds = map.getBounds();
// convert the map bounds to X,Y coordinates
mapInitialBoundsSWCoordinates = map.fromLatLngToDivPixel(mapInitialBounds.getSouthWest());
mapInitialBoundsNECoordinates = map.fromLatLngToDivPixel(mapInitialBounds.getNorthEast());
// expand the bounds by 20 pixels
// this keeps the "fringe" markers from causing the map to reload markers due to the map scrolling just outside of the current bounds
mapInitialBoundsSWCoordinatesX = mapInitialBoundsSWCoordinates.x - 20;
mapInitialBoundsSWCoordinatesY = mapInitialBoundsSWCoordinates.y + 20;
mapInitialBoundsNECoordinatesX = mapInitialBoundsNECoordinates.x + 20;
mapInitialBoundsNECoordinatesY = mapInitialBoundsNECoordinates.y - 20;
// convert eh X,Y coordinates back to Lat,Lng coordinates and set the bounds
mapInitialBoundsSW = map.fromDivPixelToLatLng(new GPoint(mapInitialBoundsSWCoordinatesX,mapInitialBoundsSWCoordinatesY));
mapInitialBoundsNE = map.fromDivPixelToLatLng(new GPoint(mapInitialBoundsNECoordinatesX,mapInitialBoundsNECoordinatesY));
}
function scaleContent(fullPage) {
/*
bodyHeight - the height of the entire page
contentHeight - defines the height of the innter content
contentWidth - defines the width of the inner content
subMainAreaInteriorWidth - this is the width of the container boxes, Map View, Detail View, List View
subFullBox - this is the width of the entire containing box that holds Map View, Detail View & List View
subFullTopBottom - this is the width of the top and bottom shadows of the entire containing box
arrowLeft - defines how far left the Hide/Show arrow will be, also defines how far left the map area box will be.
mapContainerHeight - this is the height of the entire containing box
searchInteriorSubtraction - this is the amount (in pixels) to be subtracted from the height of the search tabs (Map, Land, Local, Layers)
*/
Event.stopObserving(window, "resize", scaleContent);
if(document.getElementById('sidebar').style.display == 'none') { fullPage = 'true'; }
// var bodyHeight = wHeight() - Element.getHeight('Header') - Element.getHeight('Navigation') - Element.getHeight('Footer');
var bodyHeight = wHeight() - Element.getHeight('Header') - Element.getHeight('BottomBanner');
if(bodyHeight < 525 && version != 6) { bodyHeight = 525; var scrollBarWidth = 35; var scrollWidthNeg = -35; var scrolling = true; }
else if(bodyHeight < 595 && version == 6) { bodyHeight = 670; var scrollBarWidth = 20; var scrollWidthNeg = -20; var scrolling = true; }
else { var scrollBarWidth = 25; var scrollWidthNeg = -25; }
if(version >= 5.5) {
var contentWidth = wWidth() - 155;
var contentHeight = bodyHeight- 205;
}
else {
var contentWidth = wWidth() - 125;
var contentHeight = bodyHeight-147;
}
if(contentWidth < 862) {
contentWidth = 853;
$('MainContainer').setStyle({ 'width': contentWidth + (version >= 7 ? 115 : 95) + 'px' });
$('ContentWrapperBottomCorner').setStyle({ 'width': contentWidth + 95 + 'px' });
}
else {
$('MainContainer').setStyle({ 'width': '100%' });
$('ContentWrapperBottomCorner').setStyle({ 'width': '100%' });
}
if(fullPage == 'true') {
var subFullBox = (version >= 5.5 ? -42 : -56 ) - scrollWidthNeg;
var subMainAreaInteriorWidth = (version >= 5.5 ? -32 : -60) - scrollWidthNeg;
var subFullTopBottom = (version >= 5.5 ? ((version >= 7 ? -20 : -20) - scrollWidthNeg) : -41 - scrollWidthNeg);
var arrowLeft = 25;
}
else {
// var subFullBox = (version >= 5.5 ? (contentWidth <= 853 && version < 7 ? 265 : 245) : 245) + scrollBarWidth;
// var subMainAreaInteriorWidth = (version >= 5.5 ? (contentWidth && version < 7 <= 853 ? 270 : 250) : 245) + scrollBarWidth;
// var subFullTopBottom = (version >= 5.5 ? (contentWidth <= 853 && version < 7 ? 282 : 262) : 263) + scrollBarWidth;
var subFullBox = (version >= 5.5 ? (contentWidth <= 853 ? 265 : (version >= 7 ? 245 : 235)) : 245) + scrollBarWidth;
var subMainAreaInteriorWidth = (version >= 5.5 ? (contentWidth <= 853 ? (version >= 7 ? 270 : 280) : 250) : 245) + scrollBarWidth;
var subFullTopBottom = (version >= 5.5 ? (contentWidth <= 853 ? (version >= 7 ? 282 : 292) : 262) : 263) + scrollBarWidth;
var arrowLeft = 330;
}
// main map container area height
var mapContainerHeight = (version >= 5.5 ? 75 : 25);
// move the bottom row of content - content provided by line
//$('MapBottomRow').setStyle({ 'left': '25px', 'top': contentHeight + mapContainerHeight + (version >= 7 ? 162 : 172) + 'px' });
if(fullPage == 'true') {
if(version >= 5.5) { $('MapBox').setStyle({ 'left': (arrowLeft + (version >= 7 ? 6 : 8)) + 'px', 'height': (contentHeight + mapContainerHeight) + 'px', 'width': contentWidth - subFullBox + 8 + 'px' }); }
else { $('MapBox').setStyle({ 'left': (arrowLeft + 8) + 'px', 'height': (contentHeight + mapContainerHeight) + 'px', 'width': contentWidth - subFullBox + 4 + 'px' }); }
}
else {
if (version>=5.5) { $('MapBox').setStyle({ 'left': (arrowLeft - (version >= 5.5 ? -15 : 140)) + 'px', 'height': (contentHeight + mapContainerHeight) + 'px', 'width': contentWidth - subFullBox + 8 + 'px' }); }
else { $('MapBox').setStyle({ 'left': (arrowLeft + 8) + 'px', 'height': (contentHeight + mapContainerHeight) + 'px', 'width': contentWidth - subFullBox + 'px' }); }
}
if(version >= 7) { $('MapWrapper').style.backgroundPosition='100% 4px'; }
if(version >= 5.5) { $('MapWrapper').setStyle({ 'width': contentWidth - subFullBox + 'px' }); }
// interior search box subtraction value
var searchInteriorSubtraction = (version >= 7 ? 125 : 170);
$('MapTop').setStyle({ 'width': contentWidth - subFullTopBottom + (version >= 5.5 ? (version >= 7 ? 20 : 30) : 15) + 'px' });
if(version >= 5.5) {
$('MapBottom').setStyle({ 'width': contentWidth - subFullTopBottom + (fullPage == "true" ? 58 : (version >= 7 ? 53 : 62)) + 'px' });
$('MapLeft').setStyle({ 'height': (contentHeight + 73) + 'px', 'top': '-8px' });
$('DetailView').setStyle({ 'height': (contentHeight + 45) + 'px', 'width': contentWidth - subMainAreaInteriorWidth - 23 + 'px' });
$('MapView').setStyle({ 'height': (contentHeight + 35) + 'px', 'width': contentWidth - subMainAreaInteriorWidth + 'px' });
$('ListContent_Map').setStyle({ 'height': contentHeight-15 + 'px' });
}
else {
$('MapBottom').setStyle({ 'width': contentWidth - subFullTopBottom + 47 + 'px' });
$('MapLeft').setStyle({ 'height': (contentHeight + 31) + 'px', 'top': '-1px' });
$('DetailView').setStyle({ 'height': (contentHeight) + 'px', 'width': contentWidth - subMainAreaInteriorWidth + 'px' });
$('MapView').setStyle({ 'height': (contentHeight) + 'px', 'width': contentWidth - subMainAreaInteriorWidth + 'px' });
$('ListContent_Map').setStyle({ 'height': contentHeight-45 + 'px' });
}
$('ListView').setStyle({ 'height': (contentHeight + 45) + 'px', 'width': contentWidth - subMainAreaInteriorWidth + 'px' });
// var sidebarTop = Element.getHeight('Header') + Element.getHeight('Navigation') + Element.getHeight('MapTab') - 12;
var sidebarTop = 0;
$('sidebar').setStyle({ 'height': Element.getHeight('MapBox') + 'px', 'top': sidebarTop + 'px' });
$('HideShowArrowWrapper').setStyle({ 'left': (arrowLeft - 12) + 'px', 'top': (sidebarTop + (Element.getHeight('sidebar')/2)) + 'px' });
if(document.getElementById('Content-LocalSearch')) { $('Content-LocalSearch').setStyle({ 'height': (contentHeight - searchInteriorSubtraction + Element.getHeight('MapTab')) + 'px'}); }
if(document.getElementById('SidebarMainContainer')) { $('SidebarMainContainer').setStyle({ 'height': (contentHeight - searchInteriorSubtraction + Element.getHeight('MapTab')) + 'px'}); }
if(document.getElementById('Residential_Box')) { $('Residential_Box').setStyle({ 'height': (contentHeight - (searchInteriorSubtraction + 30) + Element.getHeight('MapTab')) + 'px'}); }
if(document.getElementById('Land_Box')) { $('Land_Box').setStyle({ 'height': (contentHeight - (searchInteriorSubtraction + 30) + Element.getHeight('MapTab')) + 'px'}); }
// $('ContentWrapperBottomCorner').setStyle({ 'width': (contentWidth+ (version >= 5.5 ? (scrolling == true ? 95 : 105) : (scrolling == true ? 100 : 114 ))) + 'px' });
Event.observe(window, "resize", scaleContent);
if(map) { map.checkResize(); }
}
// function to hide or show the sidebar
function hideShowToolbar(action) {
if(action == 'true') {
document.getElementById('sidebar').style.display = 'none';
document.getElementById('sidebar-show').style.display = 'block';
document.getElementById('sidebar-hide').style.display = 'none';
}
else {
document.getElementById('sidebar').style.display = 'block';
document.getElementById('sidebar-hide').style.display = 'block';
document.getElementById('sidebar-show').style.display = 'none';
}
scaleContent(action);
if(currentTab == "DetailView" || currentTab == "ListView") { pendingMapRefresh = true; }
else { trackChanges(true); }
}
// subdivision and city filtering function
function resetPolygonSnap() {polygonInitialSnap = false; zoomLevelSnap = false; }
// function to post requests to schedule a viewing email
function postScheduleShowing() {
var name = document.getElementById('ScheduleViewingName').value;
var dateMM = document.getElementById('ScheduleViewingDateMM').value;
var dateDD = document.getElementById('ScheduleViewingDateDD').value;
var dateYYYY = document.getElementById('ScheduleViewingDateYYYY').value;
var phone = document.getElementById('ScheduleViewingPhone').value;
var email = document.getElementById('ScheduleViewingEmail').value;
var comment = document.getElementById('ScheduleViewingComment').value;
var mls = document.getElementById('ScheduleViewingMLS').value;
if(name != '' && (dateMM != '' && dateDD != '' && dateYYYY != '') && phone != '') {
var opt = {
method: 'post',
postBody: "mls=" + mls + "&name=" + encodeURI(name) + "&comment=" + encodeURI(comment) + "&phone=" + encodeURI(phone) + "&email=" + encodeURI(email) + "&dateMM=" + encodeURI(dateMM) + "&dateDD=" + encodeURI(dateDD) + "&dateYYYY=" + encodeURI(dateYYYY),
onSuccess: function(t) {
eval(t.responseText);
}
};
new Ajax.Request('/call/postScheduleViewing.php', opt);
}
else { document.getElementById("ScheduleViewingResponse").innerHTML = "Some required fields were missing."; }
}
// function to post comments on properties
function postPropertyComment() {
var message = document.getElementById('CommentMessage').value;
var mls = document.getElementById('CommentMLS').value;
if(document.getElementById('CommentPostedTo') && document.postPropertyCommentForm.CommentPostedTo.options[document.postPropertyCommentForm.CommentPostedTo.selectedIndex].value != '' && document.postPropertyCommentForm.CommentPostedTo.options[document.postPropertyCommentForm.CommentPostedTo.selectedIndex].value != 'undefined') { var postedTo = "&CommentPostedTo=" + document.postPropertyCommentForm.CommentPostedTo.options[document.postPropertyCommentForm.CommentPostedTo.selectedIndex].value; }
else { var postedTo = ''; }
if(document.getElementById('guestName') && document.getElementById('guestName').value != '' && document.getElementById('guestName').value != 'undefined') { var guestName = "&guestName=" + document.getElementById('guestName').value; }
else { var guestName = ''; }
if(message != '') {
var opt = {
method: 'post',
postBody: "mls=" + mls + "&message=" + encodeURI(message) + guestName + postedTo,
onSuccess: function(t) {
eval(t.responseText);
if(comment != '') {
// add the comment to the list
if(document.getElementById('CommentCount').value == 0) { document.getElementById('PropertyComments').innerHTML = ''; document.getElementById('CommentCount').value = 1; }
else { document.getElementById('CommentCount').value = parseFloat(document.getElementById('CommentCount').value)+1; }
var postedMessage = document.createElement("div");
postedMessage.setAttribute('class',"PropertyCommentRow");
postedMessage.setAttribute('id','Comment-' + comment);
var messageContent = '