window._swfName = "ApArchive";
window.p_auto = true;
window.p_mode = "progressive";
window.p_rtmp = null;
window.p_flv = null;

function controller(path, params) {
	switch(path) {
		// the SWF calls this JS function when AC_RunActiveContent loads SWF, so that JS can call SWF functions (ie play, seek, etc), without this acknowledgement JS can throw error trying to access functions that are not ready.  
		case 'VideoSwfReady': 
			controller.initilized = true;
			controller('PlayVideo', [window.p_flv, window.p_mode, window.p_rtmp, window.p_auto]);
			break;
		// JS call to play video on SWF, params are p1 = p_flv (Video Source String), p2 = p_mode (Stream or Progressive Mode String), p3 = p_auto (AutoPlay Mode Boolean) 
		case 'PlayVideo': 
			swf(window._swfName).PlayVideo(params[0], params[1], params[2], params[3]);
			break;
		// JS call to seek video to specified seconds
		case 'SeekToVideoAt': 
			var decimalPlaces = Math.pow(10, 2);
	  	var seconds = Math.round(decimalPlaces * params) / decimalPlaces;
			swf(window._swfName).SeekToVideoAt(params);
			break;
	}
}
controller.initilized = false;

function swf(swf) {
	if (window.document[swf]) { return window.document[swf]; }
	else if (document.embeds && document.embeds[swf]) { return document.embeds[swf]; }
	else { return document.getElementById(swf); }
}
					
var VideoPlayerProxy = Class.create();					
VideoPlayerProxy.prototype = {
  initialize: function(holderId) {
		this.holderId = holderId;
		var args = Object.extend({
			'codebase': 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
			'name': window._swfName,
			'id': window._swfName,
			'width': '320',
			'height': '280',
			'align': 'middle',
			'quality': 'high',
			'bgcolor': '#FFFFFF',
			'play': 'true',
			'loop': 'true',
			'devicefont': 'false',
			'scale': 'showall',
			'wmode': 'transparent',
			'menu': 'false',
			'allowfullscreen': 'false',
			'allowscriptaccess': 'always',
			'pluginspage': 'http://www.macromedia.com/go/getflashplayer',
			'src': '/images/flash/flvPlayer',
			'movie': '/images/flash/flvPlayer'
		}, arguments[1] || {});
		
		this.html = AC_FL_RunContent.apply(this, $H(args).toArray().flatten());
  },
  
  renderPlayer: function() {
		if(window.p_flv != "") {
			if(document.write == Prototype.emptyFunction)
				$(this.holderId).update(this.html);
			else
				document.write(this.html);
		}
  },

	Seek: function(time) {
		controller("SeekToVideoAt", time);
	}
};