var xmlHttp
var toElement

function showSchedule(week, year)
{ 
	toElement = 1;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert("Your browser does not support this application.  You need a browswer that supports AJAX.");
  		return;
  	} 
	var url = "/scripts/schedule.asp";
	url = url + "?week=" + week;
	url = url + "&year=" + year;
	url = url + "&sid=" + Math.random();
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function reload(pweek, pyear)
{
	showSchedule(pweek, pyear);
}

function showTable(dbstring, strCategory, strConstraint, strCriteria)
{ 
	toElement = 2;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert("Your browser does not support this application.  You need a browswer that supports AJAX.");
  		return;
  	} 
	var url = "/scripts/gettable.asp";
	url = url + "?db=" + dbstring;
	url = url + "&cate=" + strCategory;
	url = url + "&cons=" + strConstraint;
	url = url + "&crit=" + strCriteria;
	url = url + "&sid=" + Math.random();
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function switchId(id){	
	if (document.getElementById(id).style.display == 'none')
	{
		document.getElementById(id).style.display = 'block';
	}
	else
	{
		document.getElementById(id).style.display = 'none';
	}
}

function show(id)
{
	document.getElementById(id).style.display = 'block';
	document.getElementById('show'+id).style.display = 'none';
	document.getElementById('hide'+id).style.display = 'block';
}

function hide(id)
{
	document.getElementById(id).style.display = 'none';
	document.getElementById('show'+id).style.display = 'block';
	document.getElementById('hide'+id).style.display = 'none';
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		if (toElement==2)
		{
			document.getElementById("stattable").innerHTML=xmlHttp.responseText;
		}
		else
		{
			document.getElementById("schedule").innerHTML=xmlHttp.responseText;
		}
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
  	{
  		// Internet Explorer
  		try
    	{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e)
    	{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}
