//functions.js
//Create a boolean variable to check for a valid IE instance.
var xmlhttp = false;

//Check if we are using IE.
try {
//If the javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
//If not, then use the older active x object.
try {
//If we are using IE.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp = false;
}
}
//If we are using a non-IE browser, create a JavaScript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}

function showSpan(theNumber) {
//alert(theNumber);
var arr = new Array();
arr = document.getElementsByTagName("span");
var theCount=0;
 for(var i=0; i < arr.length; i++){
	if (document.getElementsByTagName("span").item(i).title=="menu"){
		theCount=theCount+1;
		//alert(document.getElementsByTagName("span").item(i).title);
		var theOffID="menu" + theCount;
		//alert(theOffID);
		document.getElementById(theOffID).style.display='none';
		document.getElementById("btn" + theCount).style.backgroundColor='#f0f0f0';
		document.getElementById("btn" + theCount).style.color='black';
	}
}
var theOnID="menu" + theNumber;
document.getElementById(theOnID).style.display='block';
document.getElementById("btn" + theNumber).style.backgroundColor='rgb(4,53,52)';
document.getElementById("btn" + theNumber).style.color='yellow';
//document.getElementById("menuHead").innerHTML=document.getElementById("btn" + theNumber).value;
//alert(theOnID);
}

function monthView(theID){
//alert("hi");
xmlhttp.open("GET", "calendarMonthly.php");
xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById([theID]).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send(null);
}

function showHideCalendar(theMonth,operat,theYear) {
if (theMonth<1){
	theMonth=12;
	theYear=theYear-1;
}else if (theMonth>12){
	theMonth=1;
	theYear=theYear+1;
}else{
}
//alert(theMonth);
//The location we are loading the page into.
var objID = "gameCalendar";
var serverPage = "calendarMonthly.php?month=" + theMonth  + "&year=" + theYear;

xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("gameCalendar").innerHTML=xmlhttp.responseText;
//obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}