/******************************************** Copyright Class ********************************************/
var swsystems = new Class({
///////////////////////////////////////////////// Options /////////////////////////////////////////////////
	options: {
		directory:false,
		swspecials:false,
		swgroups:false,
		swagents:false,
		swairport:false,
		swterms:false,
		swbookings:false,
		sufix:''
     },
///////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////// Constructor ///////////////////////////////////////////////
	initialize:function(id,options) {	
/*############################################# properties ##############################################*/
		var that = this;			//holds the instance

		this.id = id;				//holds the module number
		this.setOptions(options);  //sets the options

		//adds the instance to the cache array
		swsystemsCache.addInstances(this);
		
		this.wrapperDiv = null;	//holds the specials div wrapper
/*#######################################################################################################*/

/*############################################### methods ###############################################*/
		//creates the plugin content
		this.create = function(){
			this.wrapperDiv = $("specials_v"+this.id);		//get the specials div wrapper

			//writes the design information
			if(this.options.swspecials!=false)
				this.writespecials();
				
			if(this.options.swgroups!=false)
				this.writegroups();
				
			if(this.options.swterms!=false)
				this.writeterms();
				
			if(this.options.swbookings!=false)
				this.writebookings();
		};

		this.writespecials = function () {
			var myRequest = new Ajax('/php_internal/quotes/online/promotions/special_offers.php?'+this.options.swspecials,{
	            method: 'get',
	            onComplete : function(text) {
					that.wrapperDiv.innerHTML = "<div align='center'>"+text+"</div>";
					that.fireEvent('onComplete', that);
	            }
	        }).request();
		}
		
		this.writegroups = function () {
			var myRequest = new Ajax(this.options.directory+'plugins/content/swSystemsExtended/external.php?page='+this.options.swgroups,{
	            method: 'get',
	            onComplete : function(text) {
					that.wrapperDiv.innerHTML = "<div align='center'>"+text+"</div>";
					that.fireEvent('onComplete', that);
	            }
	        }).request();
		}
		
		this.writeterms = function () {
			var myRequest = new Ajax(this.options.directory+'plugins/content/swSystemsExtended/external.php?page='+this.options.swterms,{
	            method: 'get',
	            onComplete : function(text) {
					that.wrapperDiv.innerHTML = "<div align='center'>"+text+"</div>";
					that.fireEvent('onComplete', that);
	            }
	        }).request();
		}
		
		this.writebookings = function () {
			var myRequest = new Ajax('plugins/content/swSystemsExtended/external.php?page='+this.options.swbookings,{
	            method: 'get',
	            onComplete : function(text) {
					that.wrapperDiv.innerHTML = "<div class="+sufix+">"+text+"</div>";
					that.fireEvent('onComplete', that);
	            }
	        }).request();
		}

/*#######################################################################################################*/
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
});
swsystems.implement(new Events, new Options);
/*********************************************************************************************************/

/*************************************** Cache Object *******************************************/
var swsystemsCache = {
	instances:new Array(),		//holds the instances
	
	//adds an instance
	addInstances:function(obj){

		this.instances.push(obj);
	},
	
	//inicialize all instances
	loadInstances:function(){
		for (var i=0; i<this.instances.length; i++)
			this.instances[i].create();
	}
};
/**********************************************************************************************************/

/************************************ Initialize the instances *********************************/
window.addEvent("load",function(){
	swsystemsCache.loadInstances();
});
/*********************************************************************************************************/
