function FLVPlayer(hWin, width, height){
	this.hWin = hWin;
	this.elt = null;
	this.topElt = null;
	this.flvElt = null;
	this.btmElt = null;
	this.so = null;
	this.x = null;
	this.y = null;
	this.width = width;
	this.height = height;
	this.flvEltId = 'flvplayer';  //this is the id of the elt created by SWFObject to contain the flv player
	this.fsvEltId = 'fsvFlvPlayer'; //this is the id of the elt created for a flash movie to send data to the flv player movie
}
	
FLVPlayer.prototype.loadVideo = function(vURL){
		if (stateWindow.flashVersion<8){
			if (confirm("You need Flash version 8 or higher to view video.\n\nPress OK do download it now."))
				window.open('http://www.adobe.com/go/getflashplayer') ;
			return null;
		}
		
		if(vURL == null || vURL == "null"){
			alert('Video not ready yet. Please try again in a few minutes.');
			return null;
		}
		
		if(this.elt){
			this.elt.parentNode.removeChild(this.elt);
			//this.sendData("videoURL=" + escape(vURL) + "&action=loadvideo&playOnLoad=1");
			//this.hWin.sendStringToFlash("flvplayer", "videoURL=" + escape(vURL) + "&action=loadvideo&playOnLoad=1");
		} //else {
			//create elt
			this.elt = this.hWin.document.createElement("DIV");
			this.elt.id = "flvPlayerPopup";
			
			this.topElt = this.hWin.document.createElement("DIV");
			this.topElt.id = "flvPlayerTop";
			this.topElt.style.backgroundImage = 'url(http://' + stateWindow.staticHost() + '/images/photos/flvplayertop.gif)';
			var img = this.hWin.document.createElement("IMG");
			img.src='http://' + stateWindow.staticHost() + '/images/photos/flvplayerclose.gif';
			img.value = this;
			img.className = "Cursor";
			img.onclick = function(){ this.value.close(); };
			this.topElt.appendChild(img);
			this.elt.appendChild(this.topElt);
			
			this.flvElt = this.hWin.document.createElement("DIV");
			this.flvElt.id = "flvPlayerCtn";
			this.elt.appendChild(this.flvElt);
			
			this.btmElt = this.hWin.document.createElement("DIV");
			this.btmElt.id = "flvPlayerBtm";
			this.elt.appendChild(this.btmElt);
			
			//centre elt and then show by attaching to body
			this.centre();
			this.hWin.document.body.appendChild(this.elt);
		
			//create swf
			this.so = stateWindow.createSWFObject(this.hWin, "http://" + stateWindow.staticHost() + "/swfs/flvplayer.swf", this.flvEltId, this.width, this.height, "7");
			this.so.addVariable("videoURL", escape(vURL));
			this.so.addVariable("bufferTime", "10");
			this.so.addVariable("initialVolume", "60");
			this.so.addVariable("admin", "0");
			this.so.addVariable("movieid", "flvplayer");
			this.so.addVariable("playOnLoad", "1");
			this.so.write("flvPlayerCtn");
		//}
		
		return this.elt;
	}
	
	
FLVPlayer.prototype.getSendLink = function(vidId){
	try{
		return '<A href="javascript:stateWindow.openEmailPopup(\'video\', ' + vidId + ')">send to a friend</A>';
	} catch (e) {
		alert('FLVPlayer.getSendLink exception ' + e);
	}
}

FLVPlayer.prototype.sendData = function(str){
		if(!this.hWin.document.getElementById(this.fsvEltId)){
			var divholder = this.hWin.document.createElement("div");
			divholder.id = this.fsvEltId;
			this.hWin.document.body.appendChild(divholder);
		}
		this.hWin.document.getElementById(this.fsvEltId).innerHTML = "";
		var moviePath = 'http://' + stateWindow.staticHost() + '/swfs/jstof.swf';
		var divinfo = "<embed src='" + this.moviePath + "' FlashVars='lc="+this.flvEltId+"&fq="+escape(str)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
		this.hWin.document.getElementById(this.fsvEltId).innerHTML = divinfo;
	}
	
FLVPlayer.prototype.close = function(){
		if(this.elt){
			this.sendData("action=unloadvideo");
			this.hWin.document.body.removeChild(this.elt);
		}
		this.elt = null;		
	}
	
FLVPlayer.prototype.centre = function(){
		if(this.elt){
			this.x = this.hWin.document.body.scrollLeft + (stateWindow._si.getWinWidth(this.hWin) - this.width)/2;
			this.y = (this.hWin.document.body.scrollTop - 20) + (stateWindow._si.getWinHeight(this.hWin) - (this.height + 20))/2;
			this.elt.style.left = this.x;
			this.elt.style.top = this.y;
		}
	}

