// <![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 SMSTemplate = {	
	clearDiv : function (div) {	
		$(div).value = '';
	},
	populateObjects : function ( templateID , subjectName , bodyName ,  progressBar ) {	
		
		if(subjectName != ''){
			SMSTemplate.addString( templateID , 'subject' , subjectName, progressBar );
		}
		if(bodyName != ''){			
			SMSTemplate.addString( templateID , 'body' , bodyName , progressBar );
		}
		SMSTemplate.showProgress (progressBar, '');		
	},
	addString : function ( templateID , objectType , receiverName , progressBar ){		
		if($(receiverName)){		
			ajaxObject = function () {	
				this.OnLoading = function () {	
					var image = "<img src=\"/images/icons/progress.gif\" alt=\"loading icon\" title=\"loading icon\" class=\"icor\">";
					SMSTemplate.showProgress (progressBar, "<div id=\"progress\">"+image+"Loading. please wait..."+"</div>")
				}
				this.OnSuccess = function () {	
					if(this.GetResponseText() != ''){
						SMSTemplate.writeInnerHTML ( receiverName , this.GetResponseText() )
					}					
				}
				this.GetData = function() {
					this.InitializeRequest('GET', "/smstemplate.ajax.php?link="+objectType+"&id="+templateID+"&name="+receiverName);
					this.Commit(null);
				}
			}
			ajaxObject.prototype = new ajax();
			createEvent = new ajaxObject();
			createEvent.GetData();
		}
	},
	writeInnerHTML : function ( div , results  ) {	
		$(div).value = results;	
	},
	showProgress : function ( div , results ) {	
		$(div).innerHTML = results;
	}
}