var defaultMessage="<span style='font-size: 120%; font-weight: bold;'>";defaultMessage+="Map Instructions:<ol><li>Double click the mouse on the desired center of the map.</li>";defaultMessage+="<li>Use the wheel on your mouse to zoom in or out on the map.</li>";defaultMessage+="<li>Place cursor on map, press left button and move cursor to position map.</li>";defaultMessage+="<li>Set price and other search criteria on left.</li>";defaultMessage+="<li>Map will populate with properties.</li>";defaultMessage+="<li>Move map and change search criteria at any time.</li>";defaultMessage+="<li>Please send comments to \"Contact Us\" on lower left tab.</li></ol></span>";city_buffer=[];area_buffer=[];map=undefined;mapInitialized=false;currentMarker=undefined;sidebarContent=undefined;searchRequestDelay=null;xhrSearch=null;xhrLoadMarkers=null;searchNamesBuffer=[];searchValuesBuffer=[];markers=[];marker_icons=[];_resultsMouseOver=false;debugMode=false;showSearchTimes=false;$(document).ready(function()
{if($("#map_mode").css("display")!="none")
{initializeMap();}
$(document).unload(function()
{GUnload();});if(debugMode===true)
{if($("#ajax_errors").length==0)
{$("#footer").after("<ul id=\"ajax_errors\" style=\"background: #c0c0c0;\"></ul>");}
$("#ajax_errors").ajaxError(function(event,request,settings)
{$(this).append("<li>Error requesting page: "+settings.url+" / Request ready state: "+request.readyState+"</li>");});}
$("fieldset").each(function()
{if(!$(this).hasClass("nolegend"))
{var id=$(this).attr('id');var selector=(id===null||id==''?"legend":"#"+id+" > legend");var title=$(selector).html();if($(this).hasClass("collapsible"))
{$(selector).replaceWith("<div class='legend'>"+title+"</div>");$(".legend",this).after("<div class='summary collapsed'></div>");$(".legend",this).append("<a class='control' href='#'></a>");}
else
{$(selector).replaceWith("<div class='legend'>"+title+"</div>");}}});prop_attr_state=='expanded'?expandPropertyAttributes():collapsePropertyAttributes();search_type_state=='expanded'?expandSearchTypes():collapseSearchTypes();prop_types_state=='expanded'?expandPropertyTypes():collapsePropertyTypes();prop_features_state=='expanded'?expandPropertyFeatures():collapsePropertyFeatures();$("ul#search_modes input").click(function(e)
{var searchMode=$(this).attr("id").replace("by_","");showSearchMode(searchMode);if(searchMode=='map')
{mapSizeChange();}
else
{updateSearchBuffers([$(this).attr("name")],[searchMode]);setSearchRequestTimer();}
e.stopPropagation();});$("fieldset#search_types input[type='radio']").click(function(e)
{var searchType=$(this).attr("id").replace("for_","");showSearchType(searchType);updateSearchBuffers([$(this).attr("name")],[searchType]);setSearchRequestTimer();e.stopPropagation();});$("#zip_mode li.go input").click(function(e)
{updateSearchBuffers([$("#zip_codes_text").attr("name")],[$("#zip_codes_text").val()]);setSearchRequestTimer();e.stopPropagation();});$("#address_mode li.go input").click(function(e)
{updateSearchBuffers([$("#address_text").attr("name")],[$("#address_text").val()]);setSearchRequestTimer();e.stopPropagation();});$("#mls_mode li.go input").click(function(e)
{updateSearchBuffers([$("#mls_text").attr("name")],[$("#mls_text").val()]);setSearchRequestTimer();e.stopPropagation();});$("div#location textarea").keypress(function(e)
{if(e.which==13)
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();return false;}});$("select#county_select").change(function()
{populateCitySelect();populateAreaSelect();});$("select#city_select").change(function()
{updateCityBuffer();deselectMacroOptions($(this));populateAreaSelect();});$("select#area_select").change(function()
{updateAreaBuffer();deselectMacroOptions($(this));});$("fieldset#city_mode select").change(function()
{values=[];$("select#area_select option:selected").each(function()
{values.push($(this).val());});if(values.length==0)
{values.push("");}
updateSearchBuffers(["areas[]"],[values.join()]);setSearchRequestTimer();});$("#select_all_areas").click(function()
{selectAllAreasMacro();$('select#area_select').click();deselectMacroOptions($('select#area_select'));return false;});$("fieldset#search_options select").change(function()
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();});$("fieldset#search_options input[type='text']").blur(function()
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();});$("fieldset#search_options input[type='text']").keypress(function(e)
{if(e.which==13)
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();return false;}});$("fieldset#property_types input[type='checkbox']").click(function(e)
{updateSearchBuffers([$(this).attr("name")],[$(this).attr("checked")==true]);setSearchRequestTimer();e.stopPropagation();});$("#ptype_comi").click(function(e)
{hideOrShowCBALink();e.stopPropagation();});hideOrShowCBALink();function hideOrShowCBALink()
{if($("#ptype_comi").is(':checked'))
{$("#cba_link").show();}
else
{$("#cba_link").hide();}}
$("fieldset#property_features input[type='checkbox']").click(function(e)
{updateSearchBuffers([$(this).attr("name")],[$(this).attr("checked")==true]);setSearchRequestTimer();e.stopPropagation();});$("fieldset#results_sort select").change(function()
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();});$("fieldset#results_pagesize select").change(function()
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();});$("fieldset#open_house_options select").change(function()
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();});$("fieldset#sold_date_options input[type='text']").change(function()
{if($(this).val().isDate())
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();}
else
{alert('Please enter a valid date with the following format: mm/dd/yyyy.');}});$("fieldset#sold_date_options input[type='text']").keypress(function(e)
{if(e.which==13)
{if($(this).val().isDate())
{updateSearchBuffers([$(this).attr("name")],[$(this).val()]);setSearchRequestTimer();}
else
{alert('Please enter a valid date with the following format: mm/dd/yyyy.');}
e.stopPropagation();}});$("#criteria_select a").click(function(e)
{sidebarContent='criteria';$("#account").hide();$("#account_select").removeClass("selected");$("#criteria").show();$("#criteria_select").addClass("selected");saveToSession('search_sidebar','criteria');moveSaveControls(sidebarContent);e.stopPropagation();return false;});$("#account_select a").click(function(e)
{sidebarContent='account';$("#criteria").hide();$("#criteria_select").removeClass("selected");$("#account").show();$("#account_select").addClass("selected");saveToSession('search_sidebar','account');moveSaveControls(sidebarContent);e.stopPropagation();return false;});if($("#account").css('display')!='none')
{moveSaveControls('account');}
$("div.paginator a").each(function()
{$(this).click(function(e)
{var page=$(this).attr("href").split("=")[1];updateSearchBuffers(["CurrentPage"],[page]);setSearchRequestTimer();e.stopPropagation();return false;});});if($("#by_map").is(":checked"))
{sendAddMarkerRequest();}
$("#save_named_search_button").replaceWith("<input id='save_named_search_button' name='save_named_search_button' type='image' src='images/themes/"+theme_name+"/find/save_this_search.png'>");$("#new_search_button").replaceWith("<input id='new_search_button' name='new_search_button' type='image' src='images/themes/"+theme_name+"/find/new_search.png'>");$("#save_named_search_button").click(function(e)
{sendSaveSearchRequest();e.stopPropagation();return false;});$("#new_search_button").click(function(e)
{window.location='find.php?newsearch=1';e.stopPropagation();return false;});$("#cboEmailFreq").change(function(e)
{var frequency=$("#cboEmailFreq").val();$.get("async/save_search_notification_frequency.xml.php","frequency="+frequency,function parseSaveSearchResultsXml(xml)
{var responses="";$(xml).find("Response").each(function()
{responses+=$(this).text()+"\n";});if(responses.length>0)setMessage(responses);},"xml");});sidebarContent=$("#search_sidebar").val();var small_size=300;var large_size=500;var small_class='moremap';var large_class='lessmap';$("#mapsize a").click(function(e)
{if($("#map_canvas").height()==small_size)
{$("#map_canvas").height(large_size);$("#mapsize a").addClass(large_class);$("#mapsize a").removeClass(small_class);}
else
{$("#map_canvas").height(small_size);$("#mapsize a").addClass(small_class);$("#mapsize a").removeClass(large_class);}
map.checkResize();saveToSession('mapsize',$("#map_canvas").height());mapSizeChange();e.stopPropagation();return false;});if($("#map_canvas").height()==small_size)
{$("#mapsize a").addClass(small_class);$("#mapsize a").removeClass(large_class);}
else
{$("#mapsize a").addClass(large_class);$("#mapsize a").removeClass(small_class);}
localPopupify();$("body").click(function(e)
{$("#infowindow").hide();$("#map_type_popup").hide();e.stopPropagation();});$(".favorite_check").click(function(e)
{addToFavorites($(this).val(),$(this).attr('id'));e.stopPropagation();});stripeResults();attachMapIconGlow();if(readCookie('foo')===null)
{$('#results_list').html(defaultMessage);createCookie('foo','bar',0);}
if(area_buffer.length==0&&$('#area_select option:selected').length>0)
{area_select=$('#area_select').get(0);for(i=0;i<area_select.length;i++)
{if(area_select.options[i].selected==true)
{area_buffer[area_select[i].value]=true;}}}
$("#infowindow,#infowindow *").click(function(e)
{e=e||event;e.stopPropagation?e.stopPropagation():e.cancelBubble=true;});});function addToFavorites(ln,id)
{if(!user_logged_in)
{var popSet=new popupSettings('addtofavorites login',false);window.open('favorites_dialog.php?ln='+ln+(aid!=0?'&aid='+aid:''),id,popSet.windowAttributes);return false;}
else
{$.ajax({url:root_path+"/async/add_to_favorite.xml.php",type:"POST",data:"ln="+ln,dataType:"xml",timeout:30000,cache:false,success:parseAddToFavoriteXml});}}
function updateSearchBuffers(names,values)
{var historyCount=10;for(var i=0;i<values.length;i++)
{searchNamesBuffer.unshift(names[i]);searchValuesBuffer.unshift(values[i]);}
if(searchValuesBuffer.length>historyCount)
{searchNamesBuffer=searchNamesBuffer.slice(0,historyCount);searchValuesBuffer=searchValuesBuffer.slice(0,historyCount);}
var unique_values='';var to_remove=[];for(var i=0;i<searchValuesBuffer.length;i++)
{var current=searchNamesBuffer[i];if(unique_values.indexOf(current+',')===-1)
{unique_values+=current+','}
else
{to_remove.unshift(i);}}
for(i in to_remove)
{searchNamesBuffer.splice(to_remove[i],1);searchValuesBuffer.splice(to_remove[i],1);}}
function showBoundaryPoints(outputSelector)
{var bounds=map.getBounds();var ne=bounds.getNorthEast();var sw=bounds.getSouthWest();$(outputSelector).html('NE Lat: '+ne.lat()+'<br />NE Lng: '+ne.lng()+'<br />SW Lat: '+sw.lat()+'<br />SW Lng: '+sw.lng())}
function initializeMap()
{if(!mapInitialized)
{if(GBrowserIsCompatible())
{map=new GMap2(document.getElementById("map_canvas"));var SW=new GLatLng($("#MapSWLat").val(),$("#MapSWLng").val());var NE=new GLatLng($("#MapNELat").val(),$("#MapNELng").val());var bounds=new GLatLngBounds(SW,NE);map.setCenter(bounds.getCenter());map.setZoom(map.getBoundsZoomLevel(bounds));map.addMapType(G_PHYSICAL_MAP);switch($("#MapType").val())
{case"Street":map.setMapType(G_NORMAL_MAP);break;case"Satellite":map.setMapType(G_SATELLITE_MAP);break;case"Hybrid":map.setMapType(G_HYBRID_MAP);break;case"Terrain":map.setMapType(G_PHYSICAL_MAP);break;default:map.setMapType(G_NORMAL_MAP);break;}
map.addControl(new SkylineZoomPanControl(),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,-40)));map.addControl(new SkylineMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(0,-35)));var otherOpts={buttonStartingStyle:{background:'transparent',width:'56px',height:'40px',cursor:'pointer'},buttonHTML:'<img src="images/themes/'+theme_name+'/find/dragzoom.png" title="Click and drag the map to zoom in" />',buttonZoomingHTML:'<img src="images/themes/'+theme_name+'/find/dragzoom.png" title="Click and drag the map to zoom in" />',buttonZoomingStyle:{}}
map.addControl(new DragZoomControl({},otherOpts,{}),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(79,-40)));map.enableScrollWheelZoom();GEvent.addListener(map,"moveend",function()
{mapSizeChange();});GEvent.addListener(map,"movestart",function()
{$("#infowindow").hide();map.clearOverlays();});GEvent.addListener(map,"click",function()
{$("#infowindow").hide();$("#map_type_popup").hide();});}
else
{alert("It appears that your browser does not support Google Maps.");}
mapInitialized=true;}}
function parseAddToFavoriteXml(xml)
{var errors="";$(xml).find("Errors").each(function()
{errors+=$(this).text()+"\n";});if(errors.length>0)alert(errors);window.location.href=window.location.href}
function parseAddMarkersXml(xml)
{var responses="";$(xml).find("Response").each(function()
{responses+=$(this).text()+"\n";});if(responses.length>0)alert(responses);$(xml).find("Listing").each(function()
{var lat=$(this).find("Lat").text();var lng=$(this).find("Lng").text();var property_type=$(this).find("PropertyType").text();var ln=$(this).find("MlsNumber").text();var icon_number=$(this).find("IconNumber").text();var user_favorite=$(this).find("UserFavorite").text();var table=$(this).find("Table").text();var icon_name=user_favorite=="true"?"themes/"+theme_name+"/find/map_icon_favorite":"themes/"+theme_name+"/find/map_icon";var icon=new GIcon();icon.image="http://www.skylineproperties.com"+root_path+"/images/map_icon.php?text="+icon_number+"&icon="+icon_name;icon.iconSize=new GSize(18,18);icon.iconAnchor=new GPoint(0,0);icon.infoWindowAnchor=new GPoint(0,0);var point=new GLatLng(lat,lng);var marker=new GMarker(point,icon);GEvent.addListener(marker,"mouseover",function()
{currentMarker=marker;$.ajax({url:root_path+"/async/infowindow_snapshot.xml.php",type:"POST",data:"ln="+ln+'&table='+table,dataType:"xml",timeout:30000,cache:false,success:parseInfowindowXml});});GEvent.addListener(marker,"click",function()
{window.location="http://www.skylineproperties.com"+root_path+"/property_detail.php?ln="+ln+"&ptyp="+property_type+(aid!=0?'&aid='+aid:'');});GEvent.addListener(marker,"mouseout",function()
{});markers[icon_number]=marker;marker_icons[icon_number]=icon.image;map.addOverlay(marker);});xhrLoadMarkers=null;}
function parseInfowindowXml(xml)
{var responses="";$(xml).find("Response").each(function()
{responses+=$(this).text()+"\n";});if(responses.length>0)alert(responses);var templater=new cTemplate();var snapshotHtml=$(xml).find("SnapshotHtml").text();templater.loadTemplate(snapshotHtml);templater.addVariable('infowindow_snapshot','title',$(xml).find("Title").text());templater.addVariable('infowindow_snapshot','address',$(xml).find("Address").text());templater.addVariable('infowindow_snapshot','price',$(xml).find("Price").text());templater.addVariable('infowindow_snapshot','image_src',$(xml).find("ThumbnailImageSrc").text());templater.addVariable('infowindow_snapshot','mls_number',$(xml).find("MlsNumber").text());templater.addVariable('infowindow_snapshot','property_type',$(xml).find("PropertyType").text());templater.addVariable('infowindow_snapshot','image_path','images/themes/'+theme_name+'/');templater.addVariable('infowindow_snapshot','favorite_check',$(xml).find("UserFavorite").text()=='true'?'checked':'');var attr='';var beds=$(xml).find("Bedrooms").text();var baths=$(xml).find("Bathrooms").text();var squareFeet=$(xml).find("SquareFeet").text();var status=$(xml).find("Status").text();if(beds&&beds!='0.00')attr+=beds+" bedroom";if(baths&&baths!='0.00')attr+=(attr?', ':'')+baths+" bath";if(squareFeet)attr+=(attr?', ':'')+squareFeet+" sq. ft.";if(status)attr+=(attr?', ':'')+status;templater.addVariable('infowindow_snapshot','attribute_summary',attr);templater.hideOption('infowindow_snapshot','favorite_link');var open_houses=$(xml).find("OpenHouse");if(open_houses.size()>0)
{var open_house_html='';$(xml).find("OpenHouse").each(function(index)
{open_house_html+='<li>'+$(this).text()+'</li>';if(index==1)return false;});var count=$(xml).find("OpenHouse").size();if(count>2)
{var more=count-2;var ln=$(xml).find("MlsNumber").text();var ptype=$(xml).find("PropertyType").text();open_house_html+="<li><a href='property_detail.php?ln="+ln+"&ptype="+ptype+"'>"+more+" more...</a></li>";}
templater.addVariable('infowindow_snapshot','open_houses',open_house_html);}
else
{templater.hideOption('infowindow_snapshot','open_houses');}
var infowindowHtml=templater.getHTML('infowindow_snapshot');var markerPoint=map.fromLatLngToContainerPixel(currentMarker.getPoint());var mapSize=map.getSize();$("#infowindow").html(infowindowHtml);if((mapSize.width-markerPoint.x)<265)
{$("#infowindow").css('left',(markerPoint.x-260)+'px');$("#infowindow div#arrow").removeClass('arrow_left');$("#infowindow div#arrow").addClass('arrow_right');}
else
{$("#infowindow").css('left',(markerPoint.x+45)+'px');$("#infowindow div#arrow").removeClass('arrow_right');$("#infowindow div#arrow").addClass('arrow_left');}
$("#infowindow").css('top',(markerPoint.y-25)+'px');$("#infowindow").show();localPopupify("div.infowindow_snapshot");appendAid();$(".favorite_check","div.infowindow_snapshot").click(function()
{addToFavorites($(this).val(),$(this).attr('id'));});}
function parseSearchResultsXml(xml)
{var responses="";$(xml).find("Response").each(function()
{responses+="<li>"+$(this).text()+"</li>";});if(responses.length>0)setMessage("<ul>"+responses+"</ul>");var rowCount=$(xml).find("RowCount").text();var pageCount=$(xml).find("PageCount").text();var currentPage=$(xml).find("CurrentPage").text();var recordsPerPage=$(xml).find("RecordsPerPage").text();$("#row_count").val(rowCount);$("#async_notify").removeClass("loading");$("#results_summary").html(rowCount+" results on "+pageCount+" pages.");var icon_number=(recordsPerPage*(currentPage-1))+1;var listings=[];$(xml).find("Listing").each(function()
{var is_favorite=$(this).find("UserFavorite").text()=='true';var listing=[];listing["title"]=$(this).find("Title").text();listing["price"]=$(this).find("Price").text();listing["address"]=$(this).find("Address").text();listing["image_src"]=$(this).find("ImageSrc").text();listing['mls_number']=$(this).find("MlsNumber").text();listing['property_type']=$(this).find("PropertyType").text();listing['status']=$(this).find("Status").text();listing['icon_number']="<img src=\"images/map_icon.php?text="+(icon_number++)+"&icon=../images/themes/"+theme_name+"/find/map_icon"+(is_favorite?'_favorite':'')+"\" />";listing['favorite_check']=is_favorite?'checked':'';var attr='';var beds=$(this).find("Bedrooms").text();var baths=$(this).find("Bathrooms").text();var squareFeet=$(this).find("SquareFeet").text();if(beds&&beds!='0.00')attr+=beds+" bedroom";if(baths&&baths!='0.00')attr+=(attr?', ':'')+baths+" bath";if(squareFeet)attr+=(attr?', ':'')+squareFeet+" sq. ft.";listing['attribute_summary']=attr;var open_houses=$(this).find("OpenHouse");if(open_houses.size()>0)
{var open_house_html='';$(this).find("OpenHouse").each(function(index)
{open_house_html+='<li>'+$(this).text()+'</li>';if(index==1)return false;});var count=$(this).find("OpenHouse").size();if(count>2)
{var more=count-2;var ln=listing['mls_number'];var ptype=listing['property_type'];open_house_html+="<li><a href='property_detail.php?ln="+ln+"&ptype="+ptype+"'>"+more+" more...</a></li>";}
listing['open_houses']=open_house_html;}
else
{listing['hideoption']='open_houses';}
listings.push(listing);});var templater=new cTemplate();var snapshotHtml=$(xml).find("SnapshotHtml").text();templater.loadTemplate(snapshotHtml);var resultsHtml=templater.repeater("search_snapshot",listings,['favorite_link']);if(!($("#results_list").html().indexOf('Map Instructions')>-1&&resultsHtml==''))
{$("#results_list").html(resultsHtml);}
var paginationItemHtml=$(xml).find("PaginationItem").text();templater.loadTemplate(paginationItemHtml);paginator=new cPaginator(currentPage,pageCount);paginationHtml=templater.repeater("pagination_item",paginator.getPaginationArray());$(".paginator").html(paginationHtml);$("div.paginator a").each(function()
{$(this).click(function(e)
{var page=$(this).attr("href").split("=")[1];updateSearchBuffers(["CurrentPage"],[page]);setSearchRequestTimer();e.stopPropagation();return false;});});if($(xml).find("SearchMode").text()=="map"&&$(xml).find("NoDatasetChange").text()=="false")
{map.clearOverlays();markers=[];marker_icons=[];sendAddMarkerRequest();}
localPopupify("div#results_list");stripeResults("div#results_list");appendAid();$(".favorite_check","div.search_snapshot").click(function()
{addToFavorites($(this).val(),$(this).attr('id'));});attachMapIconGlow();xhrSearch=null;if(showSearchTimes===true)
{var timerResults=$(xml).find("Timer").text();$('body').append('<div class="timer">'+timerResults+'</div>');}
if(debugMode===true)
{if($("#search_sql").length==0)
{$("#footer").after("<div id=\"search_sql\" style=\"background: #FFFFE0;\"></div>");}
$("#search_sql").html($(xml).find("ListSql").text());}}
function parseSaveSearchResultsXml(xml)
{$("#async_notify").removeClass("loading");var responses="";$(xml).find("Response").each(function()
{responses+=$(this).text()+"\n";});if(responses.length>0)setMessage(responses);}
function searchStart(message)
{$("#infowindow").hide();setMessage("");setAsyncMessage(message);}
function sendAddMarkerRequest()
{var rowCount=$("#row_count").val()*1;if(rowCount==0)return;if(rowCount>300)
{setMessage("Too many properties to show on the map!");}
else
{setAsyncMessage('Loading map...')
xhrLoadMarkers=$.ajax({url:root_path+"/async/map_markers.xml.php",type:"POST",data:'',dataType:"xml",timeout:30000,cache:false,success:parseAddMarkersXml,complete:function()
{$("#async_notify").removeClass('loading');}});}}
function sendSearchRequest()
{setMessage('');var message='Searching for properties...';if(searchNamesBuffer.length==1)
{switch(searchNamesBuffer[0])
{case'CurrentPage':message='Getting page '+searchValuesBuffer[0]+'...';break;case'SortField':message='Sorting by '+$("#sort_field option:selected").html()+'...';break;case'SortOrder':message='Sorting '+$("#sort_order option:selected").html()+'...';break;case'RecordsPerPage':message='Showing '+$("#page_size option:selected").html()+'...';break;}}
searchStart(message);var post="";for(var i=0;i<searchValuesBuffer.length;i++)
{if(searchNamesBuffer[i].indexOf("[")!==-1)
{var values=searchValuesBuffer[i].split(',');for(j=0;j<values.length;j++)
{if(post.length>0)post+="&";post+=searchNamesBuffer[i]+"="+values[j];}}
else
{if(post.length>0)post+="&";post+=searchNamesBuffer[i]+"="+searchValuesBuffer[i];}}
if(post.indexOf("CurrentPage")==-1)
{if(post.length>0)post+="&";post+="CurrentPage=1";}
xhrSearch=$.ajax({url:root_path+"/async/search_results.xml.php",type:"POST",data:post,dataType:"xml",timeout:30000,cache:false,success:parseSearchResultsXml});}
function setSearchRequestTimer()
{if(xhrSearch!==null)
{xhrSearch.abort();xhrSearch=null;}
if(xhrLoadMarkers!==null)
{xhrLoadMarkers.abort();xhrLoadMarkers=null;}
if(searchRequestDelay!==null)
{clearTimeout(searchRequestDelay);searchRequestDelay=null;}
searchRequestDelay=setTimeout(function()
{sendSearchRequest();names=null;values=null;},500);}
function sendSaveSearchRequest()
{setAsyncMessage('Saving your search...');$.ajax({url:root_path+"/async/save_search.xml.php",type:"POST",data:"",dataType:"xml",timeout:30000,cache:false,success:parseSaveSearchResultsXml});}
function datePickerClosed(textbox)
{updateSearchBuffers([$('#'+textbox.id).attr("name")],[$('#'+textbox.id).val()]);setSearchRequestTimer();}
function setAsyncMessage(message)
{$("#async_notify").html("<img src=\"images/ajax-loader.gif\" /><span>"+message+"</span>");$("#async_notify").addClass("loading");}
function collapsePropertyAttributes()
{$("#search_options ol").hide();$("#search_options .legend .control").unbind('click');$("#search_options .legend .control").click(expandPropertyAttributes);$("#search_options .legend .control").html("<img src='images/themes/"+theme_name+"/find/max_fieldset.png' title='Maximize Search Criteria' />");var minPrice=$("#minimum_price_select").val();var maxPrice=$("#maximum_price_select").val();var minPriceRentals=$("#minimum_rent_select").val();var maxPriceRentals=$("#maximum_rent_select").val();var bedrooms=$("#bedrooms").val();var bathrooms=$("#bathrooms").val();var squareFeet=$("#square_feet").val();var lofSquareFeetMin=$("#lot_square_feet_min").val();var lofSquareFeetMax=$("#lot_square_feet_max").val();var garageSpace=$("#garage_space").val();var newOnMarket=$("#new_on_market").val();html=[];if(minPrice>0&&maxPrice<10000000)
{html.push('Price between '+minPrice.formatMoney('$','',',','.',0,0)+' and '+maxPrice.formatMoney('$','',',','.',0,0));}
else if(minPrice>0||maxPrice<10000000)
{if(minPrice>0)
{html.push('Price more than '+minPrice.formatMoney('$','',',','.',0,0));}
else
{html.push('Price less than '+maxPrice.formatMoney('$','',',','.',0,0));}}
if(lofSquareFeetMin!=''&&lofSquareFeetMax!='')
{html.push('Lot size between '+lofSquareFeetMin+' and '+lofSquareFeetMax+' sq. ft.');}
else if(lofSquareFeetMin!=''||lofSquareFeetMax!='')
{if(lofSquareFeetMin!='')
{html.push('Lot size at least '+lofSquareFeetMin+' sq. ft.');}
else
{html.push('Lot size smaller than '+lofSquareFeetMax+' sq. ft.');}}
if(bedrooms>0)html.push(bedrooms+'+ bedrooms');if(bathrooms>0)html.push(bathrooms+'+ bathrooms');if(squareFeet>0)html.push(squareFeet+'+ sq. ft.');if(garageSpace>0)html.push(garageSpace+'+ car garage');if(newOnMarket>0)html.push('Listed in the last '+newOnMarket);$("#search_options .summary").html((html.length>0?html.join('<br />'):"No attributes selected"));$("#search_options .summary").show();saveToSession('prop_attr_state','collapsed');return false;}
function expandPropertyAttributes()
{$("#search_options .summary").hide();$("#search_options ol").show();$("#search_options .legend .control").unbind('click');$("#search_options .legend .control").click(collapsePropertyAttributes);$("#search_options .legend .control").html("<img src='images/themes/"+theme_name+"/find/min_fieldset.png' title='Minimize Search Criteria' />");saveToSession('prop_attr_state','expanded');return false;}
function collapsePropertyTypes()
{$("#property_types ol").hide();$("#property_types .legend .control").unbind('click');$("#property_types .legend .control").click(expandPropertyTypes);$("#property_types .legend .control").html("<img src='images/themes/"+theme_name+"/find/max_fieldset.png' title='Maximize Property Types' />");html=[];if($("#ptype_resi").attr("checked")==true)html.push("residential");if($("#ptype_cond").attr("checked")==true)html.push("condominium");if($("#ptype_mult").attr("checked")==true)html.push("multi-family");if($("#ptype_vacl").attr("checked")==true)html.push("vacant land");if($("#ptype_comi").attr("checked")==true)html.push("commercial");if($("#ptype_farm").attr("checked")==true)html.push("farm");if($("#ptype_manu").attr("checked")==true)html.push("manufactured homes");$("#property_types .summary").html((html.length>0?html.join(', '):"No property type selected"));$("#property_types .summary").show();saveToSession('prop_types_state','collapsed');return false;}
function expandPropertyTypes()
{$("#property_types .summary").hide();$("#property_types ol").show();$("#property_types .legend .control").unbind('click');$("#property_types .legend .control").click(collapsePropertyTypes);$("#property_types .legend .control").html("<img src='images/themes/"+theme_name+"/find/min_fieldset.png' title='Minimize Property Types' />");saveToSession('prop_types_state','expanded');return false;}
function collapsePropertyFeatures()
{$("#property_features ol").hide();$("#property_features .legend .control").unbind('click');$("#property_features .legend .control").click(expandPropertyFeatures);$("#property_features .legend .control").html("<img src='images/themes/"+theme_name+"/find/max_fieldset.png' title='Mazimize Property Features' />");html=[];if($("#feature_view").attr("checked")==true)html.push("Properties with a view");if($("#feature_waterfront").attr("checked")==true)html.push("Properties on the water");if($("#feature_newconstruction").attr("checked")==true)html.push("New contruction");$("#property_features .summary").html((html.length>0?html.join(', '):"No features selected"));$("#property_features .summary").show();saveToSession('prop_features_state','collapsed');return false;}
function expandPropertyFeatures()
{$("#property_features .summary").hide();$("#property_features ol").show();$("#property_features .legend .control").unbind('click');$("#property_features .legend .control").click(collapsePropertyFeatures);$("#property_features .legend .control").html("<img src='images/themes/"+theme_name+"/find/min_fieldset.png' title='Minimize Property Features' />");saveToSession('prop_features_state','expanded');return false;}
function collapseSearchTypes()
{$("#search_types ol").hide();$("#search_types .legend .control").unbind('click');$("#search_types .legend .control").click(expandSearchTypes);$("#search_types .legend .control").html("<img src='images/themes/"+theme_name+"/find/max_fieldset.png' title='Maximize Search Types' />");html=[];if($("#for_purchase").attr("checked")==true)html.push("Properties for sale");if($("#for_rentals").attr("checked")==true)html.push("Properties for rent");if($("#for_openhouse").attr("checked")==true)html.push("Open houses "+$("#open_house_time option:selected").val());if($("#for_sold").attr("checked")==true)
{var from_date=$("#sold_from_date").val();var to_date=$("#sold_to_date").val();if(from_date!=''&&to_date!='')
{html.push("Properties sold between "+from_date+" and "+to_date);}
else if(from_date!='')
{html.push("Properties sold after "+from_date);}
else if(to_date!='')
{html.push("Properties sold before "+to_date);}
else
{html.push("Sold properties");}}
$("#search_types .summary").html((html.length>0?html.join(', '):""));$("#search_types .summary").show();saveToSession('search_type_state','collapsed');return false;}
function expandSearchTypes()
{$("#search_types .summary").hide();$("#search_types ol").show();$("#search_types .legend .control").unbind('click');$("#search_types .legend .control").click(collapseSearchTypes);$("#search_types .legend .control").html("<img src='images/themes/"+theme_name+"/find/min_fieldset.png' title='Minimize Search Types' />");saveToSession('search_type_state','expanded');return false;}
function minimizeCriteriaOrAccount()
{$("#infowindow").hide();sidebarContent=='criteria'?$("#criteria").hide():$("#account").hide();$("#criteria_account_selector").hide();$("#max_criteria").show();$("#results_summary").addClass('wider');$("#location").addClass('wider');$("#results").addClass('wider');$("#search_modes").addClass('wider');$("#messagebox").addClass('wider');saveToSession('search_sidebar_state','minimized');map.checkResize();if($("#map_mode").css("display")!="none")mapSizeChange();}
function maximizeCriteriaOrAccount()
{$("#infowindow").hide();sidebarContent=='criteria'?$("#criteria").show():$("#account").show();$("#criteria_account_selector").show();$("#max_criteria").hide();$("#results_summary").removeClass('wider');$("#location").removeClass('wider');$("#results").removeClass('wider');$("#search_modes").removeClass('wider');$("#messagebox").removeClass('wider');saveToSession('search_sidebar_state','maximized');map.checkResize();if($("#map_mode").css("display")!="none")mapSizeChange();}
function showSearchMode(mode)
{$('#city_mode').css('display',mode=='city'?'block':'none');$('#zip_mode').css('display',mode=='zip'?'block':'none');$('#address_mode').css('display',mode=='address'?'block':'none');$('#mls_mode').css('display',mode=='mls'?'block':'none');$('#map_mode').css('display',mode=='map'?'block':'none');var criteriaDisplay=(mode=='city'||mode=='zip'||mode=='map'?'block':'none');$('#search_options').css('display',criteriaDisplay);$('#search_types').css('display',criteriaDisplay);$('#property_types').css('display',criteriaDisplay);$('#property_features').css('display',criteriaDisplay);if(mode=='map')
{initializeMap();map.checkResize();}
$("ul#search_modes li").removeClass("selected");$("ul#search_modes li#"+mode+"_mode_select").addClass("selected");$("#criteria_select a").click();}
function showSearchType(type)
{$('.no_rental').css('display',type=='rentals'?'none':'block');$('.rental_only').css('display',type=='rentals'?'block':'none');$('#sold_date_options').css('display',type=='sold'?'block':'none');$('#open_house_options').css('display',type=='openhouse'?'block':'none');}
function updateCityBuffer()
{$("select#city_select option").each(function(){if($(this).val().indexOf('_ALL')>0&&$(this).attr("selected")==true)
{var county=$(this).val().substring(0,$(this).val().indexOf('_'));selectAllCitiesInCountyMacro(county);}
else
{city_buffer[$(this).val()]=($(this).attr("selected")==true);}});}
function updateAreaBuffer()
{if($('select#area_select option:first').attr("selected")==true&&$('select#area_select option:first').val()=='ALL_ALL')
{selectAllAreasMacro();}
else
{$("select#area_select option").each(function()
{if($(this).val().indexOf('_ALL')>0&&$(this).attr("selected")==true)
{var city=$(this).val().substring($(this).val().indexOf('_')+1,$(this).val().lastIndexOf('_'));selectAllAreasInCityMacro(city);}
else
{area_buffer[$(this).val()]=($(this).attr("selected")==true);}});}}
function populateCitySelect()
{city_select=$('#city_select').get(0);county_select=$('#county_select').get(0);city_select.options.length=0;optionCounter=0;for(i=0;i<county_select.length;i++)
{if(county_select[i].selected==true)
{thisCounty=cc_list[county_select[i].value];city_select.options[optionCounter++]=new Option('-- All '+county_select[i].value+' cities',county_select[i].value+'_ALL')
for(j=0;j<thisCounty.length;j++)
{city_select.options[optionCounter]=new Option(thisCounty[j],county_select[i].value+'_'+thisCounty[j])
if(city_buffer[county_select[i].value+'_'+thisCounty[j]]==true)
{city_select.options[optionCounter].selected=true;}
optionCounter++;}}}}
function populateAreaSelect()
{area_select=$('#area_select').get(0);city_select=$('#city_select').get(0);area_select.options.length=0;optionCounter=0;selectedCityCount=0;for(i=0;i<city_select.options.length;i++)if(city_select.options[i].selected)selectedCityCount++;if(selectedCityCount>1)
{area_select.options[optionCounter++]=new Option('-- All neighborhoods','ALL_ALL')}
for(i=0;i<city_select.length;i++)
{if(city_select[i].selected==true)
{var cityArea=city_select[i].value;var posUnder=cityArea.indexOf('_');var cityName=cityArea.substring(posUnder+1)
var thisCity=ca_list[cityName];if(cityName!="ALL")
{area_select.options[optionCounter++]=new Option('-- All '+cityName+' neighborhoods',city_select[i].value+'_ALL')
for(j=0;j<thisCity.length;j++)
{area_select.options[optionCounter]=new Option(thisCity[j],city_select[i].value+'_'+thisCity[j])
if(area_buffer[city_select[i].value+'_'+thisCity[j]]==true)
{area_select.options[optionCounter].selected=true;}
optionCounter++;}}}}}
function selectAllCitiesInCountyMacro(county)
{city_select=$('#city_select').get(0);for(i=0;i<city_select.length;i++)
{var optionValue=city_select[i].value;var posUnder=optionValue.indexOf('_');var thisCounty=optionValue.substring(0,posUnder);if(thisCounty==county)
{city_select[i].selected=true;city_buffer[city_select[i].value]=true;}}}
function selectAllAreasInCityMacro(city)
{area_select=$('#area_select').get(0);for(i=0;i<area_select.length;i++)
{var optionValue=area_select[i].value;var posFirstUnder=optionValue.indexOf('_');var posLastUnder=optionValue.lastIndexOf('_');var thisCity=optionValue.substring(posFirstUnder+1,posLastUnder);if(thisCity==city)
{area_select[i].selected=true;area_buffer[area_select[i].value]=true;}}}
function selectAllAreasMacro()
{$("select#area_select option").each(function()
{$(this).attr("selected",true);area_buffer[$(this).val()]=true;});}
function deselectMacroOptions(selectBox)
{$("option",selectBox).each(function()
{if($(this).val().indexOf('_ALL')!=-1)
{$(this).attr("selected",false);}});}
function showFavoritesList()
{$('#favorites').css('display','block');$('#saved_searches').css('display','none');saveToSession('mySkylineView','showFavoriteHomes');}
function showSavedSearchList()
{$('#favorites').css('display','none');$('#saved_searches').css('display','block');saveToSession('mySkylineView','showSavedSearches');}
function saveToSession(name,value)
{$.post(root_path+"/async/set_session_var.php","var="+name+"&value="+value);}
function localPopupify(context)
{popupify(user_logged_in,context);}
function appendAid(context)
{if(aid!=0)
{$('a').each(function()
{var href=String($(this).attr('href'));if(href.indexOf('aid')==-1)
{var separator=(href.indexOf('?')==-1?'?':'&');$(this).attr('href',href+separator+'aid='+aid);}});}}
function setMessage(message)
{if(message.length>0)
{$("#messagebox").html(message);}
else
{$("#messagebox").html('');}}
function stripeResults()
{$("#results_list > div:even").addClass("search_snapshot_alt");}
function attachMapIconGlow()
{$(".search_snapshot").each(function(i)
{var icon_src=$(".icon_number img",this).attr('src');var start=icon_src.indexOf('text=')+5;var end=icon_src.indexOf('&');var icon_number=icon_src.slice(start,end);$(this).hover(function()
{if(markers.length>0&&$("#map_mode").css("display")!="none")
{var active_icon="http://www.skylineproperties.com"+root_path+"/images/map_icon.php?text="+icon_number+"&icon=themes/"+theme_name+"/find/map_icon_active";markers[icon_number].setImage(active_icon);$(".icon_number img",this).attr('src',active_icon);var ln=$('.title em',this).html().replace('MLS# ','');var table=($('.status',this).html()=='Sold'?'nwmls_sold':'nwmls_active');currentMarker=markers[icon_number];$.ajax({url:root_path+"/async/infowindow_snapshot.xml.php",type:"POST",data:"ln="+ln+'&table='+table,dataType:"xml",timeout:30000,cache:false,success:parseInfowindowXml});}},function()
{if(markers.length>0&&$("#map_mode").css("display")!="none")
{markers[icon_number].setImage(marker_icons[icon_number]);$(".icon_number img",this).attr('src',marker_icons[icon_number]);}});});}
function mapSizeChange()
{var bounds=map.getBounds();var SW=bounds.getSouthWest();var NE=bounds.getNorthEast();updateSearchBuffers(['MapSWLat','MapSWLng','MapNELat','MapNELng','SearchMode'],[SW.lat(),SW.lng(),NE.lat(),NE.lng(),'map']);setSearchRequestTimer();}
function moveSaveControls(targetId)
{var targetSelector='#'+targetId;var sourceSelector=(targetId=='criteria'?'#account':'#criteria');$('.savesearchas',sourceSelector).clone(true).prependTo(targetSelector);$('.savesearchas',sourceSelector).remove();$('#loaded_search',sourceSelector).clone(true).prependTo(targetSelector);$('#loaded_search',sourceSelector).remove();}
function SkylineZoomPanControl()
{}
SkylineZoomPanControl.prototype=new GControl();SkylineZoomPanControl.prototype.initialize=function(map)
{var container=document.createElement("div");container.style.position="relative";container.style.height="40px";container.style.width="78px";container.style.background="transparent url("+root_path+"/images/themes/"+theme_name+"/find/d-pad.png) no-repeat";var zoomPanNorth=document.createElement("div");this.setButtonStyle_(zoomPanNorth,5,12,15,6,"Pan North");container.appendChild(zoomPanNorth);GEvent.addDomListener(zoomPanNorth,"click",function(){map.panDirection(0,+1);});var zoomPanEast=document.createElement("div");this.setButtonStyle_(zoomPanEast,12,28,6,15,"Pan East");container.appendChild(zoomPanEast);GEvent.addDomListener(zoomPanEast,"click",function(){map.panDirection(-1,0);});var zoomPanSouth=document.createElement("div");this.setButtonStyle_(zoomPanSouth,28,12,15,6,"Pan South");container.appendChild(zoomPanSouth);GEvent.addDomListener(zoomPanSouth,"click",function(){map.panDirection(0,-1);});var zoomPanWest=document.createElement("div");this.setButtonStyle_(zoomPanWest,12,5,6,15,"Pan West");container.appendChild(zoomPanWest);GEvent.addDomListener(zoomPanWest,"click",function(){map.panDirection(+1,0);});var zoomInDiv=document.createElement("div");this.setButtonStyle_(zoomInDiv,5,45,28,11,"Zoom In");container.appendChild(zoomInDiv);GEvent.addDomListener(zoomInDiv,"click",function(){map.zoomIn();});var zoomOutDiv=document.createElement("div");this.setButtonStyle_(zoomOutDiv,22,45,28,11,"Zoom Out");container.appendChild(zoomOutDiv);GEvent.addDomListener(zoomOutDiv,"click",function(){map.zoomOut();});map.getContainer().appendChild(container);return container;}
SkylineZoomPanControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0));}
SkylineZoomPanControl.prototype.setButtonStyle_=function(button,top,left,width,height,title)
{button.style.position="absolute";button.style.top=top+'px';button.style.left=left+'px';button.style.height=height+'px';button.style.width=width+'px';button.style.cursor="pointer";button.title=title;}
function SkylineMapTypeControl()
{}
SkylineMapTypeControl.prototype=new GControl();SkylineMapTypeControl.prototype.initialize=function(map)
{var container=document.createElement("div");container.style.position="relative";container.style.height="31px";container.style.width="106px";container.style.background="transparent url("+root_path+"/images/themes/"+theme_name+"/find/map_type.png) no-repeat";container.style.cursor="pointer";var popup=document.createElement("ul");popup.id="map_type_popup";popup.style.listStyleType="none";popup.style.padding="0";popup.style.margin="0";popup.style.position="absolute";popup.style.top="25px";popup.style.left="2px";popup.style.width="99px";popup.style.border="1px solid #977F6A";popup.style.background="#8296D8";popup.style.display="none";this.addMapType_(popup,"Street",G_NORMAL_MAP);this.addMapType_(popup,"Satellite",G_SATELLITE_MAP);this.addMapType_(popup,"Hybrid",G_HYBRID_MAP);this.addMapType_(popup,"Terrain",G_PHYSICAL_MAP);container.appendChild(popup);GEvent.addDomListener(container,"click",function()
{var popup=document.getElementById("map_type_popup");popup.style.display=(popup.style.display=="none"?"block":"none");});map.getContainer().appendChild(container);return container;}
SkylineMapTypeControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(0,0));}
SkylineMapTypeControl.prototype.addMapType_=function(popup,name,map_type_constant)
{var map_type=document.createElement("li");map_type.style.padding="4px";map_type.style.cursor="pointer";map_type.style.background="#8296D8";map_type.style.color="#ffffff";map_type.setAttribute("onmouseover","this.style.background = '#B0BCE6';");map_type.setAttribute("onmouseout","this.style.background = '#8296D8';");map_type.appendChild(document.createTextNode(name));GEvent.addDomListener(map_type,"click",function()
{map.setMapType(map_type_constant);saveToSession('MapType',name);});popup.appendChild(map_type);}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}