// <![CDATA[
/*
* Copyright: 2005 - 2007 SI Works Internet Solutions
* If you have come across this page, its cause you are snooping through code, and are generally a developer as such
* If you would like to use some of the code on this page, please simply email support@siworks.co.za and ask permission
* it would be much appreciated, as we have worked very hard on these func.tions() and scri.pts()
* 
* Note: All functions below are to make sure that we are sticking to standards and are mainly
* for visual effects and loading events and handlers.
*
* Calendar object that builds the calendar and sends Ajax requests
* @page calendar.class.js
* @version 1.0.2
* @author Greg Shiers, Jarratt Ingram (SI Works Internet)
* @copyright: SI Works Internet Solutions 2005 - 2007
*/

var Calendar = {	
	clearDiv : function (div) {	
		$(div).innerHTML = 'No Calendar available';
	},
	createEventElement : function ( eventID ) {	
		if ($("event")) {
			Calendar.removeEventElement();
		}
		var element = $_C("div");
			element.setAttribute('id','event');
			element.style.position = "absolute";
			element.style.top = "65px";
			element.style.left = "220px";
			$('eCalendar').style.position = "relative";
			$('eCalendar').appendChild(element);
			if ( element ) {
				ajaxObject = function () {	
					this.OnLoading = function () {	
						var image = "<img src=\"/images/icons/progress.gif\" alt=\"loading icon\" title=\"loading icon\" class=\"icor\">";
						Calendar.writeInnerHTML ('event', "<div id=\"progress\">"+image+"Loading. please wait..."+"</div>")
					}
					this.OnSuccess = function () {	
						Calendar.writeInnerHTML ( 'event' , this.GetResponseText() )
					}
					this.GetData = function() {
						this.InitializeRequest('GET', "/event.ajax.php?link=details&id="+eventID);
						this.Commit(null);
					}
				}
				ajaxObject.prototype = new ajax();
				createEvent = new ajaxObject();
				createEvent.GetData();
			}
	},
	removeEventElement : function ( ) {	
		$('eCalendar').style.position = "";
		var parent = $('eCalendar');
			parent.removeChild($("event"));
	},
	writeInnerHTML : function ( div , results ) {	
		$(div).innerHTML = results;
	},
	navigate : function ( year , month  ) {	
		ajaxObject = function () {	
			this.OnSuccess = function () {	
				Calendar.writeInnerHTML ( "eCalendar" , this.GetResponseText() )
			}
			this.GetData = function() {
				this.InitializeRequest('GET', "/event.ajax.php?link=calendar&year="+year+"&month="+month);
				this.Commit(null);
			}
		}
		ajaxObject.prototype = new ajax();
		navigateCalendar = new ajaxObject();
		navigateCalendar.GetData();
	}
}