// <![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 Program = {	
	clearDiv : function (div) {	
		$(div).innerHTML = 'No modules available';
	},
	clearModules : function (div) {	
		$(div).innerHTML = 'No program selected.';
	},
	createModuleElement : function ( programID , moduleName , divName ) {	
		
		if($(divName)){		
			ajaxObject = function () {	
				this.OnLoading = function () {	
					var image = "<img src=\"/images/icons/progress.gif\" alt=\"loading icon\" title=\"loading icon\" class=\"icor\">";
					Program.writeInnerHTML (divName, "<div id=\"progress\">"+image+"Loading. please wait..."+"</div>")
				}
				this.OnSuccess = function () {	
					if(this.GetResponseText() != ''){
						Program.writeInnerHTML ( divName , this.GetResponseText() )
					}
					else{
						Program.clearDiv(divName);
					}
					
				}
				this.GetData = function() {
					this.InitializeRequest('GET', "/program.ajax.php?link=modules&id="+programID+"&name="+moduleName);
					this.Commit(null);
				}
			}
			ajaxObject.prototype = new ajax();
			createEvent = new ajaxObject();
			createEvent.GetData();
		}
	},
	createProgramModules : function ( programID , divName) {	
		
		if($(divName)){		
			ajaxObject = function () {	
				this.OnLoading = function () {	
					var image = "<img src=\"/images/icons/progress.gif\" alt=\"loading icon\" title=\"loading icon\" class=\"icor\">";
					Program.writeInnerHTML (divName, "<div id=\"progress\">"+image+"Loading. please wait..."+"</div>")
				}
				this.OnSuccess = function () {	
					if(this.GetResponseText() != ''){
						Program.writeInnerHTML ( divName , this.GetResponseText() )
					}
					else{
						Program.clearDiv(divName);
					}
					
				}
				this.GetData = function() {
					this.InitializeRequest('GET', "/program.ajax.php?link=programs&id="+programID);
					this.Commit(null);
				}
			}
			ajaxObject.prototype = new ajax();
			createEvent = new ajaxObject();
			createEvent.GetData();
		}
	},
	writeInnerHTML : function ( div , results ) {	
		$(div).innerHTML = results;
	}
}