
function saveThisListing(mls_id,mls_no){if($("BtnSaveListing")){$("BtnSaveListing").update('Saving&hellip;');}else{$("btn_save_"+mls_id+"_"+mls_no).update('Saving&hellip;');}
var ajax_url="?";new Ajax.Request(ajax_url,{method:'get',parameters:{product:'Web',controller:'ListingSearch',action:'save_this_listing',acnt:ACNT,mls_id:mls_id,mls_no:mls_no,IDXSESS:$F("CURSID")},onSuccess:function(transport){var description=transport.responseJSON;if(description!='error'){if($("BtnSaveListing")){$("BtnSaveListing").replace('<span id="BtnListingSaved">Listing Saved</span>');}else{$("btn_save_"+mls_id+"_"+mls_no).replace('<span class="btn_saved">Saved</span>');}}else{alert("You need to login/register before you can save a listing");}},onFailure:function(){if($("BtnSaveListing")){$("BtnSaveListing").update('Save');}else{$("btn_save_"+mls_id+"_"+mls_no).update('Save');}
alert('The ajax request failed - was trying to save a listing.');}});}
function attachSaveListingEvents(){if($F('AUTHENTICATED')!=""){$$('.btn_save_listing').each(function(s){$(s).observe('click',function(event){Event.stop(event);var mlsparts=s.id.split("_",4);var mls_id=mlsparts[2];var mls_no=mlsparts[3];saveThisListing(mls_id,mls_no);});});if($("BtnSaveListing")){$("BtnSaveListing").observe('click',function(event){Event.stop(event);var mlsparts=$("BtnSaveListing").rel.split("_",2);var mls_id=mlsparts[0];var mls_no=mlsparts[1];saveThisListing(mls_id,mls_no);});}}}
Event.observe(window,'load',function(){attachSaveListingEvents();});