var active = false;

function showCalInfo(day, eventContent) {
	
	active = true;
	document.body.style.cursor = 'hand';
	
	var calInfoDay;
	calInfoDay = document.getElementById("calInfoDay");
	calInfoDay.innerHTML = day;
	
	var calInfoContentEvents;
	calInfoContentEvents = document.getElementById("calInfoContentEvents");
	calInfoContentEvents.innerHTML = eventContent;
	
	var calInfo;
	calInfo = document.getElementById("calInfo");
	calInfo.style.zIndex = '1';		
	
	//capture mouseevent
	if (window.Event) {
    	document.captureEvents(Event.MOUSEMOVE);
 	}	   
	document.onmousemove = mousemove;
			   
	calInfo.style.visibility = 'visible';
}

function mousemove(e) {

	var calInfo = document.getElementById("calInfo");

	var std_width = 150;
	var std_height = 80;
	
	x = (window.Event) ? e.pageX : event.clientX;
  	y = (window.Event) ? e.pageY : event.clientY;
	
	if (active) {
		
		winWidth = getWinWidth();
		pad_left = (winWidth - 1016)/2;
		
		var calInfoWidth = calInfo.clientWidth;
		var calInfoHeight = calInfo.clientHeight;
		
		//alert(calInfoWidth + " : " + calInfoHeight);
		
		left_shift = 165;
		top_shift = 85;
		
		width_correction = calInfoWidth - std_width;
		height_correction = calInfoHeight - std_height;
		
		document.getElementById('calInfo').style.left = (x - pad_left - left_shift - width_correction) + 'px';
		document.getElementById('calInfo').style.top = (y - top_shift - height_correction) + 'px';
	}
}

function hideCalInfo() {
	
	active = false;
	document.body.style.cursor = 'default';
	
	var calInfo;
	calInfo = document.getElementById("calInfo");
	
	calInfo.style.zIndex = '1000';
	calInfo.style.visibility = 'hidden';
}

function getWinWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  
  return myWidth;
}
