featureDisplay = {};

FeatureDisplay = Class.create();
FeatureDisplay.prototype = {
	
	initialize: function(id, app, options) {
		this.id = id;
		this.app = app;
		this.self = $(this.id);
		this.container = $(this.id + '_container');
		//this.self.onfocus = function() {this.blur();};
		
		this.options = options || {};
		
		if (browser.hasFlash8 || browser.isIE && browser.hasFlash) {
			Element.show(this.id+'_container');
			this.fob = $(this.id + '_object');
		
			updaters[this.id] = new Updater(this.id, this.app, '', {parent:this});
			this.updater = updaters[this.id];
			
			var me = this;
			page_init.scripts['feature_'+id] = function() {
				screen_overlay.register(me);
				me.loadFeatures();
			};
		} else {
			Element.show(this.id+'_no_flash');
		}		
		
	},
	
	loadFeatures: function() {
		var callParams = [];
		if (this.options.type) callParams.push('type='+this.options.type);
		this.updater.run(callParams, 'LoadFeatures', '');
	},
	
	ajaxUpdate: function(ajaxResponse) {
	
		var args = {main:{},
					selector:{initVars:[]}
		};
		
		var features = ajaxResponse.getElementsByTagName('feature');
		if (console) console.log(features.length);
		if (features) {
			for(var i=0; i<features.length; ++i) {
				var ob = {media:features[i].getAttribute('media'), link:features[i].getAttribute('link'), target:'_self', dur:features[i].getAttribute('dur')};
				if (console) console.log('FEATURE: '+ob.media+' => '+ob.link);
				if (i == 0) {
					args.main = ob;
				}
				args.selector.initVars.push(ob);						  
			}
		}
		
		this.fob.initFeatures(args);
	},
	
	show: function() {
		this.container.style.visibility = '';
	},
	
	hide: function() {
		this.container.style.visibility = 'hidden';
	}
	
};