rwOProperty=function(){};rwOProperty.config={paginationDiv:"#pagination_properties_ajax",paginationDivChild:"#pagination_properties_ajax_child",pagination:{baseUrl:"",typeCode:"",pages:0,totalListings:0,resultsPerPage:0,currentPage:0,start:0,end:0}};jQuery.extend(rwOProperty.prototype,{init:function(){this.monitorHashChange();this.setPaginationValues();this.displayPagination();this.checkCurrentHash();this.setFilterFunctionality()}});jQuery.extend(rwOProperty.prototype,{setFilterFunctionality:function(){this.setFilterHoverCursor();this.setFilterSlider();this.setFilterMultiSelect();this.setSubmitFunctionality()},setFilterHoverCursor:function(){jQuery("#filterHeader").hover(function(){jQuery(this).css({cursor:"pointer"})},function(){jQuery(this).css({cursor:"default"})})},setFilterSlider:function(){jQuery("#filterHeader").toggle(function(){jQuery("#filterFormDisplay").slideDown(400,function(){jQuery("#filterToggleText").html("Hide All");jQuery("#filterHeader").attr("class","close")})},function(){jQuery("#filterFormDisplay").slideUp(400,function(){jQuery("#filterToggleText").html("Show All");jQuery("#filterHeader").attr("class","open")})})},setFilterMultiSelect:function(){var a={multiple:false,header:false,selectedList:1,minWidth:100};jQuery("#bed").multiselect(a);jQuery("#bath").multiselect(a);jQuery("#car").multiselect(a);jQuery("#minprice").multiselect(a);jQuery("#maxprice").multiselect(a);jQuery("#results").multiselect({multiple:false,header:false,selectedList:1,minWidth:60});jQuery("#multiplesuburbs").multiselect({noneSelectedText:"ANY",selectedText:function(c,d,b){return(c>1)?c+" Suburbs Selected":c+" Suburb Selected"},minWidth:210,header:false});jQuery("#sort").multiselect({multiple:false,header:false,selectedList:1,minWidth:80});jQuery("#propertytype").multiselect({multiple:false,header:false,selectedList:1,minWidth:210});jQuery("#holidaycategorytype").multiselect({multiple:false,header:false,selectedList:1,minWidth:210});jQuery("#ruralcategorytype").multiselect({multiple:false,header:false,selectedList:1,minWidth:210});jQuery("#commercialcategorytype").multiselect({multiple:false,header:false,selectedList:1,minWidth:210});jQuery("#businesscategorytype").multiselect({multiple:false,header:false,selectedList:1,minWidth:210});jQuery("#sort").bind("multiselectclose",function(b,c){jQuery("#filterSubmit").click()});jQuery("#results").bind("multiselectclose",function(b,c){jQuery("#filterSubmit").trigger("click")})},setSubmitFunctionality:function(){jQuery("#filterSubmit").click(function(){try{filterForm=jQuery("#filterForm");filterForm.find(':input[value=""]').attr("disabled",true);jQuery(".results").find(':input[value=""]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_bed"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_bath"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_car"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_minprice"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_maxprice"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_multiplesuburbs"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_sort"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_propertytype"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_holidaycategorytype"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_ruralcategorytype"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_commercialcategorytype"]').attr("disabled",true);jQuery("#filterForm").find(':input[name="multiselect_businesscategorytype"]').attr("disabled",true)}catch(a){}filterForm.submit()})}});jQuery.extend(rwOProperty.prototype,{setPaginationValues:function(){rwOProperty.config.pagination.baseUrl=jQuery("#paginationBaseUrl").val();rwOProperty.config.pagination.typeCode=(jQuery("#paginationTypeCode").val())?jQuery("#paginationTypeCode").val():"ALL";rwOProperty.config.pagination.pages=(parseInt(jQuery("#paginationPages").val())>1)?parseInt(jQuery("#paginationPages").val()):1;rwOProperty.config.pagination.totalListings=parseInt(jQuery("#paginationTotalListings").val());rwOProperty.config.pagination.resultsPerPage=parseInt(jQuery("#paginationResultsPerPage").val());rwOProperty.config.pagination.currentPage=(parseInt(jQuery("#paginationCurrentPage").val())>1)?parseInt(jQuery("#paginationCurrentPage").val()):1;rwOProperty.config.pagination.paginationVars=jQuery("#paginationVars").val();rwOProperty.config.pagination.paginationAgentOfficeSAM=jQuery("#paginationAgentOfficeSAM").val();rwOProperty.config.pagination.Type=jQuery("#paginationType").val();rwOProperty.config.pagination.ActionType=jQuery("#paginationActionType").val()},setPaginationStart:function(){if(rwOProperty.config.pagination.currentPage<=1){rwOProperty.config.pagination.start=1}else{rwOProperty.config.pagination.start=(parseInt(rwOProperty.config.pagination.currentPage)-1)*parseInt(rwOProperty.config.pagination.resultsPerPage)+1}},setPaginationEnd:function(){if(rwOProperty.config.pagination.start==1){rwOProperty.config.pagination.end=(parseInt(rwOProperty.config.pagination.currentPage)*parseInt(rwOProperty.config.pagination.resultsPerPage))}else{rwOProperty.config.pagination.end=((parseInt(rwOProperty.config.pagination.currentPage)-1)*parseInt(rwOProperty.config.pagination.resultsPerPage))+parseInt(rwOProperty.config.pagination.resultsPerPage)}rwOProperty.config.pagination.end=(parseInt(rwOProperty.config.pagination.end)>parseInt(rwOProperty.config.pagination.totalListings))?rwOProperty.config.pagination.totalListings:rwOProperty.config.pagination.end},displayPagination:function(){jQuery(rwOProperty.config.paginationDiv).html("");this.setPaginationStart();this.setPaginationEnd();jQuery(rwOProperty.config.paginationDiv).append('<ul class="pageresults"></ul>');this.displayPaginationTotal();this.displayPaginationPrevious();this.displayPaginationLinks();this.displayPaginationNext();this.shortenPaginationLinks();if(jQuery(rwOProperty.config.paginationDivChild).length){jQuery(rwOProperty.config.paginationDivChild).html(jQuery(rwOProperty.config.paginationDiv).html())}},displayPaginationTotal:function(){var a="";a+='<li class="count">(<strong>'+rwOProperty.config.pagination.start+"-"+rwOProperty.config.pagination.end+"</strong>";a+=" of ";a+="<strong>"+rwOProperty.config.pagination.totalListings+"</strong> results)</li>";jQuery(rwOProperty.config.paginationDiv+" ul").append(a)},displayPaginationLinks:function(){for(i=1;i<=rwOProperty.config.pagination.pages;i++){this.createHashLink(i)}},displayPaginationNext:function(){if(parseInt(rwOProperty.config.pagination.currentPage)+1<=rwOProperty.config.pagination.pages){var b=window.location.href.split("#");var c=b[0]+"#page="+(parseInt(rwOProperty.config.pagination.currentPage)+1);var d=document.createElement("a");d.setAttribute("class","paginationAJAX");d.setAttribute("href",c);jQuery(d).html("&rsaquo;");var a=document.createElement("li");a.setAttribute("class","next arrow");jQuery(a).append(d);jQuery(rwOProperty.config.paginationDiv+" ul").append(a)}},displayPaginationPrevious:function(){if(parseInt(rwOProperty.config.pagination.currentPage)-1>0){var b=window.location.href.split("#");var c=b[0]+"#page="+(parseInt(rwOProperty.config.pagination.currentPage)-1);var d=document.createElement("a");d.setAttribute("class","paginationAJAX");d.setAttribute("href",c);jQuery(d).html("&lsaquo;");var a=document.createElement("li");a.setAttribute("class","prev arrow");jQuery(a).append(d);jQuery(rwOProperty.config.paginationDiv+" ul").append(a)}},shortenPaginationLinks:function(){var a="#pagination_properties_ajax li.paginationLinks";var b=jQuery(a).length;var d=parseInt(rwOProperty.config.pagination.currentPage-1);jQuery(a).hide();try{jQuery(jQuery(a)[0]).show()}catch(c){}try{jQuery(jQuery(a)[1]).show()}catch(c){}try{jQuery(jQuery(a)[b-1]).show()}catch(c){}try{jQuery(jQuery(a)[b-2]).show()}catch(c){}try{jQuery(jQuery(a)[d]).show()}catch(c){}try{jQuery(jQuery(a)[d+1]).show()}catch(c){}try{jQuery(jQuery(a)[d+2]).show()}catch(c){}try{jQuery(jQuery(a)[d-1]).show()}catch(c){}try{jQuery(jQuery(a)[d-2]).show()}catch(c){}try{if(d<6){for(i=0;i<8;i++){jQuery(jQuery(a)[i]).show()}}}catch(c){}try{if(d>b-6){for(i=0;i<7;i++){jQuery(jQuery(a)[b-i]).show()}}}catch(c){}try{if(d+3<b-2){if(!jQuery(jQuery(a)[d+3]).is(":visible")){jQuery(jQuery(a)[d+3]).show();jQuery(jQuery(a)[d+3]).children().html("..")}}if(d-3>1){if(!jQuery(jQuery(a)[d-3]).is(":visible")){jQuery(jQuery(a)[d-3]).show();jQuery(jQuery(a)[d-3]).children().html("..")}}if(d<7&&d+7<b){if(!jQuery(jQuery(a)[8]).is(":visible")){jQuery(jQuery(a)[8]).show();jQuery(jQuery(a)[8]).children().html("..")}}if(d>b-6){if(!jQuery(jQuery(a)[b-7]).is(":visible")){jQuery(jQuery(a)[b-7]).show();jQuery(jQuery(a)[b-7]).children().html("..")}}}catch(c){}}});jQuery.extend(rwOProperty.prototype,{monitorHashChange:function(){jQuery(window).hashchange(function(){if(typeof _gaq!=="undefined"){_gaq.push(["_trackPageview",window.location.pathname+window.location.search])}this.loadAJAXProperty()}.bind(this))},checkCurrentHash:function(){var a=this.getPageHash();if(a!=""&&parseInt(a)!=parseInt(rwOProperty.config.pagination.currentPage)){this.loadAJAXProperty()}},getPageHash:function(){var b=1;var d=window.location.hash;var a=d.match(/\page=(\d+)/i);if(a){b=a[1]}else{var c=window.location.href;a=c.match(/\page=(\d+)/i);if(a){b=a[1]}}return b},hashChange:function(){console.log(window.location.hash)},createHashLink:function(d,f){var c=window.location.href.split("#");var e=c[0]+"#page="+d;var g=document.createElement("a");g.setAttribute("class","paginationAJAX");g.setAttribute("href",e);var b=document.createTextNode(d);g.appendChild(b);var a=document.createElement("li");if(d==this.getPageHash()||d==rwOProperty.config.pagination.currentPage){a.setAttribute("class","current");jQuery(a).append(g);jQuery(rwOProperty.config.paginationDiv+" ul").append(a)}else{jQuery(a).append(g);jQuery(rwOProperty.config.paginationDiv+" ul").append(a)}jQuery(a).addClass("paginationLinks")}});jQuery.extend(rwOProperty.prototype,{loadAJAXProperty:function(){var a=this.getUrl();this.getData(a)},getUrl:function(){var a=rwOProperty.config.pagination.baseUrl;a+=(rwOProperty.config.pagination.baseUrl.match(/[\?]/i))?"&":"?";a+="page="+this.getPageHash();a+="&ajax="+rwOProperty.config.pagination.typeCode;a+="&type="+rwOProperty.config.pagination.Type;a+="&actiontype="+rwOProperty.config.pagination.ActionType;if(rwOProperty.config.pagination.paginationAgentOfficeSAM!=""){a+="&agentofficesam="+rwOProperty.config.pagination.paginationAgentOfficeSAM}a+=rwOProperty.config.pagination.paginationVars;return a},getData:function(a){jQuery.ajax({url:a,dataType:"jsonp",jsonp:"callback",start:this.startDataLoad(),error:function(c,d,b){if(console){console.log(d+" "+b)}}.bind(this),success:function(c){if(c&&c.properties){jQuery("#properties").html("");var b="";var d=1;jQuery.each(c.properties,function(e,f){if(f&&f.details){b+=this.getPropertyHTML(f,d);d++}}.bind(this));jQuery("#properties").html(b);rwOProperty.config.pagination.currentPage=this.getPageHash();this.displayPagination();jQuery("#properties").fadeTo("fast",1,function(){try{this.style.removeAttribute("filter")}catch(f){}});jQuery(rwOProperty.config.paginationDivChild).show();jQuery("img[data-src]").bind("scrollin",{distance:500},function(){var e=this,f=jQuery(e);f.unbind("scrollin");e.src=f.attr("data-src")})}}.bind(this)})},startDataLoad:function(){jQuery(rwOProperty.config.paginationDivChild).hide();jQuery("#properties").fadeTo("fast",0.2);jQuery("#properties").prepend("<div id='loader'><img src='"+jQuery.rwo.settings.rwoImagePath+"loading-sm.gif' /></div>")},getPropertyHTML:function(b,c){var a="";a+='<article class="block">';if(typeof b.details.thumbnailurl!=="undefined"){a+='<a href="'+b.details.url+'" class="thumb"><img src="'+b.details.thumbnailurl+'" width="120" height="90" alt="'+b.details.address+'" /></a>'}else{a+='<a href="'+b.details.url+'" class="thumb"><img src="'+ +jQuery.rwo.settings.rwoImagePath+'no-thumb.jpg" width="120" height="90" alt="'+b.details.address+'" /></a>'}a+='   <div class="summary">';a+="   	<header>";a+='			<div class="amens">';a+=(b.details.bedrooms!="")?'<span class="bed">'+b.details.bedrooms+'<span class="hidden amenPrint">&nbsp;Bedrooms</span></span>':"";a+=(b.details.bathrooms!="")?'<span class="bath">'+b.details.bathrooms+'<span class="hidden amenPrint">&nbsp;Bathrooms</span></span>':"";a+=(b.details.carspaces!="")?'<span class="car">'+b.details.carspaces+'<span class="hidden amenPrint">&nbsp;Carspaces</span></span>':"";a+="			</div>";a+='			<h2><a href="'+b.details.url+'">'+b.details.address+"</a></h2>";if(typeof b.details.price!="undefined"){a+="			<h3>"+b.details.price+"</h3>"}a+="		</header>";a+="		<section>";a+='            <ul class="insp">';if(b.details.auctionTime!=""){a+="					 <li><strong>Auction</strong> "+b.details.auctionTime+"</li>"}if(b.details.nextInspectionStart!=""){a+="					 <li><strong>Inspection</strong><br /><br />"+b.details.ofi+"</li>"}a+="            </ul>";a+="			<h4>"+b.details.listingtitle+"</h4>";a+="			<p>";a+=b.details.listingdescription;a+="			</p>";a+='			<ul class="sub-actions">';a+='				<li class="button details"><a href="'+b.details.url+'">View details</a></li>';a+="			</ul>";a+="		</section>";a+="   </div>";a+="</article>";return a}});jQuery.extend(rwOProperty.prototype,{heroIMages:function(){this.hideAll();this.setFirstVisible();this.setLinks();this.setThumbnailLinks();this.setFloorplanLinks();this.preLoadCurrentImage(0);this.preLoadImages();this.toggleArrows()},hideAll:function(){jQuery.each(jQuery("li.gMainImg"),function(a,b){if(a>0){jQuery(b).hide()}});jQuery("li.gMainFloorplan").hide()},setFirstVisible:function(){jQuery(jQuery("li.gMainImg")[0]).show();jQuery(jQuery("li.gThumbImg")[0]).addClass("active")},nextImage:function(){var c=this.getCurrentImage();var b=c;var a=this.getNextId();rwOProperty.prototype.hideShowImages(b,a)},previousImage:function(){var c=this.getCurrentImage();var b=c;var a=this.getPreviousId();rwOProperty.prototype.hideShowImages(b,a)},getNextId:function(){var b=this.getCurrentImage();var a=(b>=(jQuery("li.gMainImg").length-1))?0:b+1;return a},getPreviousId:function(){var b=this.getCurrentImage();var a=(b==0)?jQuery("li.gMainImg").length-1:b-1;return a},hideShowImages:function(b,a){this.preLoadCurrentImage(a);jQuery(jQuery("li.gMainImg")[b]).hide();jQuery(jQuery("li.gThumbImg")[b]).removeClass("active");jQuery(jQuery("li.gMainImg")[a]).show();jQuery(jQuery("li.gThumbImg")[a]).addClass("active");this.preLoadImages()},getCurrentImage:function(){var a=0;jQuery.each(jQuery("li.gMainImg"),function(b,c){if(jQuery(jQuery("li.gMainImg")[b]).is(":visible")){a=b}});return a},setLinks:function(){jQuery(".rwOHero-next").click(function(){rwOProperty.prototype.nextImage();return false});jQuery(".rwOHero-prev").click(function(){rwOProperty.prototype.previousImage();return false})},setThumbnailLinks:function(){jQuery.each(jQuery("li.gThumbImg"),function(a,b){jQuery(b).click(function(){var e=rwOProperty.prototype.getCurrentImage();var d=e;var c=a;rwOProperty.prototype.hideShowImages(d,c)});jQuery(b).hover(function(){jQuery(this).css({cursor:"pointer"})},function(){jQuery(this).css({cursor:"default"})})})},setFloorplanLinks:function(){try{jQuery.each(jQuery("li.gThumbFloorplan"),function(b,c){jQuery("a[rel='floorplan"+b+"']").colorbox({onOpen:function(){if(rwOProperty.prototype.getCurrentImage()==0&&jQuery("li.gMainImg.video").length){jQuery("li.gMainImg.video").hide()}},onCleanup:function(){if(rwOProperty.prototype.getCurrentImage()==0&&jQuery("li.gMainImg.video").length){jQuery("li.gMainImg.video").show()}}})})}catch(a){}},preLoadCurrentImage:function(b){var a=b;try{jQuery(jQuery(".gMainImg img")[a]).attr("src",jQuery(jQuery(".gMainImg img")[a]).attr("load-src"))}catch(c){}},preLoadImages:function(){var a=this.getNextId();var b=this.getPreviousId();try{jQuery(jQuery(".gMainImg img")[a]).attr("src",jQuery(jQuery(".gMainImg img")[a]).attr("load-src"));jQuery(jQuery(".gMainImg img")[b]).attr("src",jQuery(jQuery(".gMainImg img")[b]).attr("load-src"))}catch(c){}this.toggleArrows()},toggleArrows:function(){try{if(jQuery("li.gMainImg.video").is(":visible")){jQuery(".rwOHero-prev").hide();jQuery(".rwOHero-next").hide()}else{jQuery(".rwOHero-prev").show();jQuery(".rwOHero-next").show()}}catch(a){}}});
