function videowidth(fn)
{
	//returns video width from a file
	//standard width from 1X = 180, 2X=360, 3X=540, 4X=720
	if(fn.indexOf("X.") !=-1)
	{
		//has a standard format
		var Xscale;
		var Xpos;
		Xpos = fn.indexOf("X.");
		Xscale = fn.substr(Xpos-1,2);
		if(Xscale == "1X") {return "180";}
		if(Xscale == "2X") {return "360";}
		if(Xscale == "3X") {return "540";}
		if(Xscale == "4X") {return "720";}
	} else if (fn.indexOf("x") !=-1)
	{
		//special width and height
		var xscale;
		var xpos;
		xpos = fn.indexOf("x");
		xscale = fn.substr(xpos-3,3);
		return xscale;
	}else
	{
		return null;
	}
}

function videoheight(fn)
{
	//returns video width from a file
	//standard width from 1X = 120, 2X=240, 3X=360, 4X=480
	if(fn.indexOf("X.") !=-1)
	{
		//has a standard format
		var Xscale;
		var Xpos;
		Xpos = fn.indexOf("X.");
		Xscale = fn.substr(Xpos-1,2);
		if(Xscale == "1X") {return "120";}
		if(Xscale == "2X") {return "240";}
		if(Xscale == "3X") {return "360";}
		if(Xscale == "4X") {return "480";}
	} else if (fn.indexOf("x") !=-1)
	{
		//special width and height
		var xscale;
		var xpos;
		xpos = fn.indexOf("x");
		xscale = fn.substr(xpos+1,3);
		return xscale;
	}else
	{
		return null;
	}
}

function controllerheight(cntlr)
{
	cntlr = cntlr.toLowerCase();
	//returns the controller height 
	if(cntlr == "swf") {return "0";} else
	if(cntlr == "mov") {return "16";} else
	if(cntlr == "wmv") {return "46";}else
	if(cntlr == "avi") {return "46";}else
	if(cntlr == "gif") {return "0";}else
	if(cntlr == "jpg") {return "0";}else
	if(cntlr == "rm") {return "30";}else  //need to check on realplayer height addition
	{ return null;}
}

function fnext(fn)
{
	//returns the extension of a filename
	//assume an exentsion is 3 or less from end
	var dot = fn.indexOf(".",fn.length-4);
	if(dot != -1) 
	{ 
		return fn.substr(dot+1);
	} else 
	{
		return null;
	}
}

function classidWMP()
{	//browser ActiveX detection
	var WMP;
	if (window.ActiveXObject) 
	{
		if( WMP = new ActiveXObject("WMPlayer.OCX.7"))
		{
			//WMP version 7 or 9
			//return(WMP.versionInfo);
			return "6BF52A52-394A-11d3-B153-00C04F79FAA6";
		} else if( WMP = new ActiveXObject("MediaPlayer.MediaPlayer.1"))
		{
			//WMP version 6.4
			//return(WMP.versionInfo);
			return "22D6F312-B0F6-11D0-94AB-0080C74C7E95";
		}else if( WMP = new ActiveXObject("AMOVIE.OCX"))
		{
			//WMP version 6.0
			//WMP version 6 ran on Win95 and WinNT4.0
			//return(WMP.versionInfo);
			return "02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
		}
	} else if (window.GeckoActiveXObject)
	{
		if((WMP = new GeckoActiveXObject("WMPlayer.OCX.7")) || 
			(WMP = new GeckoActiveXObject("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")))
		{
			//WMP version 7 or 9
			//return(WMP.versionInfo);
			return "6BF52A52-394A-11d3-B153-00C04F79FAA6";
		} else if((WMP = new GeckoActiveXObject("MediaPlayer.MediaPlayer.1")) ||
				   (WMP = new GeckoActiveXObject("{22D6F312-B0F6-11D0-94AB-0080C74C7E95}")))
		{
			//WMP version 6.4
			//return(WMP.versionInfo);
			return "22D6F312-B0F6-11D0-94AB-0080C74C7E95";
		}else if((WMP = new GeckoActiveXObject("AMOVIE.OCX")) ||
				   (WMP = new GeckoActiveXObject("{05589FA1-C356-11CE-BF01-00AA0055595A}")))
		{
			//WMP version 6.0
			//WMP version 6 ran on Win95 and WinNT4.0
			//return(WMP.versionInfo);
			return "02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
		}
	} else
	{
		//browser plugin detection
		var i;var pl; var plugin = "Windows Media Player";
		if (navigator.plugins && navigator.plugins.length > 0) 
		{
			pl = navigator.plugins.length;
			var numMatch = 0;
			for(i=0; i < pl; i++)
			{
				if((navigator.plugins[i].name.indexOf(plugin) >= 0) || 
				(navigator.plugins[i].description.indexOf(plugin) >= 0))
				{
					numMatch++;
				} 
			}
			//if match then the embed will trigger the player so just return the latest classid, OTW an older classid
			if(numMatch){return "6BF52A52-394A-11d3-B153-00C04F79FAA6";}else
			{ return "22D6F312-B0F6-11D0-94AB-0080C74C7E95";}
		}
	}
}

