/**
 * flv Player
 * js version 1.0.0
 * video player version 1.2.0
 * author : mutationevent
 * web sites : http://www.mutationevent.com
 * 
 * fvp is (c) 2006 mutationevent.com and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
function fvp(flvURL,Attributes){
	this.movieID = this.randomId('5');
	this.movieURL = 'fvpPlayer.swf';
	this.AttrObj = {
		classid : 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
		codebase : 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0',
		width : Attributes.width,
		height : Attributes.height,
		id : this.movieID
	};
	this.ParamObj = {
		movie : this.movieURL,
		bgcolor : Attributes.bgcolor
	};
	this.EmbedObj = {
		type : 'application/x-shockwave-flash',
		pluginpage : 'http://www.macromedia.com/go/getflashplayer',
		width : Attributes.width,
		height : Attributes.height,
		name : this.movieID,
		bgcolor : Attributes.bgcolor,
		src : this.movieURL
	};
	this.FlashVars = {
		videoURL : flvURL,
		bufferTime : '10',
		description : Attributes.description
	}
	
};
fvp.prototype.player = function(){
	var str = '<object ';
	for(var i in this.AttrObj){
		str += i + '="' + this.AttrObj[i] + '" ';
	}
	str += '>\n';
	for(var i in this.ParamObj){
		str += '<param name="' + i + '" value="' + this.ParamObj[i] + '" />\n';
	}
	str += '<param name="FlashVars" value="'+ this.parseVars() + '" />\n';
	str += '<embed ';
	for(var i in this.EmbedObj){
		str += i + '="' + this.EmbedObj[i] + '" ';
	}
	str += 'FlashVars="' + this.parseVars() + '"';
	str += '/>\n';
	str += '</object>\n';
	return str;
};
fvp.prototype.load = function(){
	document.write(this.player());
};
fvp.prototype.setBufferTime = function(time){
	this.FlashVars.bufferTime = time;
};
fvp.prototype.setParameters = function(name,value){
	this.ParamObj[name] = value;
	this.setEmbedAttributes(name,value);
};
fvp.prototype.setAttributes = function(name,value){
	this.AttrObj[name] = value;
};
fvp.prototype.setVariables = function(name,value){
	this.FlashVars[name] = value;
};
fvp.prototype.setEmbedAttributes = function(name,value){
	this.EmbedObj[name] = value;
};
fvp.prototype.parseVars = function(){
	var rslt = '';
	for(var i in this.FlashVars){
		rslt += i + '=' + this.FlashVars[i] + '&';
	}
	return rslt;
};
fvp.prototype.randomId = function(length){
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomStr = '';
	for (var i=0; i<length; i++) {
		var r = Math.floor(Math.random() * chars.length);
		randomStr += chars.substring(r,r+1);
	}
	return randomStr;
	
}