var propertySearch_redirectTo="";
var propertySearch_isSimpleSearch=false;
var propertySearch_isOpeningPage=false;
var propertySearch_isPropertySearchPage=false;
var propertySearch_isCustomType=false;
var propertySearch_searchType="sale";
var propertySearch_searchSubType="suburb";
var propertySearch_searchOpening=false;
var propertySearch_searchCustom=false;
var propertySearch_suburbsSelected=new Object();
var propertySearch_firstSuburbAdded=false;
var propertySearch_suburbCarousel=null;
var propertySearch_suburbCarouselBlinkEnabled=true;
var propertySearch_autocompleteAddressAdded=false;
var propertySearch_suburbMapSelectorOpen=false;
var propertySearch_advancedSearchOpen=false;
var propertySearch_nullValue;
var propertySearch_options={dataType:"json",url:"/site/master.cfm?fuseaction=site-ajax.search",type:"POST",async:true,cache:false,beforeSubmit:function(formArray,qForm){if(propertySearch_check(qForm[0])){propertySearch_sendToAnalytics(qForm[0]);
propertySearch_prepareRedirection();
if(propertySearch_isOpeningPage==true){if(openingListing_changeEnabled==false){return false;
}}else{if(propertySearch_isPropertySearchPage==true){if(propertyListing_changeEnabled==false){return false;
}}}moveTop();propertySearch_lock();
if(contentDirection==DIRECTION_OPEN){maskClick();
}return true;}else{return false;
}},success:function(response){if(response.retcode=="OK"){if(propertySearch_redirectTo!=""){document.location.href=propertySearch_redirectTo;
}else{if(propertySearch_isOpeningPage==true){if(openingListing_changeEnabled==true){openingListing_switchToMode(openingListing_currentMode);
}}else{if(propertySearch_isOpeningPage==false){if(propertyListing_changeEnabled==true){if(response.retrecentlylisted>0){propertyListing_setOrder("sort_by_date_listed");
propertyListing_setOrderDirection("1");
}else{if(response.retrecentlysold>0){propertyListing_setOrder("sort_by_date_sold");
propertyListing_setOrderDirection("1");
}else{if(response.retmostviewed>0){propertyListing_setOrder("sort_by_most_viewed");
propertyListing_setOrderDirection("1");
}else{if(response.retrecentlyleased>0){propertyListing_setOrder("sort_by_date_leased");
propertyListing_setOrderDirection("1");
}else{propertyListing_setOrder("sort_by_price");
propertyListing_setOrderDirection("asc");
propertyListing_toggleSortStyle("sort_by_price","asc");
}}}}propertyListing_switchToPage(1);
propertyListing_refreshInterface();
}}}propertySearch_unlock();
}}else{alert("An error occured, please try again\n");
propertySearch_unlock();
}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("An error occured, please try again\n"+textStatus+" "+errorThrown);
propertySearch_unlock();
}};function propertySearch_lock(){$("#search_pre").html('<div id ="loader" class="preloader_light_16"></div>');
$("#search_pre").animate({opacity:"show"},{queue:"false",duration:100,easing:"linear"});
$(".searchButton").unbind();
}function propertySearch_unlock(){$("#search_pre").animate({opacity:"hide"},{queue:"false",duration:0,easing:"linear"});
$(".searchButton").animate({opacity:"show"},{queue:"false",duration:100,easing:"linear"});
$(".searchButton").bind("click",propertySearch_setSearch);
$(".searchButton").hoverClass2("buttonInputHover","buttonInputOut");
}function propertySearch_setSearch(){if(($("#suburbAuto").val()!="")&&($("#suburbAuto").val()!="Enter suburb or postcode")){$(".ac_over").click(function(){$("#suburbAuto").val("");
});$(".ac_over").click();
}var suburbIds="0";for(var elId in propertySearch_suburbsSelected){suburbIds+=","+propertySearch_suburbsSelected[elId].id;
}$("#searchSuburbIds").val(suburbIds);
clearCol3();$("#searchForm").ajaxSubmit(propertySearch_options);
return false;}function propertySearch_toggleInspectionTimes(attr1,attr2){if($("#"+attr1).attr("checked")==true){$("#"+attr2).addClass("checkBoxChecked");
$(".normalList .recent_options").find("input").css("display","none");
$(".normalList .recent_options").find("label").css("display","none");
propertySearch_searchOpening=true;
}else{$("#"+attr2).removeClass("checkBoxChecked");
$(".normalList .recent_options").find("input").css("display","inline");
$(".normalList .recent_options").find("label").css("display","inline");
propertySearch_searchOpening=false;
}}function propertySearch_selectInspectionTimes(attr1,attr2){$("#"+attr1).attr("checked",true);
propertySearch_toggleInspectionTimes(attr1,attr2);
}function propertySearch_deselectInspectionTimes(attr1,attr2){$("#"+attr1).attr("checked",false);
propertySearch_toggleInspectionTimes(attr1,attr2);
}function propertySearch_sendToAnalytics(myform){var searchCategory="";
var searchString="";var keywordStr="";
if(myform.land.checked){searchCategory+="land,";
}if(myform.apartment.checked){searchCategory+="apartment,";
}if(myform.house.checked){searchCategory+="house,";
}if(myform.commercial.checked){searchCategory+="commercial,";
}keywordStr=keywordStr.replace(myform.searchKeyword.value,"Enter Keywords","");
searchString="/search.html?searchType="+myform.searchType.value+"&minPriceVal="+myform.minPriceVal.value+"&maxPriceVal="+myform.maxPriceVal.value+"&bedsVal="+myform.bedsVal.value+"&bathsVal="+myform.bathsVal.value+"&parkingVal="+myform.parkingVal.value+"&keyword="+keywordStr+"&category="+searchCategory;
try{pageTracker._trackPageview(searchString);
}catch(err){}}function propertySearch_check(myform){why="";
focusfield="";if(why!=""){return false;
}else{return true;}}function propertySearch_clearAdvanced(searchType){$("#col1b .checkboxInput").attr("checked",false);
$("#col1b .clickLabel").removeClass("checkBoxChecked");
$("#bedsVal").val(0);
$("#bedsLabelText").html("Any");
$("#bedsOptions").fadeOut("fast");
$("#bathsVal").val(0);
$("#bathsLabelText").html("Any");
$("#bathsOptions").fadeOut("fast");
$("#parkingVal").val(0);
$("#parkingLabelText").html("Any");
$("#parkingOptions").fadeOut("fast");
$("#searchKeyword").val("Enter keywords...");
$("#suburbAuto").val("Enter suburb or postcode");
$("#propAddress").val("Enter address or property id");
}function propertySearch_clearNormal(searchType,openingPage){var tmpMinPriceOptions="";
var tmpMaxPriceOptions="";
if(searchType=="rent"){tmpMinPriceOptions=$("#minPriceOptionsRent").html();
tmpMaxPriceOptions=$("#maxPriceOptionsRent").html();
}else{if(searchType=="sale"){tmpMinPriceOptions=$("#minPriceOptionsSale").html();
tmpMaxPriceOptions=$("#maxPriceOptionsSale").html();
}}$("#minPriceOptions").html(tmpMinPriceOptions);
$("#maxPriceOptions").html(tmpMaxPriceOptions);
$("#minPriceVal").val(0);
$("#minPriceLabelText").html("Minimum price");
$("#minPriceOptions").fadeOut("fast");
$("#maxPriceVal").val(999999999);
$("#maxPriceLabelText").html("Maximum price");
$("#maxPriceOptions").fadeOut("fast");
$("#col1a .checkboxInput").attr("checked",false);
$("#col1a .clickLabel").removeClass("checkBoxChecked");
$("#col1a .textInput").val("");
if(openingPage==true){propertySearch_selectInspectionTimes("inspectionTimes","inspectionTimes_label");
}else{propertySearch_deselectInspectionTimes("inspectionTimes","inspectionTimes_label");
}$(".selectReplaceUL").hoverClass2("ul-hover","ul-out");
$(".selectReplaceUL-LI-UL > li").hoverClass2("li-hover","li-out");
$("#minPrice ul > li").click(function(){$("#minPriceVal").val($(this).attr("value"));
$("#minPriceLabelText").html($(this).html());
$("#minPriceOptions").fadeOut("fast");
});$("#maxPrice ul > li").click(function(){$("#maxPriceVal").val($(this).attr("value"));
$("#maxPriceLabelText").html($(this).html());
$("#maxPriceOptions").fadeOut("fast");
});if(propertySearch_suburbCarousel!=null){propertySearch_removeAllItems();
}}function propertySearch_clearAll(searchType,openingPage){propertySearch_clearNormal(searchType,openingPage);
propertySearch_clearAdvanced(searchType);
if($("#SST_SuburbPanelWrapper").css("display")=="block"){$("#SST_SuburbPanelWrapper").css("display","none");
}if(propertySearch_suburbMapSelectorOpen){getFlashReference("bw_sst").restartMapJs(searchType+"_"+currentDate);
propertySearch_showMapForm();
}}function switchToSearchType(searchType){propertySearch_clearAll(searchType,propertySearch_isOpeningPage);
$("#searchTypeSale, #searchTypeRent").removeClass("active");
if(searchType=="sale"){$("#searchType").val(searchType);
$("#searchTypeSale").addClass("active");
}else{if(searchType=="rent"){$("#searchType").val(searchType);
$("#searchTypeRent").addClass("active");
}}propertySearch_prepareSearch(propertySearch_isSimpleSearch,propertySearch_isOpeningPage,propertySearch_isPropertySearchPage,propertySearch_isCustomType,searchType,propertySearch_searchSubType);
}function propertySearch_prepareRedirection(){var redirect=false;
if(propertySearch_isSimpleSearch||(propertySearch_searchOpening&&!propertySearch_isOpeningPage)||(!propertySearch_searchOpening&&propertySearch_isOpeningPage)||(!propertySearch_searchCustom&&propertySearch_isCustomType)||(!propertySearch_isSimpleSearch&&!propertySearch_isOpeningPage&&!propertySearch_isPropertySearchPage)){redirect=true;
}if(redirect){if(propertySearch_searchType=="sale"){if(propertySearch_searchOpening){propertySearch_redirectTo="/real-estate/Buy/Open-Times";
}else{propertySearch_redirectTo="/real-estate/Buy/Property-Search";
}}else{if(propertySearch_searchType=="rent"){if(propertySearch_searchOpening){propertySearch_redirectTo="/real-estate/Rent/Open-Times";
}else{propertySearch_redirectTo="/real-estate/Rent/Property-Search";
}}}}else{propertySearch_redirectTo="";
}}function propertySearch_prepareSearch(isSimpleSearch,isOpeningPage,isPropertySearchPage,customType,searchType,searchSubType){propertySearch_isOpeningPage=isOpeningPage;
if(customType!=""){propertySearch_isCustomType=true;
}propertySearch_isPropertySearchPage=isPropertySearchPage;
propertySearch_isSimpleSearch=isSimpleSearch;
propertySearch_searchType=searchType;
if(propertySearch_searchSubType!=searchSubType){toggleSearchSubType(searchSubType);
}propertySearch_setAddressAutocomplete();
}function propertySearch_initSuburbCarousel(carousel){propertySearch_suburbCarousel=carousel;
}function propertySearch_nextButtonStateHandler(carousel,button,enabling){}function propertySearch_prevButtonStateHandler(carousel,button,enabling){}function propertySearch_addItem(data,pos,repopulating){if($("#SST_SuburbPanelWrapper").css("display")=="none"){$("#SST_SuburbPanelWrapper").css("display","block");
}var htmlEl="";htmlEl='<a href="#" onclick="return propertySearch_removeItem('+data.id+');return false;"></a>&nbsp;&nbsp; '+data.suburb+"<span> "+data.state+'</span><span class="postcode"> '+data.postcode+"</span>";
propertySearch_suburbCarousel.size(pos);
propertySearch_suburbCarousel.add(pos,htmlEl);
if(propertySearch_suburbMapSelectorOpen){getFlashReference("bw_sst").setSelectionJs(data.id,"add");
}if((repopulating!=1)&&propertySearch_suburbCarouselBlinkEnabled){$(".jcarousel-item-"+pos,"#SST_SuburbPanel").animate({color:"#ffffff",backgroundColor:"#46B3BA"},300).animate({color:"#888886",backgroundColor:"#252722"},500);
}}function propertySearch_setSelectedSuburbs(suburbsData,action){for(var i=0;
i<suburbsData.length;
i++){if(action=="remove"){propertySearch_removeItem(suburbsData[i][3]);
}else{propertySearch_selectItem(suburbsData[i]);
}}}function propertySearch_selectItem(data){var htmlEl="";
var elId=0;var elPos=0;
var elData;if(propertySearch_firstSuburbAdded==false){propertySearch_firstSuburbAdded=true;
loadSuburbPanel();}elId=data[3];
if(!(elId in propertySearch_suburbsSelected)&&data[3]!=0){elData={suburb:data[0],state:data[1],postcode:data[2],id:data[3]};
propertySearch_suburbsSelected[elId]=elData;
elPos=Object.size(propertySearch_suburbsSelected);
propertySearch_addItem(elData,elPos,0);
propertySearch_suburbCarousel.scroll(jQuery.jcarousel.intval(elPos));
}$("#suburbAuto").val("");
return true;}function propertySearch_removeItem(id){var el;
var elAddTo=0;var elMoveTo=0;
for(var elId in propertySearch_suburbsSelected){elMoveTo++;
if(elId==id){break;}}delete propertySearch_suburbsSelected[id];
if(propertySearch_suburbMapSelectorOpen){getFlashReference("bw_sst").setSelectionJs(id,"remove");
}propertySearch_suburbCarousel.reset();
propertySearch_suburbCarousel.lock();
for(var elId in propertySearch_suburbsSelected){elAddTo++;
el=propertySearch_suburbsSelected[elId];
propertySearch_addItem(el,elAddTo,1);
}propertySearch_suburbCarousel.unlock();
propertySearch_suburbCarousel.scroll(jQuery.jcarousel.intval(elMoveTo));
return false;}function propertySearch_removeAllItems(){propertySearch_suburbsSelected=new Object();
propertySearch_suburbCarousel.reset();
}function propertySearch_formatItem(row,position,items,term){return row[0]+" <span>"+row[1]+'</span><span class="postcode">'+row[2]+"</span>";
}function loadSuburbPanel(){$("#SST_SuburbPanelWrapper").css("display","block");
$("#SST_SuburbPanel").jcarousel({initCallback:propertySearch_initSuburbCarousel,vertical:true,start:1,wrap:false,buttonNextCallback:propertySearch_nextButtonStateHandler,buttonPrevCallback:propertySearch_prevButtonStateHandler,scroll:4});
}function propertySearch_saveSearch(pagePath){var options={dataType:"json",url:"/site/master.cfm?fuseaction=site-ajax.validateAuth",type:"GET",async:false,cache:false,timeout:30,success:function(response){if(response.retcode=="OK"){subnav_show("site-ajax.displayPopupSaveSearch",0);
}else{subnav_show("site-ajax.displayLogin",1,"component","site-ajax.displayPopupSaveSearch%26thisPagePath="+pagePath);
}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("An error occured, please try again\n"+textStatus+" "+errorThrown);
}};$.ajax(options);return false;
}function propertySearch_sendMMS(pagePath,searchType,propertyArray,nType,ntoKey,nfromKey,nReferer){var propertyIdList=propertyArray.toString();
var options={dataType:"json",url:"/site/master.cfm?fuseaction=site-ajax.validateAuth",type:"GET",async:false,cache:false,timeout:30,success:function(response){if(response.retcode=="OK"){subnav_show("site-ajax.displayPopupMMS&searchType="+searchType+"&openType=&propertyListing="+propertyIdList,0);
trackme(nType,ntoKey,nfromKey,nReferer);
}else{subnav_show("site-ajax.displayLogin",1,"component","site-ajax.displayPopupMMS%26thisPagePath="+pagePath+"%26searchType="+searchType+"%26openType=%26propertyListing="+propertyIdList);
}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("An error occured, please try again\n"+textStatus+" "+errorThrown);
}};alert("TODO this needs to be done....");
$.ajax(options);return false;
}function propertySearch_toggleAdvancedForm(){if(propertySearch_advancedSearchOpen==true){propertySearch_hideAdvancedForm();
}else{propertySearch_showAdvancedForm();
}}function checkSearchPanels(){if(propertySearch_advancedSearchOpen==true){propertySearch_hideAdvancedForm();
}if(propertySearch_suburbMapSelectorOpen==true){propertySearch_hideMapForm();
}}function propertySearch_showAdvancedForm(){if(propertySearch_suburbMapSelectorOpen==true){propertySearch_hideMapForm();
}$("#col1b").animate({width:"300"},200,function(){$(this).css("display","block");
});$("#srchMoreOptions").css("display","none");
$("#srchLessOptions").css("display","inline");
propertySearch_advancedSearchOpen=true;
}function propertySearch_hideAdvancedForm(){$("#col1b").animate({width:"0"},200,function(){$(this).css("display","none");
});$("#simpleSearchBtn").css("display","inline");
$("#srchMoreOptions").css("display","inline");
$("#srchLessOptions").css("display","none");
propertySearch_advancedSearchOpen=false;
}function propertySearch_toggleMapForm(){if(propertySearch_suburbMapSelectorOpen==true){propertySearch_hideMapForm();
}else{propertySearch_showMapForm();
}}function propertySearch_showMapForm(){if(propertySearch_advancedSearchOpen==true){propertySearch_hideAdvancedForm();
}$("#col1c").animate({width:"660"},400,function(){$(this).css("display","block");
});$("#srchOpenMap").css("display","none");
$("#srchCloseMap").css("display","inline");
propertySearch_suburbMapSelectorOpen=true;
}function propertySearch_hideMapForm(){$("#col1c").animate({width:"0"},400,function(){$(this).css("display","none");
});$("#simpleSearchBtn").css("display","inline");
$("#srchOpenMap").css("display","inline");
$("#srchCloseMap").css("display","none");
propertySearch_suburbMapSelectorOpen=false;
}function propertySearch_applySuburbsSelection(){if(propertySearch_suburbMapSelectorOpen){for(var elId in propertySearch_suburbsSelected){getFlashReference("bw_sst").setSelectionJs(propertySearch_suburbsSelected[elId].id,"add");
}getFlashReference("bw_sst").loadComplete(propertySearch_searchType+"_"+currentDate);
}}function propertySearch_setAddressAutocomplete(){var options={delay:400,minChars:1,cacheLength:1,matchSubset:false,matchContains:false,mustMatch:false,formatItem:propertySearch_formatAddressItem,selectItem:propertySearch_selectAddressItem,resultsClass:"search_acResults",width:258,autoFill:false,max:20,scroll:false,scrollHeight:300,extraParams:{fuseaction:"site-ajax.autocompleteAddress",searchType:propertySearch_searchType}};
if(propertySearch_autocompleteAddressAdded==false){$("#addressAuto").autocomplete("/site/master.cfm",options);
propertySearch_autocompleteAddressAdded=true;
}else{$("#addressAuto").flushCache();
$("#addressAuto").setOptions(options);
}}function propertySearch_init(){propertySearch_unlock();
var timer1="";var timer2="";
$("#minPriceLabelText").click(function(){$("#minPriceVal").val(0);
$("#minPriceLabelText").html("Minimum price");
$("#minPriceOptions").slideToggle("normal");
});$("#maxPriceLabelText").click(function(){$("#maxPriceVal").val(999999999);
$("#maxPriceLabelText").html("Maximum price");
$("#maxPriceOptions").slideToggle("normal");
});var bedTimer="";var bathTimer="";
var parkTimer="";$("#bedsLabelText").click(function(){$("#bedsVal").val(0);
$("#bedsLabelText").html("Any");
$("#bedsOptions").slideToggle("normal");
});$("#beds ul > li").click(function(){$("#bedsVal").val($(this).attr("value"));
$("#bedsLabelText").html($(this).html());
$("#bedsOptions").fadeOut("fast");
});$("#bathsLabelText").click(function(){$("#bathsVal").val(0);
$("#bathsLabelText").html("Any");
$("#bathsOptions").slideToggle("normal");
});$("#baths ul > li").click(function(){$("#bathsVal").val($(this).attr("value"));
$("#bathsLabelText").html($(this).html());
$("#bathsOptions").fadeOut("fast");
});$("#parkingLabelText").click(function(){$("#parkingVal").val(0);
$("#parkingLabelText").html("Any");
$("#parkingOptions").slideToggle("normal");
});$("#parking ul > li").click(function(){$("#parkingVal").val($(this).attr("value"));
$("#parkingLabelText").html($(this).html());
$("#parkingOptions").fadeOut("fast");
});$("#SST_SuburbPanelWrapper").css("display","none");
$("#suburbAuto").autocomplete("/site/master.cfm",{delay:400,minChars:1,cacheLength:1,matchSubset:false,matchContains:false,mustMatch:false,formatItem:propertySearch_formatItem,selectItem:propertySearch_selectItem,resultsClass:"search_acResults",width:258,autoFill:false,max:15,scroll:false,scrollHeight:300,extraParams:{fuseaction:"site-ajax.autocompleteSuburb"}});
}function propertySearch_formatAddressItem(row,position,items,term){return row[0]+' <span class="postcode">'+row[1]+"</span>";
}function propertySearch_selectAddressItem(data){var elId=0;
elId=data[1];elURL=data[2];
if(data[1]!=propertySearch_nullValue){propertySearch_lock();
document.location.href=elURL+"?searchsubtype=address&searchType="+propertySearch_searchType;
}return true;}function toggleSearchSubType(theSubType){if(theSubType=="suburb"){$("#addressSearch").hide();
$("#suburbSearch").show();
$("#searchSelTypeAddress").removeClass("active");
$("#searchSelTypeSuburb").addClass("active");
$("#searchSubType").val("suburb");
propertySearch_searchSubType="suburb";
}else{$("#suburbSearch").hide();
$("#addressSearch").show();
$("#searchSelTypeSuburb").removeClass("active");
$("#searchSelTypeAddress").addClass("active");
$("#searchSubType").val("address");
propertySearch_searchSubType="address";
}}