function VideoPlayer(t, w, h) {
	this._root = globalroot;
	this._domain = this.getDomain();
	this._path = this.getPath();
	
	this._file;
	this._width;
	this._height;
	this._type;
	this._playlist;
	this._playlistsize;
	this._streamer;
	
	if (t) {
		this.setType(t);
	}
	if (w) {
		this.setWidth(w);
	}
	if (h) {
		this.setHeight(h);
	}
	
	
}

VideoPlayer.prototype.getDomain = function() {
	var d = document.domain;
	return d;
}

VideoPlayer.prototype.getPath = function() {
	var myloc = window.location.href;
	var locarray = myloc.split("/");
	delete locarray[(locarray.length-1)];
	var arraytext = locarray.join("/");
	return arraytext;
}

VideoPlayer.prototype.setFile = function(p) {
	this._file = p;
}

VideoPlayer.prototype.setWidth = function(w) {
	this._width = w;
}

VideoPlayer.prototype.setHeight = function(h) {
	this._height = h;
}

VideoPlayer.prototype.setSize = function(w, h) {
	this.setWidth(w);
	this.setHeight(h);
}

VideoPlayer.prototype.setType = function(t) {
	if (t.toUpperCase() == "FLV" || t.toUpperCase() == "WMV" || t.toUpperCase() == "QT") {
		this._type = t;
	} else {
		if (this._file.toUpperCase().indexOf("WMV") > -1) {
			this._type = "WMV";
		} else if (this._file.toUpperCase().indexOf("MOV") > -1) {
			this._type = "QT";
		} else {
			this._type = "FLV";
		}
	}
}

VideoPlayer.prototype.setStreamer = function(s) {
	this._streamer = s;
}

VideoPlayer.prototype.setPlaylist = function(s) {
	this._playlist = s;
}

VideoPlayer.prototype.setDefaults = function() {
	if (!this._file) {
		this.setFile(this._root + '/flash/no_video.swf');
	}
	if (!this._type) {
		this.setType(this._file);
	}
	if (!this._width) {
		this.setWidth(320);
	}
	if (!this._height) {
		this.setHeight(240);
	}
	if (!this._streamer) {
		this.setStreamer('');
	}
	
	// if (this._file.toUpperCase().indexOf("XML") > -1) {
	if (this._playlist == "bottom") {
		this.setHeight(this._height + 120);
		this.playlistsize = 120;
	} else if (this._playlist == "right") {
		this.setWidth(this._width + 180);
		this.playlistsize = 180;
	} else if (this._playlist == "over") {
		this.setHeight(this._height);
		this.playlistsize = 0;
	} else {
		this._playlist = "none";
		this.playlistsize = 0;
	}
}

