dojo.require("dojox.embed.Flash");

dojo.declare("MovieController", null, {
	_container : null,
	_skin : null,
	_autoplay : null,
	_path : null,
	_movies : null,
	_height : 280,
	_width : 360,
	_movie : null,
	constructor : function(cfgObj) {
		this._container = cfgObj.container;
		this._skin = cfgObj.skin;
		this._autoplay = cfgObj.autoplay;
		this._path = cfgObj.path;
		this._movies = [];
			
		if(typeof cfgObj.height != "undefined") {
			this._height = cfgObj.height;
		}
			
		if(typeof cfgObj.width != "undefined") {
			this._width = cfgObj.width;
		}
	},
	add : function(cfgObj) {
		this._movies.push(cfgObj);
	},
	load : function(index) {
			
		this._movie = new dojox.embed.Flash({
			height : this._height,
			path : this._path,
			params : {
				quality : "high",
				salign : "lt",
				scale : "noscale",
				type : "application/x-shockwave-flash"
			},
			vars : {
				MM_ComponentVersion : 1,
				skinName : this._skin,
				streamName : this._movies[index].flv,
				autoPlay : this._autoplay,
				autoRewind : false
			},
			width : this._width
		}, this._container);
			
	},
	init : function() {
		dojo.forEach(this._movies, function(o, i) {
			dojo.forEach(o.triggers, function(o2, i2) {
				dojo.connect(o2, "onclick", this, function(e){
					this.load(i);
						
					dojo.stopEvent(e);
				});
			}, this);
		}, this);
	}
});
