var xmlhttp;
var wasOff = false;

function loadXMLDoc(url){

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=state_Change
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {
  //window.status = "Vote recorded"
  }
  else
  {
  //window.status = "Problem retrieving XML data:" + xmlhttp.statusText;
  }
  }
}
function messageVote(messageId, value){
	loadXMLDoc("/forum/messagevote?messageId=" + messageId + "&value=" + value);
	displayVote(messageId, value);
}

function displayVote(messageId, value){
	if (value == -1){
		document.getElementById(messageId + "vote-1").src="/images/icons/bad.gif";
		document.getElementById(messageId + "vote0").src="/images/icons/ok_grey.gif";
		document.getElementById(messageId + "vote1").src="/images/icons/good_grey.gif";
	}
	if (value == 0){
		document.getElementById(messageId + "vote-1").src="/images/icons/bad_grey.gif";
		document.getElementById(messageId + "vote0").src="/images/icons/ok.gif";
		document.getElementById(messageId + "vote1").src="/images/icons/good_grey.gif";
	}
	if (value == 1){
		document.getElementById(messageId + "vote-1").src="/images/icons/bad_grey.gif";
		document.getElementById(messageId + "vote0").src="/images/icons/ok_grey.gif";
		document.getElementById(messageId + "vote1").src="/images/icons/good.gif";
	}
	window.status = "You voted: " + value;
	wasOff = false;
}


function rollOver(image, name){
	if (image.src.indexOf(name + "_grey.gif")!=-1){
		image.src="/images/icons/" + name + ".gif";
		wasOff = true;
	}
}

function rollOff(image, name){
	if ((image.src.indexOf(name + ".gif")!=-1)&&(wasOff==true)){
		image.src="/images/icons/" + name + "_grey.gif";
		wasOff = false;
	}
	
}