// AJAX stuffs kthxbai

function voteScript(id, vote)
	{
		var xmlHttp;
		// Determine browser
		try
			{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
			}
		catch (e)
			{
				// Internet Explorer
				try
					{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
				catch (e)
					{
						try
							{
								xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
							}
						catch (e)
							{
								alert("Your browser does not support AJAX!");
								return false;
							}
					}
			}
		xmlHttp.onreadystatechange=function()
			{
				if(xmlHttp.readyState==4)
					{
						return_value=xmlHttp.responseText;
						
						if(return_value == "true")
							{
								alert("Vote counted successfully!");
								window.location = window.location;
							}
						if(return_value == "false")
							{
								alert("There was an error with registering your vote, please try again later.");
							}
						if(return_value == "voted already")
							{
								alert("It seems that you have already voted for this script!");
							}
						if(return_value == "too high")
							{
								alert("Nice try, but you can't vote over 5");
							}
					}
			}
			
		if(vote > 5)
			{
				alert("Nice try, but you can't vote over 5");
			}
		else
			{
				xmlopen = xmlHttp.open("GET","includes/scripts/vote.php?id=" + id + "&amp;vote=" + vote,true);
				xmlHttp.send(null);
			}
	}
	
function voteTut(id, vote)
	{
		var xmlHttp;
		// Determine browser
		try
			{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
			}
		catch (e)
			{
				// Internet Explorer
				try
					{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
				catch (e)
					{
						try
							{
								xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
							}
						catch (e)
							{
								alert("Your browser does not support AJAX!");
								return false;
							}
					}
			}
		xmlHttp.onreadystatechange=function()
			{
				if(xmlHttp.readyState==4)
					{
						return_value=xmlHttp.responseText;
						
						if(return_value == "true")
							{
								alert("Vote counted successfully!");
								window.location = window.location;
							}
						if(return_value == "false")
							{
								alert("There was an error with registering your vote, please try again later.");
							}
						if(return_value == "voted already")
							{
								alert("It seems that you have already voted for this tutorial!");
							}
						if(return_value == "too high")
							{
								alert("Nice try, but you can't vote over 5");
							}
					}
			}
			
		if(vote > 5)
			{
				alert("Nice try, but you can't vote over 5");
			}
		else
			{
				xmlHttp.open("GET","includes/tutorials/vote.php?id=" + id + "&amp;vote=" + vote,true);
				xmlHttp.send(null);
			}
	}