var sCalendarFeed = '';
var xmlhttpcalendarfeed;

function get_calendarfeed(sDate, sType){
	sCalendarFeed = '';
	
	var d = new Date();
	load_calendarfeed('../common/calendar_feed.asp?t=' + sType + '&d=' + sDate + '&time=' + d.getFullYear() + d.getMonth() + d.getDate());
}

function load_calendarfeed(url) {
	xmlhttpcalendarfeed=null;

	if (window.XMLHttpRequest) {
		// code for Mozilla, etc.
		xmlhttpcalendarfeed=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// code for IE
		xmlhttpcalendarfeed=new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xmlhttpcalendarfeed!=null) {
		xmlhttpcalendarfeed.onreadystatechange=calendarfeed_state_Change;
		xmlhttpcalendarfeed.open("GET",url,true);
		xmlhttpcalendarfeed.send(null);
	} else {
		alert("Your browser does not support XMLHTTP.");
	}
}			

function calendarfeed_state_Change() {

	// if xmlhttpcalendarfeed shows "loaded"
	if (xmlhttpcalendarfeed.readyState==4) {
		// if "OK"
		if (xmlhttpcalendarfeed.status==200) {
			// ...some code here...		 
			sCalendarFeed = xmlhttpcalendarfeed.responseText;
			update_calendar_popup();
		}
	}
}

function update_calendar_popup(){
	document.getElementById('calendar_popup_details').innerHTML = sCalendarFeed
}

function show_calendar_item(sCalendarItemDate, sCalendarItemText, sCalendarItemType){
	get_calendarfeed(sCalendarItemDate, sCalendarItemType)
	
	document.getElementById('calendar_popup_date').innerHTML = sCalendarItemText

	document.getElementById('calendar_popup_shadow').style.display = '';
	document.getElementById('calendar_popup'       ).style.display = '';
}

function hide_calendar_item(){
	document.getElementById('calendar_popup'       ).style.display = 'none';
	document.getElementById('calendar_popup_shadow').style.display = 'none';

	document.getElementById('calendar_popup_details').innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/com/loading.gif'></td></tr></table>"
}