function aviWindow(vfile,vloop,vcontroller,vautoplay)
{
	//set the parameters
	var filename = vfile;
	var autoplay = vautoplay;
	var loop = vloop;
	var controller = vcontroller;
	var cssfile;
	var activexfile;
	
	//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	var ext = fnext(vfile);
	var cheight = controllerheight(ext);
	
	var xautoplay;
	var xloop;
	var xcontroller;
	
	//convert the parameters
	if(autoplay == 1) { xautoplay = "true"; } else { xautoplay = "false"; }
	if(loop == 1) { xloop = "true"; } else { xloop = "false"; }
	if(controller == 1) 
	{ 
		xcontroller = "true"; 
		vpheight = parseInt(vpheight) + parseInt(cheight);
	} else 
	{ 
		xcontroller = "false"; 
	}
	//set the classid;
	var classid;
	//classid = classidWMP();
	classid = "22D6F312-B0F6-11D0-94AB-0080C74C7E95";

	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";

	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<object id='video' classid='clsid:" + classid + "'" ;
	text += " width='" + vpwidth + "'"; 
	text += " height='" + vpheight + "'";   
	text += " type='application/x-oleobject'";   
	text += " standby='Loading Windows Media Player components...'"; 
	text += " codebase='http://www.microsoft.com/windows/windowsmedia/mp10/default.aspx'";
	text += " boarder='0'>";   
	text += "<param name='ShowDisplay' value='0'>";
	text += "<param name='ShowControls' value='" + xcontroller + "'>";
	text += "<param name='AutoStart' value='" + xautoplay + "'>";
	text += "<param name='AutoRewind' value='" + xloop + "'>";
	//text += "<param name='PlayCount' value='0'>";
	text += "<param name='Loop' value='" + xloop + "'>";
	//text += "<param name='Appearance' value='0'>";
	//text += "<param name='BorderStyle' value='0'>";
	text += "<param name='MovieWindowHeight' value='" + vpheight + "'>";
	text += "<param name='MovieWindowWidth' value='" + vpwidth + "'>";
	text += "<param name='FileName' value='" + filename + "'>";
	text += "<embed src='" + filename + "'";
	text += " type='video/x-msvideo'";
	text += " width='" + vpwidth  + "'";
	text += " height='" + vpheight + "'";                
	text += " loop ='" + loop + "'";               
	text += " autostart='" + autoplay + "'";          
	text += " controls='" + controller + "'";
	text += " bgcolor='#000000'>";
	text += "</embed>"; 	      
	text += "</object>";		   
	text += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a></br>\n";
	//fix for IE ActiveX error
	text += "<form  name='formx' action='' method='get'><input name='videopreferencetype' type='hidden' value='swf'>" + vfile.lastIndexOf("../") + "</form>";
	text +=	"<!--[if IE]><script language='Javascript' type='text/javascript'  src='" + activexfile + "'  defer='defer'></script><![endif]-->";
	//end IE ACtiveX fix
	text += "\n</body>\n</html>\n";
	
	return text;
}

