// Invoke add to favorites
function invokeAddToFavorites( objectId )
	{
	/* Create URL for ajax query */
	url = "http://www.ledigalokaler.com/main_lediga.php?cmd=favorites_add&id=" + objectId;

	/* Make ajax query AND redirect response to apropriate function */
	sendAjaxQuery(url, defaultResponseHandler, 'favorites_add');
	}

// Invoke remove/clear favorites
function invokeRemoveFavorite( objectId )
	{
	/* Create URL for ajax query */
	url = "http://www.ledigalokaler.com/main_lediga.php?cmd=favorites_remove&id=" + objectId;

	/* Make ajax query AND redirect response to apropriate function */
	sendAjaxQuery(url, defaultResponseHandler, 'favorites_remove');
	}

// Invoke listing of favorites	
function invokeListFavorites()
	{
	/* Create URL for ajax query */
	url = "http://www.ledigalokaler.com/main_lediga.php?cmd=favorites_list";

	/* Make ajax query AND redirect response to apropriate function */
	sendAjaxQuery(url, updateFavoriteList, 'favorites_list');
	}

// Update list of favorites
function updateFavoriteList( xmlDoc, tag )
	{
	if( xmlDoc.readyState == 4 && xmlDoc.status == 200 )
		{
		/* Get response as text */
		var favoriteCount = xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteCount").text ? xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteCount").text : xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteCount").textContent;
		var favoriteList = xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteList").text ? xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteList").text : xmlDoc.responseXML.selectSingleNode("/xmlRoot/favoriteList").textContent;

		/* Divs */
		var divFavoriteCount = document.getElementById('favoriteCount');
		var divFavoriteList = document.getElementById('favoriteList');

		if( divFavoriteList && divFavoriteCount && favoriteCount )
			{
			divFavoriteList.innerHTML = unescape(favoriteList);
			divFavoriteCount.innerHTML = unescape(favoriteCount);
			}

		xmlDoc = null;
		}
	}

