// GetXmlHttpObject
function GetXmlHttpObject(){
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();}
		catch (era){
			//Internet Explorer
			try{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
			catch (erb){
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
		return xmlHttp;}
		
// CLASSES CHANGED	
function classesChanged() 
{ 
if (UCxmlHttp.readyState==4 || UCxmlHttp.readyState=="complete")
	{ 
	document.getElementById('program_calendar').innerHTML=UCxmlHttp.responseText;
	}
updateCalendarDisplay();
}
	
// UPDATE CLASSES
function changeDate(selectedDate)
	{
	document.getElementById('program_calendar').innerHTML='<div class="loadUpdate"><p>Updating...</p><img src="/_images/_calendar/graphic_loading.gif" alt="Updating..." /></div>';	
	UCxmlHttp=GetXmlHttpObject();
	if (UCxmlHttp===null)
		{
		alert ("Browser does not support HTTP Request");
		return;
		}
	var url="/_includes/_calendar/program_calendar.php";
	url=url+"?date_id="+selectedDate;
	url=url+"&sid="+Math.random();
	UCxmlHttp.onreadystatechange=classesChanged;
	UCxmlHttp.open("GET",url,true);
	UCxmlHttp.send(null);
	}

// UPDATE DISPLAY CALENDAR
function updateCalendarDisplay()
	{
	var countInputs = document.getElementsByTagName('input');
	//alert(countInputs.length);
	var countSpans= document.getElementsByTagName('span');
	//alert(countSpans.length);
	var tagValue;
	// HIDE EVERYTHING FIRST
	for (j=0 ; j < countSpans.length ; j++)
		{
		if (countSpans[j].className.indexOf('calx') != -1)
			{
			//countSpans[j].style.display='none';
			}
		}
	// NOW SHOW LOCATIONS CHECKED OFF
	for (i=0 ; i < countInputs.length ; i++)
		{
		if (countInputs[i].className=='calloc' && countInputs[i].checked)
			{
			tagValue = countInputs[i].value;
			for (j=0 ; j < countSpans.length ; j++)
				{
				if (countSpans[j].className.indexOf(tagValue) != -1)
					{
					countSpans[j].style.display='';
					}
				}
			}
		}
	// NOW HIDE DAYS AND TIMES NOT OFF
	for (i=0 ; i < countInputs.length ; i++)
		{
		if (countInputs[i].className=='calv' && countInputs[i].checked==false)
			{
			tagValue = countInputs[i].value;
			for (j=0 ; j < countSpans.length ; j++)
				{
				if (countSpans[j].className.indexOf(tagValue) != -1)
					{
					countSpans[j].style.display='none';
					}
				}
			}
		}
	}