function movWindow(vfile,vloop,vcontroller,vautoplay)
{
	//set the parameters
	var filename = vfile;
	var autoplay = vautoplay;
	var loop = vloop;
	var controller = vcontroller;
	var cssfile;
	var activexfile;
	
	//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	var ext = fnext(vfile);
	var cheight = controllerheight(ext);

//convert the parameters
	if(autoplay == 1) { autoplay = "TRUE"; } else { autoplay = "FALSE"; }
	if(loop == 1) { loop = "TRUE"; } else { loop = "FALSE"; }
	if(controller == 1) 
	{ 
		controller = "TRUE"; 
		vpheight = parseInt(vpheight) + parseInt(cheight);
	} else 
	{ 
		controller = "FALSE"; 
	}
	
	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";

	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text +=  "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<OBJECT CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' NOEXTERNALDATA='TRUE'\n" ;
	text += "WIDTH='" + vpwidth  + "'\n";
	text += "HEIGHT='" + vpheight + "'\n";   
	text += "CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab'>\n";
	text += "<PARAM NAME='controller' VALUE='" + controller + "'>\n";
	text += "<PARAM NAME='type' VALUE='video/quicktime'>\n";
	text += "<PARAM NAME='autoplay' VALUE='" + autoplay + "'>\n";
	text += "<PARAM NAME='target' VALUE='myself'>\n";
	text += "<PARAM NAME='SRC' VALUE='" + filename + "'>\n";
	text += "<PARAM NAME='LOOP' VALUE='" + loop + "'>\n";
	text += "<PARAM NAME='pluginspage' VALUE='http://www.apple.com/quicktime/download/indext.html'>\n";
	text += "<EMBED WIDTH='" + vpwidth  + "'";
	text += "HEIGHT='" + vpheight + "'";                
	text += "CONTROLLER='" + controller + "'";
	text += "TYPE='" + 'video/quicktime' + "'";
	text += "SRC='" + filename + "'";
	text += "TYPE='video/quicktime'";
	text += "AUTOPLAY='" + autoplay + "'";          
	text += "LOOP ='" + loop + "'";               
	text += "BGCOLOR='#000000'";
	text += "CACHE='true'";
	text += "KIOSKMODE='true'";
	text += "PLAYEVERYFRAME='true'";                       
	text += "PLUGINSPAGE='http://www.apple.com/quicktime/download/'>";                        
	text += "</EMBED>"; 	      
	text += "</OBJECT>\n";		   
	text += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a></br>\n";
	//fix for IE ActiveX error
	text += "<form  name='formx' action='' method='get'><input name='videopreferencetype' type='hidden' value='swf'>" + vfile.lastIndexOf("../") + "</form>";
	text +=	"<!--[if IE]><script language='Javascript' type='text/javascript'  src='" + activexfile + "'  defer='defer'></script><![endif]-->";
	//end IE ACtiveX fix
	text += "\n</body>\n</html>\n";
	
	return text; 
}

function rmWindow(vfile,vloop,vcontroller,vautoplay)
{
		//set the parameters
	var filename = vfile;
	var autoplay = vautoplay;
	var loop = vloop;
	var controller = vcontroller;
	var cssfile;
	var activexfile;

if(autoplay == 1) {autoplay = true;} else {autoplay = false;}
	if(controller = 1) {controller = true;} else {controller = false;}
	if(loop == 1) {loop = true;} else {loop = false;}

//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	//add controller height
	vpheight = parseInt(vpheight) + 32;

	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";

	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'" ;
	text += " width='" + vpwidth  + "'";
	text += " height='" + vpheight + "'>";   
	text += "<param name='SRC' value='" + filename + "'>";
	text += "<param name='autostart' value='" + autoplay + "'>";
	text += "<param name='loop' value='" + loop + "'>";
	text += "<param name='controls' value='false'>";
	text += "<param name='backgroundcolor' value='white'>";
	text += "<param name='nologog' value='true'>";
	text += "<embed src='" + filename + "'";
	text += " width='" + vpwidth  + "'";
	text += " type='audio/x-pn-realaudio-plugin'";
	text += " height='" + vpheight + "'";                
	text += " autostart='" + autoplay + "'";          
	text += " loop ='" + loop + "'";               
	text += " controls='false'";
	text += " nologog='true'";
	text += " backgroundcolor='white'>";
	text += "</object>\n";		   
	text += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a></br>\n";
	//fix for IE ActiveX error
	text += "<form  name='formx' action='' method='get'><input name='videopreferencetype' type='hidden' value='swf'>" + vfile.lastIndexOf("../") + "</form>";
	text +=	"<!--[if IE]><script language='Javascript' type='text/javascript'  src='" + activexfile + "'  defer='defer'></script><![endif]-->";
	//end IE ACtiveX fix
	text += "\n</body>\n</html>\n";

	return text; 
}

