var hostname=top.location.hostname;var root="/";if(hostname=="localhost"){root="/cafe.rc.propertysitecontent/"}var favorites;$(document).ready(function(){initFavorites();$(".removeFavorite").live("click",function(b){b.preventDefault();var a=$(this).attr("href").replace("#","");toggleFavorite(a)})});function initFavorites(){var a=GetCookie("Favorites");if(!a){favorites=[]}else{favorites=a.split(",");$("#myFavoritesList .body .compareBtn").show()}$("#myFavoritesList .body").droppable({drop:function(b,c){toggleFavorite(c.draggable.attr("alt"));c.draggable.draggable("disable")},activate:function(b,c){$(this).addClass("active")},deactivate:function(b,c){$(this).removeClass("active")},hoverClass:"over"});$(".favoriteCheck").click(function(){var c=$(this).attr("id").replace("favoriteCheckBox","");var d=$(".property"+c).find(".parameters .propertyLat").html();var b=$(".property"+c).find(".parameters .propertyLng").html();toggleFavorite(c,d,b);if($(this).is(":checked")){if(top.location.href.indexOf("rentcafe")!=-1){if($(this).hasClass(".forrent")){_gaq.push(["_trackEvent","AddToFavorites_ForRent","Click",$(this).attr("id").replace("favoriteCheckBox","")])}else{_gaq.push(["_trackEvent","AddToFavorites","Click",$(this).attr("id").replace("favoriteCheckBox","")])}}}});updateFavorites()}function showFavorites(){if(favorites.length==0){$("#favoritesContainer").dialog("close");alert("You must have at least one favorite.  To add a favorite click the checkbox on the result.");return}showDialog("Favorites","rcfavorites","favorites="+favorites.toString())}function updateFavorites(){var a="";$("input.favoriteCheck").attr("checked",false);if(typeof(favorites)=="undefined"||favorites.toString()=="undefined"){favorites=[]}$(".favoriteCount").html(favorites.length);SetCookie("Favorites",favorites.toString());if(favorites.length>0){a=favorites.toString();$("#myFavoritesList .body .compareBtn").show();$("#searchResultFavoritesListWrap .body .compareBtn").show();$("#myFavoritesList .body .favoritesListContainer").slideUp(200,function(){$("#myFavoritesList .body .favoritesListContainer").html("Loading...");$("#myFavoritesList .body .favoritesListContainer").load(root+"rcLoadContent.ashx?contentclass=MyFavoritesUL&favorites="+a,function(){$("#myFavoritesList .body .favoritesListContainer").slideDown(200);$("#myFavoritesList .favoriteCount").html(favorites.length)})});if($("#SearchResultFavoritesList").length>0){$("#SearchResultFavoritesList .body").show();$("#SearchResultFavoritesList .body .favoritesListContainer").load(root+"rcLoadContent.ashx?contentclass=searchResultFavoritesUL&favorites="+a,function(){$("#SearchResultFavoritesList .body .favoritesListContainer").slideDown(200);$("#SearchResultFavoritesList .favoriteCount").html(favorites.length)})}}else{$("#myFavoritesList .body").slideUp(200,function(){$("#myFavoritesList .body .favoritesListContainer").html("You have not added any favorites yet.");$("#myFavoritesList .body .compareBtn").hide();$("#myFavoritesList .body").slideDown()});$("#SearchResultFavoritesList .body").slideUp(200,function(){$("#SearchResultFavoritesList .body .favoritesListContainer").html("You have not added any favorites yet.")});$("#searchResultFavoritesListWrap .header a.arrow").removeClass("open")}updateFavoritesControls()}function toggleFavorite(b,d,a){for(var c=0;c<favorites.length;c++){var e=favorites[c].split("(")[0];if(e==b){favorites.splice(c,1);$(".property"+b).show();$(".property"+b+" .draggable").draggable("enable");$(".favbutton"+b).removeClass("onList");$(".favbutton"+b).val("Add To Favorites");$("#favoriteCheckBox"+b).siblings("label").html("Add To Favorites").removeClass("onList");updateFavorites();if($("#refineSearchWrap").length>0){$("#mapContainer").ResultsMap("refreshMap",{lat:d,lng:a,resetCenter:true,pagination:true,showBalloons:true,showBoxSearch:true})}else{$("#mapContainer").ResultsMap("refreshMap",{showRadius:false,lat:d,lng:a,resetCenter:true,pagination:false,showBalloons:true,showBoxSearch:false})}return}}favorites[favorites.length]=b+"("+d+"^"+a+")";updateFavorites();if($("#refineSearchWrap").length>0){$("#mapContainer").ResultsMap("refreshMap",{lat:d,lng:a,resetCenter:true,pagination:true,showBalloons:true,showBoxSearch:true})}else{$("#mapContainer").ResultsMap("refreshMap",{showRadius:false,lat:d,lng:a,resetCenter:true,pagination:false,showBalloons:true,showBoxSearch:false})}return}function updateFavoritesControls(){for(var a=0;a<favorites.length;a++){var b=favorites[a].split("(")[0];$(".property"+b).fadeOut();$("#favoriteCheckBox"+b).attr("checked",true);$("#favoriteCheckBox"+b).siblings("label").html("Added To Favorites").addClass("onList");$(".favbutton"+b).addClass("onList");$(".favbutton"+b).val("Remove Favorite");$(".property"+b+" .draggable").draggable("disable")}}function sendToCompare(a){if(favorites.length<1){alert("You haven't selected any properties to compare, review and apply.  Please select at least 1 property to your favorites.");return false}SetCookie("Compare","Y");window.location.href=a};
