/**
* Copyright (c) 2006 Andriy Bidochko. All Rights Reserved.
* http://www.mapbuilder.net
*
* This code (including but not limited to the actual source code, documentation and database schemes) 
* is not freeware and is intended for the use of the original license purchaser according to the license agreement.
* The code all or in part may not be sold, redistributed, or included as part of another application.
* 
* THIS SOFTWARE PRODUCT IS PROVIDED "AS IS" AND LICENSOR MAKE NO WARRANTY AS TO ITS USE, PERFORMANCE, 
* OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function GetRealEstetaJSONDate(jData){try{var markers=mapdata.markers;for(var i=0;i<markers.length;i++){id=i;var Property=null;try{Property=markers[i].Property;if(Property!=''){MAPBUILDER.widget.MapObject.Ref.markers[id].Property=Property;}
else
MAPBUILDER.widget.MapObject.Ref.markers[id].Property=null;}
catch(e){}}}
catch(e){}}
function onMarkerClick(id,point,html,iconname){try{document.getElementById('dImg').innerHTML='';document.getElementById('dImages').innerHTML='';var Property=MAPBUILDER.widget.MapObject.Ref.markers[id].Property;if(Property!=null){try{var images=Property.Images;for(var i=0;i<images.length;i++){if(i==0)addImg('dImg','<img src="'+images[i].ImageUrl+'" alt="Image">')
addImg('dImages','<img src="'+images[i].ImageUrl+'" alt="Image">')}}
catch(e){}
var addr=buildAddrStr(MAPBUILDER.widget.MapObject.Ref.markers[id].address,MAPBUILDER.widget.MapObject.Ref.markers[id].city,MAPBUILDER.widget.MapObject.Ref.markers[id].zip,MAPBUILDER.widget.MapObject.Ref.markers[id].state,MAPBUILDER.widget.MapObject.Ref.markers[id].country);document.getElementById('dFeatures').style.display='none';setText('dTitle',MAPBUILDER.widget.MapObject.Ref.markers[id].name);setText('dAddress',addr);setText('dDescription',MAPBUILDER.widget.MapObject.Ref.markers[id].description);setText('dPrice',Property.Currency+'&nbsp;'+MAPBUILDER.util.formatNumber(Property.Price));setText('dShortInfo',Property.Bedrooms+' BR, '+Property.Bathrooms+' Bath');setText('Type',Property.Type+', '+Property.Status);setText('BuildDate',Property.BuildDate);setText('Bedrooms',Property.Bedrooms);setText('Bathrooms',Property.Bathrooms);setText('Garage',Property.Garage);setText('GarageCars',Property.GarageCars);setText('Stories',Property.Stories);setText('Square',Property.Square+", "+Property.Unit);setText('Notes',Property.Notes);setBool('AC',Property.AC);setBool('Pool',Property.Pool);setBool('Spa',Property.Spa);setBool('Fireplace',Property.Fireplace);setBool('MasterBedroom',Property.MasterBedroom);setBool('DiningRoom',Property.DiningRoom);setBool('Library',Property.Library);setBool('SeparateFamilyRoom',Property.SeparateFamilyRoom);setBool('SeparateLivingUnit',Property.SeparateLivingUnit);setBool('Basement',Property.Basement);document.getElementById('dFeatures').style.display='block';}
document.getElementById('propertyInfoNo').style.display='none';document.getElementById('propertyInfo').style.display='block';tabbedPane.set('detail');}
catch(e){}}
function onRenderMarkers(){if(MAPBUILDER.widget.MapObject.Ref.sideBar){MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML="";}
var html,price,tmpHtml;tmpHtml='';for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.markers.length;i++){if(!MAPBUILDER.widget.MapObject.Ref.markers[i].visible)continue;try{price=MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Price.substring(0,MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Price.length-3);html=MAPBUILDER.util.trunkStr(MAPBUILDER.widget.MapObject.Ref.markers[i].name,20);if(MAPBUILDER.widget.MapObject.Ref.sideBar){tmpHtml+='<tr><td>'+MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Currency;tmpHtml+=((price=='')?'0':price)+"K</td><td>"+"<a href='javascript:MAPBUILDER.event.infoLink("+i+");'>"+html+"</a><br>";tmpHtml+='</td></tr>';}}
catch(e){}}
if(tmpHtml!=''){document.getElementById('sidebarHeader').innerHTML='<table><tbody><thead><tr><th>Price</th><th>Description</th></tr></thead></tbody></table>';tmpHtml='<table><tbody>'+tmpHtml+'</tbody></table>';}
MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML=tmpHtml;}
function onCreateMarker(id,marker){var images=MAPBUILDER.widget.MapObject.Ref.markers[id].Property.Images;var imgTag='';for(var i=0;i<images.length;i++){if(i==0)imgTag='<img src="'+images[i].ImageUrl+'" alt="Image">';}
marker.setTooltip(MAPBUILDER.widget.MapObject.Ref.markers[id].Property.Currency+MAPBUILDER.util.formatNumber(MAPBUILDER.widget.MapObject.Ref.markers[id].Property.Price)+"<br/>"+imgTag);marker.setOpacity(100);return marker;}
function showPropertyInfo(id){alert("showPropertyInfo"+id);}
function buildAddrStr(a,c,z,s,co){var addr=(a=='')?'':(a+'<br />');addr=(addr=='')?((c=='')?'':c):(addr+((c=='')?'':(c+', ')));addr=(addr=='')?((s=='')?'':s):(addr+((s=='')?'':(s+' ')));addr=(addr=='')?((z=='')?'':z):(addr+((z=='')?'':(z)));return addr;}
function addImg(id,value){document.getElementById(id).innerHTML=(document.getElementById(id).innerHTML=='')?value:(document.getElementById(id).innerHTML+"<br />"+value);}
function setText(id,value){document.getElementById(id).innerHTML=value;}
function setBool(id,value){document.getElementById(id).innerHTML=(value=='1')?'Y':'N';}
function appLayoutSize(){var clientWidth=document.body.clientWidth;var cliHeight=document.body.clientHeight;var d=550;var dd=22;var widthPx=(clientWidth-d)+"px";var widthPx2=(clientWidth-d-dd)+"px";if((clientWidth-d)<250){var widthPx="250px";var widthPx2="228px";}
document.getElementById("content").style.width=clientWidth+"px";document.getElementById("mapColumn").style.width=widthPx;document.getElementById("tabbedPane2").style.width=widthPx;document.getElementById("mapcontainer").style.width=widthPx2;}
function resizeMap(){appLayoutSize();MyMapObject.onResize();}
function doSearch(){document.getElementById('statusBar').innerHTML='Searching...';var isHouse=document.getElementById('House').checked;var isCondo=document.getElementById('Condo').checked;var isApartment=document.getElementById('Apartment').checked;var isLot=document.getElementById('Lot').checked;var isAny=document.getElementById('Any').checked;var intMinBedrooms=MAPBUILDER.util.toInt(MAPBUILDER.util.getRadioValue(document.getElementById('F').MinBedrooms));var fMinBathrooms=MAPBUILDER.util.toFloat(MAPBUILDER.util.getRadioValue(document.getElementById('F').MinBathrooms));var intMinPrice=MAPBUILDER.util.toInt(document.getElementById('MinPrice').options[document.getElementById('MinPrice').selectedIndex].value);var intMaxPrice=MAPBUILDER.util.toInt(document.getElementById('MinPrice').options[document.getElementById('MaxPrice').selectedIndex].value);var price,bedrooms,bathrooms;var nFound=0;for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.markers.length;i++){try{MAPBUILDER.widget.MapObject.Ref.markers[i].visible=true;price=MAPBUILDER.util.toInt(MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Price);bedrooms=MAPBUILDER.util.toInt(MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Bedrooms);bathrooms=MAPBUILDER.util.toFloat(MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Bathrooms);if(price<intMinPrice){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(intMaxPrice>0&&price>intMaxPrice){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(!isAny){if(!isHouse&&MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='House'){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(!isCondo&&(MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Condo'||MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Townhouse')){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(!isApartment&&MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Apartment'){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(!isLot&&MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Lot/Land'){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
if(MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Farm'||MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Multi-Family'||MAPBUILDER.widget.MapObject.Ref.markers[i].Property.Type=='Other'){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}}
if(intMinBedrooms!=0){if(intMinBedrooms<5&&bedrooms<intMinBedrooms){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
else
if(intMinBedrooms>=5&&bedrooms<intMinBedrooms){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}}
if(intMinBedrooms!=0){if(intMinBedrooms<3&&bathrooms<fMinBathrooms){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}
else
if(intMinBedrooms>=3&&bathrooms<fMinBathrooms){MAPBUILDER.widget.MapObject.Ref.markers[i].visible=false;continue;}}
nFound++;}
catch(e){}}
document.getElementById('statusBar').innerHTML=nFound+' locations found.';MAPBUILDER.widget.MapObject.Ref.renderMarkers();}