function getHTTPObject()
{var xmlhttp;if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();}
else if(window.ActiveXObject)
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");if(!xmlhttp)
{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}}
return xmlhttp;}
var http=getHTTPObject();
function thoughtcount(sitepath,count,id,type)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=thoughtcount";
	url=url+'&count='+count+'&id='+id+'&type='+type;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('thoughtscounts1').innerHTML = results;
			}
		}
	}
	http.send(null);
}
function popularcount(sitepath,count,id,type)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=popularcount";
	url=url+'&count='+count+'&id='+id+'&type='+type;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('thoughtscounts2').innerHTML = results;
			}
		}
	}
	http.send(null);
}
function deletecomments(sitepath,id)
{
	if (confirm("Are you sure you want to Delete this comment?")) 
	{		
		var url=sitepath+"model/ajaxhandler.class.php?action=deletecomment&id="+id;
		newURL = window.location.protocol + "//" + window.location.host + "" + window.location.pathname;
		http.open("GET", url, true);
		http.onreadystatechange = function()
		{
			if (http.readyState == 4)
			{
				if(http.status==200)
				{
					var results=http.responseText;
					window.location=newURL+"/success";
				}
			}
		}
		http.send(null);
	}
	else
	{
		return false;
	}
}
function ChangeThoughts(sitepath,id,type,types)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=getthoughtsforweek";
	url=url+'&id='+id+'&type='+type+'&types='+types;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('thought').style.display = 'none';
				document.getElementById('newthoughts').innerHTML = results;
			}
		}
	}
	http.send(null);
}
function ChangePopular(sitepath,id,type,types)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=getpopularforweek";
	url=url+'&id='+id+'&type='+type+'&types='+types;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('popular_thought').style.display = 'none';
				document.getElementById('newpopular').innerHTML = results;
			}
		}
	}
	http.send(null);
}
function thoughtcountnew(sitepath,count,id,type,action,date)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=getthoughtsforweeknew";
	url=url+'&date='+date+'&id='+id+'&type='+type;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('thought').style.display = 'none';
				document.getElementById('newthoughts').innerHTML = results;
			}
		}
	}
	http.send(null);
}
function popularcountnew(sitepath,count,id,type,action,date)
{
	var url=sitepath+"model/ajaxhandler.class.php?action=getpopularforweeknew";
	url=url+'&date='+date+'&id='+id+'&type='+type;
	http.open("GET", url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4)
		{
			if(http.status==200)
			{
				var results=http.responseText;
				document.getElementById('popular_thought').style.display = 'none';
				document.getElementById('newpopular').innerHTML = results;
			}
		}
	}
	http.send(null);
}

