function vote(count,id){
	// GET CORRECT XMLhttp REQUEST
	var http = GetXmlHttpObject();
	if (http == null){
		alert ("Browser does not support HTTP Request");
		return;
	} 
	// SET UP OUR VARS
	var url = window.location.protocol+"//"+window.location.host+"/vote.php";
	var params = "count="+count+"&id="+id;
	// OPEN THE CONNECTION
	http.open("POST", url, true);
	// SEND THE PROPER HEADER INFO ALONG WITH THE REQUEST
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	// WHEN READY UPDATE THE PAGE WITH NEW INFO
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) {
			//alert(http.responseText);
			if(http.responseText == 'not votable') {
				document.getElementById("vote_"+count).innerHTML="<span>voted</span>";
			}else{
				document.getElementById("votes_"+count).innerHTML=http.responseText+"<span>Votes</span>";
				document.getElementById("vote_"+count).innerHTML="<span>voted</span>";
			}			
		}
	}
	// SEND PARAMS VIA POST
	http.send(params);
}

function comment(id){	
	// GET CORRECT XMLhttp REQUEST
	var http = GetXmlHttpObject();
	if (http == null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	// SNAG THE COMMENT THE USER WISHES TO SUBMIT
	var comment = document.getElementById('comment').value;
	// SET UP OUR VARS
	var url = window.location.protocol+"//"+window.location.host+"/comment.php";
	var params = "comment="+comment+"&id="+id;
	// OPEN THE CONNECTION
	http.open("POST", url, true);
	// SEND THE PROPER HEADER INFO ALONG WITH THE REQUEST
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	// WHEN READY UPDATE THE PAGE WITH NEW INFO
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) {
			//alert(http.responseText);
			if(document.getElementById("comment_last")){
				document.getElementById("comment_last").className = 'comment';
				document.getElementById("comments_wrapper").innerHTML+=http.responseText;
				document.getElementById("comment").value='';
			}else{
				document.getElementById("comments_wrapper").innerHTML+=http.responseText+'<div id="tut_footer"></div>';
				document.getElementById("comment").value='';
			}
		}
	}
	// SEND PARAMS VIA POST
	http.send(params);	
}

function GetXmlHttpObject() { 
	// CREATE NEW VAR
	var objXMLHttp=null;
	// IF U HAVE A DOPE BROWSER THIS WILL WORK
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest();
	}
	// IF YOUR ON THE SHITTIEST BROWSER ON EARTH YOU WILL NEED THIS
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	// SEND CORRECT REQUEST BACK
	return objXMLHttp;
}