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("Sorry, your browser does not support this feature.  Please install Firefox or Internet Explorer to use this feature.");
        return false;
      }
    }
  }
  return xmlHttp;
}

function RateReply(rating, replyid)
{
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function()
  {
	if(xmlHttp.readyState == 1)
	{
		document.getElementById('RateReply' + replyid + 'Div').innerHTML = '<img src="/images/working.gif" />';
	}
    if(xmlHttp.readyState == 4)
    {
      document.getElementById('RateReply' + replyid + 'Div').innerHTML = xmlHttp.responseText;
    }
  }

  xmlHttp.open("GET", "ajax_scripts/ajax_ratereply.php?replyid=" + replyid + "&rating=" + rating, true); 
  xmlHttp.send(null);
}

function CheckUsernameAvail(desiredUsername)
{
	desiredUsername = desiredUsername.replace("&","%");
	desiredUsername = desiredUsername.replace(" ","%");
	//if(desiredUsername.length >= 4)
	//{
	  var xmlHttp = getXMLHttp();
	  xmlHttp.onreadystatechange = function()
	  {
		if(xmlHttp.readyState == 4)
		{
		  document.getElementById('createusernamestatus').innerHTML = xmlHttp.responseText;
		}
	  }
	
	  xmlHttp.open("GET", "ajax_scripts/ajax_check_username_avail.php?desired_username=" + desiredUsername, true); 
	  xmlHttp.send(null);
	//}
}