	var xmlUrl = '/page_templates/act/act_generate-event-xml.cfm';
  
  var events = getEventObj();
  

  function getResponseXml(xmlUrl) {
	var xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  }
	if (xmlhttp!=null){
		xmlhttp.open("GET", xmlUrl, false);
		xmlhttp.send(null);
		return xmlhttp;
	}
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function getEventObj(){
	var xmlHttpRequest =getResponseXml(xmlUrl);
  
  	var xmlObj = xmlHttpRequest.responseXML;

	var xmlDoc = xmlObj.documentElement;
    //Handle data.
	
	return xmlDoc.getElementsByTagName('event');
};
  
  function getEvent(year, month, day) {
  	
		var date = day+'-'+(month+1)+'-'+year;

		var isSpecial= false;
		
		for(i=0;i<events.length;i++){
			var eventurl = getValueByTagName(events,"url");		
			var eventDate = getValueByTagName(events,"startdate");

			if(date == eventDate){
				isSpecial = eventurl;
			}
		}
		return isSpecial;
	};

function getValueByTagName(node, tag) {
  var a = node[i].getElementsByTagName(tag)[0];
  if (a) {
    if (a.firstChild && a.firstChild.nodeValue) {
		
      return(a.firstChild.nodeValue);
	  
    }
  } else {
  console.log("node[" + i + "] is null: tag=" + tag);
  }
};
	
  function dateChanged(calendar) {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked) {
      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth();     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
	  var eventUrl = getEvent(y, m, d);
	   if (eventUrl){
		window.location = eventUrl;
	  }
	  
	
    }
  };

  function specialDateStatusFunc(date, y, m, d) {
    if (getEvent(y, m, d))
      return "special";
    else
      return false; // other dates are enabled
      // return true if you want to disable other dates
  };	