function createXMLHttpRequest(){
	if (document.all){
		try {
			return new ActiveXObject("Microsoft.XMLHTTP");
		} 
		
		catch(e){}
		
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		
		catch(e){}
	}
	
	else {
		try {
			return new XMLHttpRequest();
		}
	
	catch(e){}
	}
	
	return null;
}

function IsIE(){
	return document.all ? true : false;
}

function E(id){
	return document.getElementById(id);
}

function more(type){
	var xmlrequest = createXMLHttpRequest();
	xmlrequest.open("POST", "picks-"+type+".html", true);
	xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlrequest.send("");
	xmlrequest.onreadystatechange = function(){
		if (xmlrequest.readyState == 4){
			switch(type){
				case "online":
					E("picks_online").innerHTML = xmlrequest.responseText;
				break;
				
				case "random":
					E("picks_random").innerHTML = xmlrequest.responseText;
				break;
			}
		}
	};
}

function addComment(gameId){
	E("newComment_submitbtn").value = " Submitting... ";
	E("newComment_submitbtn").disabled = true;
	var xmlrequest = createXMLHttpRequest();
	xmlrequest.open("POST", "inc/ajax/addComment.php?gameId="+gameId+"&user="+E('newComment_name').value+"&comment="+E('newComment_comment').value+"&captcha="+E('newComment_code').value, true);
	xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlrequest.send("");
	xmlrequest.onreadystatechange = function(){
		if (xmlrequest.readyState == 4){
			eval(xmlrequest.responseText);
		}
	};
}

function gameComments(gameId, page, tc){
	var xmlrequest = createXMLHttpRequest();
	xmlrequest.open("POST", "inc/ajax/gameComments.php?gameId="+gameId+"&gamePage="+page+"&tc="+tc, true);
	xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlrequest.send("");
	xmlrequest.onreadystatechange = function(){
		if (xmlrequest.readyState == 4){
			eval(xmlrequest.responseText);
		}
		else {
			E("ogComments").innerHTML = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td align=\"center\"><img src=\"images/v2/loading.gif\" width=\"31\" height=\"31\" alt=\"\" /></td></tr></table>";
		}
	};
}

function ifConfirmGoToLoc(confirmText, confirmUrl){
	if (confirm(confirmText)){
		self.location = confirmUrl;
	}
	else {
		return;
	}
}

function gameVote(gameId,yesno){
	var xmlrequest = createXMLHttpRequest();
	xmlrequest.open("POST", "inc/ajax/gameVote.php?gameId="+gameId+"&yesno="+yesno, true);
	xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlrequest.send("");
	xmlrequest.onreadystatechange = function(){
		if (xmlrequest.readyState == 4){
			eval(xmlrequest.responseText);
		}
	};
}
