// JavaScript Document

function goPrevious(y,m){

var month;
var year;
if(m==1){
month=12;
year	=parseInt(y)-1;
}
else {
month=parseInt(m)-1;
year=y;
}
/*document.frmM.submitcal.onclick=true;
document.frmM.submit();
*/
var url	=	"calendar.php?year="+ year +"&month="+ month ;
//alert(url);
 if (window.XMLHttpRequest) { 
      req = new XMLHttpRequest();
      req.onreadystatechange = takeCal;
      try {
      	req.open("GET", url, true); //was get
      } catch (e) {
        alert("Problem Communicating with Server\n"+e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) 
      {
      req.onreadystatechange = takeCal;
        req.open("GET", url, true);
        req.send(null);
       
      }
    }
}
 function takeCal() 
   {
  	  if (req.readyState == 4)
  	   { // Complete
      if (req.status == 200) 
      { // OK response
    // alert("Ajax response:"+req.responseText);
        document.getElementById("show_calendar").style.display="inline";  
      document.getElementById("show_calendar").innerHTML=req.responseText 
                                  
      } 
      else 
      {
        alert("Problem with server response:\n " + req.statusText);
      }
    }
  }

function goNext(y,m){
var month;
var year;

if(m==12){
month=1;
year	=parseInt(y) + 1;
}
else {
month	= parseInt(m) + 1;
year=y;
}
var url	=	"calendar.php?year="+ year +"&month="+ month ;
//alert(url);
 if (window.XMLHttpRequest) { 
      req = new XMLHttpRequest();
      req.onreadystatechange = takeCal;
      try {
      	req.open("GET", url, true); //was get
      } catch (e) {
        alert("Problem Communicating with Server\n"+e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) 
      {
      req.onreadystatechange = takeCal;
        req.open("GET", url, true);
        req.send(null);
       
      }
    }
}
 function showToolTip(e,text){
	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}	

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}
function addEventForm(id,day)
{
var m	= document.frmM.month.value;
var y	= document.frmM.year.value;
if(day<10)
{
day="0"+day;
}

if(m<10)
{
m="0"+m;
}
var date	= y+"-"+m+"-"+day
 var url="event_details.php?date="+ date;
 	window.location	=	url;	
	// alert(url);
   
}
