function changeFav(id)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			reloadFavs();
			if(xmlhttp.responseText == 'remove')
			{
				document.getElementById("favbutton-" + id).src = 'template/images/fav_save.png';
				document.getElementById("headline-content").innerHTML = 'You have successfully removed this topic from your favorites.';
			}
			else
			{
				document.getElementById("headline-content").innerHTML = 'You have successfully added this topic to your favorites.';
				document.getElementById("favbutton-" + id).src = 'template/images/fav_check.png';
			}
		}
	}
	xmlhttp.open("GET", "getfavs.php?id=" + id + "&mode=change", true);
	xmlhttp.send(null);
}

function reloadFavs()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById("m1").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET", "getfavs.php", true);
	xmlhttp.send(null);
}