function wmvWindow(vfile,vloop,vcontroller,vautoplay)
{
	//set the parameters
	var filename = vfile;
	var autoplay = vautoplay;
	var loop = vloop;
	var controller = vcontroller;
	var cssfile;
	var activexfile;
	
	//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	var ext = fnext(vfile);
	var cheight = controllerheight(ext);
	
	//convert the parameters
	var xautoplay;
	var xloop;
	var xcontroller;
	if(autoplay == 1) { xautoplay = "true"; } else { xautoplay = "false"; }
	if(loop == 1) { xloop = "true"; } else { xloop = "false"; }
	if(controller == 1) 
	{ 
		xcontroller = "true"; 
		vpheight = parseInt(vpheight) + parseInt(cheight);
	} else 
	{ 
		xcontroller = "false"; 
	}
	var classid;
	//classid = classidWMP();
	classid = "6BF52A52-394A-11d3-B153-00C04F79FAA6";

	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";

	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<object id='video' classid='" + classid + "'" ;
	text += " width='" + vpwidth + "'"; 
	text += " height='" + vpheight + "'";   
	text += " type='application/x-oleobject'";   
	//text += " standby='Loading Windows Media Player components...'";   
	//text += " codebase='http://www.microsoft.com/windows/windowsmedia/mp10/default.aspx'";
	text += " boarder='0'>";   
	text += "<param name='ShowDisplay' value='true'>";
	text += "<param name='uiMode' value='full'>";
	//choices for uimode are invisible,none,mini,full,custom
	text += "<param name='ShowControls' value='" + xcontroller + "'>";
	text += "<param name='AutoStart' value='" + xautoplay + "'>";
	text += "<param name='AutoRewind' value='" + xloop + "'>";
	//text += "<param name='PlayCount' value='0'>";
	text += "<param name='Loop' value='" + xloop + "'>";
	//text += "<param name='Appearance' value='0'>";
	//text += "<param name='BorderStyle' value='0'>";
	text += "<param name='MovieWindowHeight' value='" + vpheight + "'>";
	text += "<param name='MovieWindowWidth' value='" + vpwidth + "'>";
	text += "<param name='FileName' value='" + filename + "'>";
	text += "<embed src='" + filename + "'";
	text += " type='video/x-msvideo'";
	text += " width='" + vpwidth  + "'";
	text += " height='" + vpheight + "'";                
	text += " loop ='" + loop + "'";               
	text += " autostart='" + autoplay + "'";          
	text += " controls='" + controller + "'";
	text += " bgcolor='#000000'>";
	text += "</embed>"; 	      
	text += "</object>";		   
	text += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a></br>\n";
	//fix for IE ActiveX error
	text += "<form  name='formx' action='' method='get'><input name='videopreferencetype' type='hidden' value='swf'>" + vfile.lastIndexOf("../") + "</form>";
	text +=	"<!--[if IE]><script language='Javascript' type='text/javascript'  src='" + activexfile + "'  defer='defer'></script><![endif]-->";
	//end IE ACtiveX fix
	text += "\n</body>\n</html>\n";
	
	return text;
}

function swfWindow(vfile,vloop,vcontroller,vautoplay)
{

	//set the parameters
	var filename = vfile;
	//var autoplay = vautoplay;
	//var loop = vloop;
	var controller = vcontroller;
	var cssfile;
	var activexfile;
	
	//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	var ext = fnext(vfile);
	var cheight = controllerheight(ext);
	
	//convert the parameters
	//var xautoplay;
	//var xloop;
	//var xcontroller;
	//if(autoplay == 1) { xautoplay = "true"; } else { xautoplay = "false"; }
	//if(loop == 1) { xloop = "true"; } else { xloop = "false"; }
	if(controller == 1) 
	{ 
		xcontroller = "true"; 
		vpheight = parseInt(vpheight) + parseInt(cheight);
	} else 
	{ 
		xcontroller = "false"; 
	}
	//need to account for differnce file levels
	
	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";
	
	var classid;
	classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	//bgcolor='#000000'
	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>\n";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<object name='video' classid='" + classid + "'" ;
	text += " width='" + vpwidth + "'"; 
	text += " height='" + vpheight + "'";   
	text += " standby='Loading Flash Movie...'";   
	//text += " codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'";
	text += " codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0'";
	text += " align='middle'>";   
	text += "<param name='allowScriptAccess' value='sameDomain'>";
	text += "<param name='quality' value='best'>";
	text += "<param name='bgcolor' value='#000000'>";
	text += "<param name='movie' value='" + filename + "'>";
	text += "<embed src='" + filename + "'";
	text += " quality='best'";
	text += " pluginspage='http://www.macromedia.com/go/getflashplayer'";
	text += " width='" + vpwidth  + "'";
	text += " height='" + vpheight + "'";                
	text += " bgcolor='#000000'>";
	text += "</embed>"; 	      
	text += "</object>\n";
	text += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a></br>\n";
	//fix for IE ActiveX error
	text += "<form  name='formx' action='' method='get'><input name='videopreferencetype' type='hidden' value='swf'>" + vfile.lastIndexOf("../") + "</form>";
	text +=	"<!--[if IE]><script language='Javascript' type='text/javascript'  src='" + activexfile + "'  defer='defer'></script><![endif]-->";
	//end IE ACtiveX fix
	text += "\n</body>\n</html>\n";

	return text;
}
					
			  