VideoPlayer.prototype.write = function(div) {
	this.setDefaults();
	
	var embedcode = "";
	
	if (this._type == "WMV") {
		var hAdjust;
		var userPlatform = navigator.platform;
		
		if (userPlatform == "MacIntel" || userPlatform == "MacPPC") {
			hAdjust = 16;
		} else {
			hAdjust = 143;
		}
		
		embedcode += '<div id="__wmvplayer__">';
		embedcode += '	<OBJECT ID="MediaPlayer" ';
		embedcode += '		WIDTH="' + this._width + '" ';
		embedcode += '		HEIGHT="' + (this._height + hAdjust) + '" ';
		embedcode += '		CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ';
		embedcode += '		STANDBY="Loading Windows Media Player components..." ';
		embedcode += '		TYPE="application/x-oleobject">';
		embedcode += '		<PARAM NAME="FileName" VALUE="' + this._file + '">';
		embedcode += '		<PARAM name="ShowControls" VALUE="true">';
		embedcode += '		<param name="ShowStatusBar" value="true">';
		embedcode += '		<PARAM name="ShowDisplay" VALUE="true">';
		embedcode += '		<PARAM name="autostart" VALUE="true">';
		embedcode += '		<EMBED TYPE="application/x-mplayer2" ';
		embedcode += '			SRC="' + this._file + '" ';
		embedcode += '			NAME="MediaPlayer" ';
		embedcode += '			WIDTH="' + this._width + '" ';
		embedcode += '			HEIGHT="' + (this._height + hAdjust) + '" ';
		embedcode += '			ShowControls="1" ';
		embedcode += '			ShowStatusBar="1" ';
		embedcode += '			ShowDisplay="1" ';
		embedcode += '			autostart="1">';
		embedcode += '		</EMBED>';
		embedcode += '	</OBJECT></div>';
	} else if (type == "QT") {
		embedcode += '<div id="__qtplayer__">';
		embedcode += '	<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ';
		embedcode += '		CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" ';
		embedcode += '		WIDTH="' + this._width + '" ';
		embedcode += '		HEIGHT="' + (this._height + 16) + '"> ';
		embedcode += '		<PARAM NAME="src" VALUE="' + this._file + '" > ';
		embedcode += '		<PARAM NAME="AutoPlay" VALUE="true" > ';
		embedcode += '		<PARAM NAME="Controller" VALUE="true" > ';
		embedcode += '		<EMBED SRC="' + this._file + '" ';
		embedcode += '			WIDTH="' + this._width + '" ';
		embedcode += '			HEIGHT="' + (this._height + 16) + '" ';
		embedcode += '			TYPE="video/quicktime" ';
		embedcode += '			PLUGINSPAGE="http://www.apple.com/quicktime/download/" ';
		embedcode += '			AUTOPLAY="true" ';
		embedcode += '			CONTROLLER="true" />';
		embedcode += '	</OBJECT></div>';
	} else {
		embedcode += '<div id="__flvplayer__">';
		embedcode += '	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
		embedcode += '		codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
		embedcode += '		width="' + this._width + '" ';
		embedcode += '		height="' + (this._height + 20) + '" ';
		embedcode += '		id="flvplayer" ';
		embedcode += '		align="middle">';
		embedcode += '		<param name="movie" value="' + this._root + '/flash/player.swf">';
		embedcode += '		<param name="flashvars" value="file=' + this._file + '&autostart=true&playlist=' + this._playlist + '&playlistsize=' + this.playlistsize + '&repeat=list&streamer=' + this._streamer + '&controlbar=bottom&stretching=uniform"> ';
		embedcode += '		<param name="allowScriptAccess" value="sameDomain">';
		embedcode += '		<param name="allowFullScreen" value="true">';
		embedcode += '		<param name="quality" value="high">';
		embedcode += '		<param name="bgcolor" value="#FFFFFF">';
		embedcode += '		<embed src="' + this._root + '/flash/player.swf" ';
		embedcode += '			flashvars="file=' + this._file + '&autostart=true&playlist=' + this._playlist + '&playlistsize=' + this.playlistsize + '&repeat=list&streamer=' + this._streamer + '&controlbar=bottom&stretching=uniform" ';
		embedcode += '			quality="high" ';
		embedcode += '			bgcolor="#FFFFFF" ';
		embedcode += '			width="' + this._width + '" ';
		embedcode += '			height="' + (this._height + 20) + '" ';
		embedcode += '			name="flvplayer" ';
		embedcode += '			align="middle" ';
		embedcode += '			allowScriptAccess="sameDomain" ';
		embedcode += '			allowFullScreen="true" ';
		embedcode += '			type="application/x-shockwave-flash" ';
		embedcode += '			pluginspage="http://www.macromedia.com/go/getflashplayer">';
		embedcode += '	</object></div>';
	}
	
	if (div) {
		document.getElementById(div).innerHTML = embedcode;
	} else {
		document.write(embedcode);
	}
}

VideoPlayer.prototype.trace = function(t) {
	alert(t);
}

VideoPlayer.prototype.IncludeJavaScript = function(js) {
	document.write('<script type="text/javascript" src="' + js + '"></scr' + 'ipt>'); 
}
