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