var xmlHttpBox = false;
var xmlHttpD = false;
var xmlHttpST = false;
var xmlHttpNEWS = false;
var xmlHttpTOP = false;
var xmlHttpGD = false;
var xmlHttpPOLL = false;
var xmlHttpTPOLL = false;
var xmlHttpVPOLL = false;
var xmlHttpDONATE = false;
try {
  xmlHttpBox = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpD = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpST = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpNEWS = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpTOP = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpGD = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpPOLL = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpTPOLL = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpVPOLL = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttpDONATE = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttpBox = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpD = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpST = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpNEWS = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpTOP = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpGD = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpPOLL = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpTPOLL = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpVPOLL = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpDONATE = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttpBox = false;
	xmlHttpD = false;
	xmlHttpST = false;
    xmlHttpNEWS = false;
    xmlHttpTOP = false;
    xmlHttpGD = false;
    xmlHttpPOLL = false;
    xmlHttpTPOLL = false;
    xmlHttpVPOLL = false;
 	xmlHttpDONATE = false;
  }
}

if (!xmlHttpBox && typeof XMLHttpRequest != 'undefined') {
  xmlHttpBox = new XMLHttpRequest();
}
if (!xmlHttpD && typeof XMLHttpRequest != 'undefined') {
  xmlHttpD = new XMLHttpRequest();
}
if (!xmlHttpST && typeof XMLHttpRequest != 'undefined') {
  xmlHttpST = new XMLHttpRequest();
}
if (!xmlHttpNEWS && typeof XMLHttpRequest != 'undefined') {
  xmlHttpNEWS = new XMLHttpRequest();
}
if (!xmlHttpTOP && typeof XMLHttpRequest != 'undefined') {
  xmlHttpTOP = new XMLHttpRequest();
}
if (!xmlHttpGD && typeof XMLHttpRequest != 'undefined') {
  xmlHttpGD = new XMLHttpRequest();
}
if (!xmlHttpPOLL && typeof XMLHttpRequest != 'undefined') {
  xmlHttpPOLL = new XMLHttpRequest();
}
if (!xmlHttpTPOLL && typeof XMLHttpRequest != 'undefined') {
  xmlHttpTPOLL = new XMLHttpRequest();
}
if (!xmlHttpVPOLL && typeof XMLHttpRequest != 'undefined') {
  xmlHttpVPOLL = new XMLHttpRequest();
}
if (!xmlHttpDONATE && typeof XMLHttpRequest != 'undefined') {
  xmlHttpDONATE = new XMLHttpRequest();
}




function showspinner(){
var show_spinner = "<img src=\"../images/puckinnet.gif\">";
  document.getElementById("mainpage").innerHTML = show_spinner;
}

