 ////////////////////////////
 //			XHR			   //
 ////////////////////////////
 
 function useXHR(method, file, async, readyFunction, params){
	var xhr = getXHR(); 
	setXHRMethod(xhr, method, file, async);
	xhr.onreadystatechange = function(){
		if (xhr.readyState == 4){
			var threechars = readyFunction.substring(0,3);
			if (readyFunction == "removeGameFromFreeAgent"){
				getData("freeagentgames.php", callback, "freeagentgames", '', ''); 
			} 
			else if (readyFunction == "removeGameFromTeam"){
				getData("teamgames.php", callback, "teamgames", '', '');
			}
			else if (threechars == "pan"){
				document.getElementById(readyFunction).innerHTML = xhr.responseText;
			}
			else if (readyFunction.split('.')[1] == "php"){
				location.assign(readyFunction);
			}
			else if (readyFunction.indexOf("(") != -1){
				readyFunction();
			}
			delete xhr;
			xhr = null;
		}
	}
	XHRSend(xhr, method, params);
 }
 
 function getXHR(){
	 if (window.XMLHttpRequest) {
	  	return new XMLHttpRequest();
	 } 
	 else if (window.ActiveXObject) {
	  	return new ActiveXObject("Microsoft.XMLHTTP");
	 }
 }
 
 function setXHRMethod(xhr, method, file, async){
	 xhr.open(method,file,async);
 }
 
 function XHRSend(xhr, method, params){
	 if (method == "POST"){
		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		var sendParams = "";
		for (var i = 0; i < params.length; i++){
			if (i == 0){
				sendParams += params[i];
			}
			else{
				sendParams += "&" + params[i];	
			}
		}
		xhr.send(sendParams);
	 }
	 else{
		xhr.send(null);
	 }
 }
 
 ////////////////////////////
 //		   XHR END		   //
 ////////////////////////////

function moveDiv(e, div, adjst){
	if (navigator.appName != "Microsoft Internet Explorer"){
		e = e || window.event;
		document.getElementById(div).style.position="absolute";
		//document.getElementById(div).style.margin="auto auto";
		if (e.clientX > (innerWidth/2)){
			var profileWidth = 450;
			document.getElementById(div).style.left= (e.clientX - profileWidth - 40) + "px";
		}
		else{
			document.getElementById(div).style.left= (e.clientX + 40) + "px";
		}
		
		var profileHeight = 460;
		/*if (e.clientY > (innerHeight - (profileHeight/2))){
			document.getElementById(div).style.marginTop = (e.clientY - profileHeight - 50) + "px";	
		}
		else{
			document.getElementById(div).style.marginTop = (e.clientY - profileHeight - 50) + "px";	
		}*/
		document.getElementById(div).style.top= (e.clientY + pageYOffset - (profileHeight/2) + 30) +"px";
	}
	else{
		document.getElementById(div).style.left= 0 + "px";	
		document.getElementById(div).style.top= -1000 + "px";	
	}
}