function createObject()
{
	var request_type;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  request_type=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		request_type=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  request_type=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  return request_type;
}

function updateLolNumber(username, linkId, incrementFactor)
{
	//alert(document.getElementById('b'+linkId).src);
	if(incrementFactor==1 && document.getElementById('b'+linkId).src.indexOf('greydown.gif')!=-1)
		document.getElementById('a'+linkId).src='up.gif';
	if(incrementFactor==-1 && document.getElementById('a'+linkId).src.indexOf('greyup.gif')!=-1)
		document.getElementById('b'+linkId).src='down.gif';
	xmlHttp = createObject();
	xmlHttp.open("get", "updateLol.php?username=" + username + "&linkId=" + linkId + "&incrementFactor=" + incrementFactor, true);
	xmlHttp.onreadystatechange = function(){processRequest(linkId);}
	xmlHttp.send(null);
}

function processRequest(linkId)
{
	//if(xmlHttp.readyState == 4)
		//alert('hi');
	
	if(xmlHttp.readyState == 4)
		document.getElementById(linkId).innerHTML = xmlHttp.responseText;

}

//Login

function login(username, password)
	{
	//alert(username + " " + password);
	xmlHttp = createObject();
	xmlHttp.open("get", "afterlogin.php?username="+username+"&password="+password, true);
	xmlHttp.onreadystatechange=function(){processLogin();}
	xmlHttp.send(null);
	}
	
function processLogin()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.responseText!="0")
		{
			document.getElementById('login').innerHTML="Welcome " + xmlHttp.responseText;
			toggleOn('logindrop');
		}
		else
		{
			document.getElementById('error').innerHTML="Incorrect username/password.";
		}
	}
}
			