function gifWindow(vfile,vloop,vcontroller,vautoplay)
{
		//set the parameters
	var filename = vfile;
	var autoplay = 0;
	var loop = 0;
	var controller = 0;
	var cssfile;
	var activexfile;

if(autoplay == 1) {autoplay = true;} else {autoplay = false;}
	if(controller = 1) {controller = true;} else {controller = false;}
	if(loop == 1) {loop = true;} else {loop = false;}

//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	//add controller height
	//vpheight = parseInt(vpheight) + 32;
	cssfile = "./css/popup.css";
	activexfile = "./scripts/activex.js";
	
	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<table width='100%' align='center' valign='top'><tr><td>";
	text += "<img src=" + filename + "'";
	text += " width='" + vpwidth + "'"; 
	text += " height='" + vpheight + "'>";   
	text += "</td></tr><tr><td>";
	text += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a>\n";
	text += "</td></tr></table>\n</body>\n</html>\n";

	return text; 
}

function jpgWindow(vfile,vloop,vcontroller,vautoplay)
{
		//set the parameters
	var filename = vfile;
	var autoplay = 0;
	var loop = 0;
	var controller = 0;
	var cssfile;
	var activexfile;

	if(autoplay == 1) {autoplay = true;} else {autoplay = false;}
	if(controller = 1) {controller = true;} else {controller = false;}
	if(loop == 1) {loop = true;} else {loop = false;}
//get parameters
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);
	//add controller height
	//vpheight = parseInt(vpheight) + 32;
	if(vfile.lastIndexOf("../") < 0)
	{
		cssfile = "css/popup.css";
		activexfile = "scripts/activex.js";
	} else if(vfile.lastIndexOf("../") > 0)
	{
		cssfile = "../../css/popup.css";
		activexfile = "../../scripts/activex.js";
	} else
	{
		cssfile = "../css/popup.css";
		activexfile = "../scripts/activex.js";
	}
	
	text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
	text += "<html>\n<head>\n<title>" + filename + "</title>";
	text += "<link href=\"" + cssfile + "\" rel=\"stylesheet\" type=\"text/css\">";
	text += "</head>\n<body align='left' leftmargin='0' topmargin='0' bgcolor='#000000'>\n";
	text += "<table width='100%' align='center' valign='top'><tr><td>";
	text += "<img src='" + filename + "'";
	text += " width='" + vpwidth + "'"; 
	text += " height='" + vpheight + "'>";   
	text += "</td></tr><tr><td>";
	text += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:self.close()'>Close Window</a>\n";
	text += "</td></tr></table>";
	text += "\n</body>\n</html>\n";

	return text; 
}



var newWindow;
function openVideoWin(vfile,vloop,vcontroller,vautoplay)
{
	//close an open window
	if (newWindow && !newWindow.closed)	
	{
		newWindow.close();	
	} 
	
	var vpwidth = videowidth(vfile);
	var vpheight = videoheight(vfile);	
	var ext = fnext(vfile);
	
	if(vcontroller == 1) 
	{ 
		var cheight = controllerheight(ext);
		vpheight = parseInt(vpheight) + parseInt(cheight);
	}	
	
	var text;
	if(ext == "swf") {text = swfWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "mov") {text = movWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "rm")  {text = rmWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "avi") {text = aviWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "gif") {text = gifWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "jpg") {text = jpgWindow(vfile,vloop,vcontroller,vautoplay)} else
	if(ext == "wmv") {text = wmvWindow(vfile,vloop,vcontroller,vautoplay)}
	
	//add height for close window link
	vpheight = vpheight + 25;
	
	//newWindow = window.open('','VideoPlayer','width=' + vpwidth + ',height=' + vpheight + ',resizable') ;
	newWindow = window.open('','VideoPlayer','width=' + vpwidth + ',height=' + vpheight + ',resizable=no') ;
	newWindow.document.write(text);
	newWindow.focus();
	newWindow.document.close();

}

