function addToFavorites(mls_num, is_session) {
	if(is_session == 1) {
		var url = "addsessionfavorites.php?mls_num=" + mls_num;
	} else {
		var url = "addfavorites.php?mls_num=" + mls_num;
	}
	var div = document.getElementById('fav_reply');
	if(div == null) {
		div = document.getElementById("fav_reply_" + mls_num);
	}
	var handleSuccess = function(){
			div.innerHTML = '<span class="errormessage">Added to <a href="favorites.php">favorites</a>!</span>';
	}
	var handleFailure = function(){
		div.innerHTML = '<span class="errormessage">Error with favorites. Please try again.</span>';
	}
	var callback =
	{
	  success:handleSuccess,
	  failure: handleFailure
	};
	var request = YAHOO.util.Connect.asyncRequest('GET', url, callback);
	
	return false;	
}

function removeFromFavorites(mls_num) {
	var url = "removefavorites.php?mls_num=" + mls_num;
	var favorites_div = document.getElementById("tr_mlsnum_" + mls_num);
	var div = document.getElementById('fav_reply');
	if(div == null) {
		div = document.getElementById("fav_reply_" + mls_num);
	}

	var handleSuccess = function(){
		div.innerHTML = '<span class="errormessage">Removed from Favorites. <a href="favorites.php">Reload this page</a> to update the map and results.</span>';
		if(favorites_div != null) {
			//This works in Firefox but not IT
			favorites_div.innerHTML = '<td colspan="3" class="errormessage">This home removed from favorites. <a href="favorites.php">Reload this page</a> to update the map and results.</td>';
		} 
	}
	var handleFailure = function(){
			favorites_div.innerHTML = '<td colspan="3" class="errormessage">Error connecting to server. Please reload this page.</td>';
	}
	var callback =
	{
	  success:handleSuccess,
	  failure: handleFailure
	};
	var request = YAHOO.util.Connect.asyncRequest('GET', url, callback);
	
	return false;	
}

