function getXMLHttp()
{
  var xmlHttp

  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;
      }
    }
  }
  return xmlHttp;
}

function voteLOL(type, postid)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText, type, postid);
    }
  }

  xmlHttp.open("GET", "/views/default/magic.php?type=" + type + "&postid=" + postid, true); 
  xmlHttp.send(null);
}

function HandleResponse(response, type, postid)
{
  document.getElementById(type+'rate'+postid).innerHTML = response;
}

function countChars(field, count, max) {
	if (field.value.length > max)
		field.value = field.value.substring(0, max);
	else
		count.value = max - field.value.length;
}