/** Schedule Preview **/
var x;
var y;
var iWidth = 265;
var iHeight = 100;
var offset = 20;
var ie = document.all;
var timeID;
var startID;
var delay = 300;
var fillSpeed = 20;
var fullOpacity = 100;
var opacityInterval = 10;
var tipOpacity = 0;

function updatePos(e) {
	x = e.pageX;
	y = e.pageY;	
}

function ieUpdatePos(e) {
	x = event.clientX+document.documentElement.scrollLeft;
	y = event.clientY+document.documentElement.scrollTop;
}

document.onmousemove = ie ? ieUpdatePos : updatePos;
document.onclick = function(e) { 	document.getElementById('tip').style.visibility = 'hidden'; }
//document.onmouseover = function(e) { document.getElementById('tip').style.visibility = 'hidden'; }

function showTip() {
	tempX = xpos = x + offset;
	tempY = ypos = y + offset;

	if (tempX + iWidth > document.documentElement.clientWidth+document.documentElement.scrollLeft) {
		tempX -= (iWidth + offset);
	}
	if (tempY + iHeight > document.documentElement.clientHeight+document.documentElement.scrollTop) {
		tempY -= (iHeight + offset);
	}

	document.getElementById('tip').style.left = Math.floor(tempX) + 'px';
	document.getElementById('tip').style.top = Math.floor(tempY) + 'px';
	tipOpacity = 0;
	document.getElementById('tip').style.opacity = '0';
	document.getElementById('tip').style.filter = 'alpha(opacity:0)';
	document.getElementById('tip').style.visibility = 'visible';
	startID = setTimeout('timeID = setInterval("fadeIn()", fillSpeed)', delay);
}

function hideTip() {
	clearTimeout(startID);
	clearInterval(timeID);
	document.getElementById("tip").style.visibility = "hidden";
	document.getElementById('tip').style.filter = 'alpha(opacity:0)';
}

function fadeIn() {
	if (tipOpacity < fullOpacity) {
		tipOpacity += opacityInterval;
		document.getElementById('tip').style.opacity = tipOpacity/100;
		document.getElementById('tip').style.filter = 'alpha(opacity:' + tipOpacity + ')';
	} else {
		clearInterval(timeID);
		document.getElementById('tip').style.opacity = tipOpacity/100;
		document.getElementById('tip').style.filter = 'alpha(opacity:' + tipOpacity + ')';
	}
}

/** AJAX Part **/
var xmlHttp;

function showDance(day,type,month,year)
{
	document.getElementById("tip").innerHTML = "";
	showTip();
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="getinfo.asp"
	url=url+"?day="+day+"&type="+type+"&month="+month+"&year="+year
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("tip").innerHTML=xmlHttp.responseText;

		tipWidth = document.getElementById('tip').offsetWidth;
		tipHeight = document.getElementById('tip').offsetHeight;

		if (xpos + tipWidth > document.documentElement.clientWidth+document.documentElement.scrollLeft) {
			xpos -= (tipWidth + offset);
			document.getElementById('tip').style.left = Math.floor(xpos) + 'px';
		}
		if (ypos + tipHeight > document.documentElement.clientHeight+document.documentElement.scrollTop) {
			ypos = (document.documentElement.clientHeight+document.documentElement.scrollTop - tipHeight);
			document.getElementById('tip').style.top = Math.floor(ypos) + 'px';
		}
	} 
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
