var videoPlayer = {		
	
	//where the swfObject gets stored
	vidObj:{},
			
	config: {
		VIDEO_ID: "video-player",
		ACTIVE_CLASS: "active",
		VIDEO_EMBED_ID: "drtvplayer",
		SWF_PATH: "/text/flash/drtvplayer.swf",
		SWF_SKIN: "/text/flash/drtvSkin.swf",
		SWF_STARTPIC: "",
		SWF_VIDEO: "",
		SWF_WIDTH: 286,
		SWF_HEIGHT: 252,
		SWF_VERSION: 9,
		SWF_BGCOLOR: "#FFFFFF",
		SWF_VIDEO_OFFSET_WIDTH: 10,
		SWF_VIDEO_OFFSET_HEIGHT: 45,
		AUTO_PLAY: false,
		HIDEABLE: false,
		VIDEO_WRAPPER: "video-wrapper"
	},
	
	insert:function(config){
		this.loadConfig(config);
		
		if(!this.config.SWF_STARTPIC || !this.config.SWF_VIDEO) {
			document.getElementById(this.config.VIDEO_ID).innerHTML = "<p>Missing some parameters required to load the video</p>";
			return;
		}
		
		this.vidObj = new SWFObject(this.config.SWF_PATH, this.config.VIDEO_EMBED_ID, this.config.SWF_WIDTH, this.config.SWF_HEIGHT, this.config.SWF_VERSION, this.config.SWF_BGCOLOR);
		this.vidObj.addVariable("videoWidth", this.config.SWF_WIDTH - this.config.SWF_VIDEO_OFFSET_WIDTH);
		this.vidObj.addVariable("videoHeight", this.config.SWF_HEIGHT - this.config.SWF_VIDEO_OFFSET_HEIGHT);
		this.vidObj.addVariable("playerSkinURL", this.config.SWF_SKIN);
		this.vidObj.addVariable("startImageURL", this.config.SWF_STARTPIC);
		this.vidObj.addVariable("playerSourceURL", this.config.SWF_VIDEO);

		if(this.config.AUTO_PLAY) {
			this.vidObj.addVariable("autoPlay", this.config.AUTO_PLAY);
			this.start();
		}

		this.vidObj.addParam("wmode", "transparent");
		this.vidObj.useExpressInstall('flash/expressinstall.swf');
		this.vidObj.write(this.config.VIDEO_ID);		
	},
	
	start:function(){
		var vid;
		
		if(vid=this.getVideoWrapper()) {
			vid.className=this.config.ACTIVE_CLASS;
		}
		
		this.getVideo().className=this.config.ACTIVE_CLASS;
	},
	
	stop:function(){
		var vid;
		if(vid=this.getVideoWrapper()){
			vid.className="";
		}
		this.getVideo().className="";
		
		if(this.config.HIDEABLE) {
			this.hideVideo();
		}
	},
		
	hideVideo: function(){
		//because the flash object fires the stop method the scope chain needs to return a value eventually 
		//back to it.  if we destroy the flash object without breaking the scope chain, it will cause the 
		//flash plugin to block indefinitely.  so we use a timer to get around this
		var self=this;
		setTimeout(function(){
			self.getVideo().removeChild(self.getVideo().firstChild);
		},0);
	},
	
	paused:function(){
		//empty function FOR NOW!! DUH DUH DUH
	},

	getVideo:function(){
		return document.getElementById(this.config.VIDEO_ID);
	},
	
	getVideoWrapper:function(){
		return document.getElementById(this.config.VIDEO_WRAPPER);
	},
	
	getFlashObj:function(){
		return document.getElementById(this.config.VIDEO_EMBED_ID);
	},
	
	playVideo:function(){
		this.getFlashObj().playVideo("null");
	},
	
	loadConfig: function(config_file){
		if(config_file){
			for(i in this.config){
				this.config[i] = config_file[i] || this.config[i];
			}
		}			
	}
};