function rankmouseout(currentrank) {
	document.getElementById("ranking").style.backgroundPosition = currentrank + "px 0px";
}
function rankmouseover(starnumber, currentrank, userid) {
	
	ranking = document.getElementById("ranking");
	rankingtext = document.getElementById("rankingtext");
	
	
	switch (starnumber) {
		case 1:
			ranking.style.backgroundPosition = "-71px 0px";
		break;
		
		case 2: 
			ranking.style.backgroundPosition = "-54px 0px";
		break;
		
		case 3:
			ranking.style.backgroundPosition = "-37px 0px";
		break;
		
		case 4:
			ranking.style.backgroundPosition = "-20px 0px";
		break;
		
		case 5:
			ranking.style.backgroundPosition = "0px 0px";
		break;
		
		default:
			ranking.style.backgroundPosition = currentrank + "px 0px";
		break;
		
	}
	if (userid == "") {
		rankingtext.innerHTML = 'Please <a href="/login.php">log in</a> to rank this item';	
	}
}


var xmlhttp;

function vote(type, item_id, ranking, sess) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="/rank.php";
	url=url+"?type="+type;
	url=url+"&item="+item_id;
	url=url+"&ranking="+ranking;
	url=url+"&sess="+sess;
	xmlhttp.onreadystatechange=rankingChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function rankingChanged() {
	if (xmlhttp.readyState==4) {
		document.getElementById("rankingtext").innerHTML=xmlhttp.responseText;
	}
}


function deletecomment(commentid) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="/comment.php";
	url=url+"?mode=delete";
	url=url+"&commentid="+commentid;
	
	xmlhttp.onreadystatechange; //=commentDeleted();
	if (xmlhttp.readyState==4) {
		document.getElementById("comment_box_" + commentid).innerHTML=xmlhttp.responseText;
		window.alert(commentid);
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function commentDeleted() {
	if (xmlhttp.readyState==4) {
		document.getElementById("comment_box_" + commentid).innerHTML=xmlhttp.responseText;
		
		//document.getElementById("comment_response").innerHTML=xmlhttp.responseText;
		//document.getElementById("comment_box_" + commentid).style.display = "none";
	}
}


function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
  	}
	if (window.ActiveXObject) {
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return null;
}