function updatePageBox() {
  if (xmlHttpBox.readyState == 4) {
    var response = xmlHttpBox.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageD() {
  if (xmlHttpD.readyState == 4) {
    var response = xmlHttpD.responseText;
	   document.getElementById("thescore").innerHTML = response;
  }
}
function updatePageST() {
  if (xmlHttpST.readyState == 4) {
    var response = xmlHttpST.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageNEWS() {
  if (xmlHttpNEWS.readyState == 4) {
    var response = xmlHttpNEWS.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageTOP() {
  if (xmlHttpTOP.readyState == 4) {
    var response = xmlHttpTOP.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageGD() {
  if (xmlHttpGD.readyState == 4) {
    var response = xmlHttpGD.responseText;
	   document.getElementById("thescore").innerHTML = response;
  }
}
function updatePagePOLL() {
  if (xmlHttpPOLL.readyState == 4) {
    var response = xmlHttpPOLL.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageTPOLL() {
  if (xmlHttpTPOLL.readyState == 4) {
    var response = xmlHttpTPOLL.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageVPOLL() {
  if (xmlHttpVPOLL.readyState == 4) {
    var response = xmlHttpVPOLL.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}
function updatePageDONATE() {
  if (xmlHttpDONATE.readyState == 4) {
    var response = xmlHttpDONATE.responseText;
	   document.getElementById("mainpage").innerHTML = response;
  }
}


function todaysboxscore() {
	 
  var mydate = document.getElementById("boxdate").value;
  
  // Build the URL to connect to
  var url = "todaysboxscore.php"+"?mydate="+escape(mydate);
  
  // Open a connection to the server
  xmlHttpD.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpD.onreadystatechange = updatePageD;

  // Send the request
  xmlHttpD.send(null);
}


function boxscore() {
	
   showspinner();
   
  // Build the URL to connect to
  var url = "checkboxscore.php";
  
  // Open a connection to the server
  xmlHttpBox.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpBox.onreadystatechange = updatePageBox;

  // Send the request
  xmlHttpBox.send(null);
}

function standings() {
   // Build the URL to connect to
  var url = "standings.php";
  
  // Open a connection to the server
  xmlHttpST.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpST.onreadystatechange = updatePageST;

  // Send the request
  xmlHttpST.send(null);
}

function hockeynews() {
	
  showspinner();
  // Build the URL to connect to
  var url = "rssespn.php";
  
  // Open a connection to the server
  xmlHttpNEWS.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpNEWS.onreadystatechange = updatePageNEWS;

  // Send the request
  xmlHttpNEWS.send(null);
}

function topplayers() {
	
  showspinner();
   // Build the URL to connect to
  var url = "topplayers.php";
  
  // Open a connection to the server
  xmlHttpTOP.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpTOP.onreadystatechange = updatePageTOP;

  // Send the request
  xmlHttpTOP.send(null);
}

function gamedetails(gameid) {
	   
  // Build the URL to connect to
  var url = "gamedetails.php"+"?gameid="+escape(gameid);
  
  // Open a connection to the server
  xmlHttpGD.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpGD.onreadystatechange = updatePageGD;

  // Send the request
  xmlHttpGD.send(null);
}

function poll() {
	
   showspinner();
   
  // Build the URL to connect to
  var url = "poll.php";
  
  // Open a connection to the server
  xmlHttpPOLL.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpPOLL.onreadystatechange = updatePagePOLL;

  // Send the request
  xmlHttpPOLL.send(null);
}
function takepoll() {
	
  if (document.getElementById("p1").checked == true){
	  var choice = document.getElementById("p1").value;  
  } else if (document.getElementById("p2").checked == true){
	  var choice = document.getElementById("p2").value; 
  } else if (document.getElementById("p3").checked == true){
	  var choice = document.getElementById("p3").value; 
  } else if (document.getElementById("p4").checked == true){
	  var choice = document.getElementById("p4").value; 
  } else if (document.getElementById("p5").checked == true){
	  var choice = document.getElementById("p5").value; 
  } else if (document.getElementById("p6").checked == true){
	  var choice = document.getElementById("p6").value; 
  } else if (document.getElementById("p7").checked == true){
	  var choice = document.getElementById("p7").value; 
  } else if (document.getElementById("p8").checked == true){
	  var choice = document.getElementById("p8").value; 
  } else {
		alert("You need to make a choice");  
  }
  
  // Build the URL to connect to
  var url = "takepoll.php"+"?choice="+escape(choice);
  
  // Open a connection to the server
  xmlHttpTPOLL.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpTPOLL.onreadystatechange = updatePageTPOLL;

  // Send the request
  xmlHttpTPOLL.send(null);
}
function viewpoll() {

   showspinner();
  
  // Build the URL to connect to
  var url = "viewpoll.php";
  
  // Open a connection to the server
  xmlHttpVPOLL.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpVPOLL.onreadystatechange = updatePageVPOLL;

  // Send the request
  xmlHttpVPOLL.send(null);
}

function donate() {
	
    
  // Build the URL to connect to
  var url = "donate.php";
  
  // Open a connection to the server
  xmlHttpDONATE.open('GET', url, true);

  // Setup a function for the server to run when it's done
  xmlHttpDONATE.onreadystatechange = updatePageDONATE;

  // Send the request
  xmlHttpDONATE.send(null);
}
