function mm(url,w,h)
{
	return window.open(url,'_blank','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + w + ',height=' + h);
}

function openlink(url,w,h)
{
	return window.open(url,'_blank','width=' + w + ',height=' + h);
}

function startmovie()
{
var doc;
var moviestr;
var url;

		
	moviestr = this.template.replace(/<<OBJECTWIDTH>>/gi,this.objw);
	moviestr = moviestr.replace(/<<OBJECTHEIGHT>>/gi,this.objh);
	moviestr = moviestr.replace(/<<EMBEDWIDTH>>/gi,this.embw);
	moviestr = moviestr.replace(/<<EMBEDHEIGHT>>/gi,this.embh);
	moviestr = moviestr.replace(/<<FILEURL>>/gi,this.url);

	doc = mm('',this.winw,this.winh).document;

	doc.open("text/html");

	if(document.all)
		doc.charset=document.charset;
	else
		doc.characterset=document.characterset;

	//STRING LITERAL//
	doc.write("<HTML><HEAD><TITLE>ActiveBuilder Solutions</TITLE></HEAD><BODY marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 bgcolor='#084E9B'>");
	doc.write("<TABLE><TR><TD><FONT face='Verdana, Tahoma, Arial' color='#FFFFFF' size=2>"+this.title+"</FONT></TD></TR><TR><TD>");
	doc.write(moviestr);
	doc.write("</TD></TR></TABLE></BODY></HTML>");

	doc.close();
}

function mediaplayer(url,title,w,h)
{
	this.objw =w+0;
	this.objh = h+50;
	this.embw=w+0;
	this.embh=h+0;
	this.winw=w+6;
	this.winh=h+92;
	this.url=url;
	this.title = title;
	this.start = startmovie;

	this.template="<OBJECT WIDTH=<<OBJECTWIDTH>> HEIGHT=<<OBJECTHEIGHT>> CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,2,902' TYPE='application/x-oleobject'>" +
		      "<PARAM NAME='ShowControls' VALUE='1'><PARAM NAME='FileName' VALUE='<<FILEURL>>'><PARAM NAME='AutoStart' Value='1'><PARAM NAME='AnimationAtStart' VALUE=0><PARAM NAME='TransparentAtStart' VALUE='1'>" +
		      "<EMBED WIDTH=<<EMBEDWIDTH>> HEIGHT=<<EMBEDHEIGHT>> TYPE='application/x-mplayer2' PLUGINSPAGE='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' FILENAME='<<FILEURL>>' SHOWCONTROLS=1 SHOWTRACKER=1 AUTOSTART=1></EMBED></OBJECT>";
}

function realplayer(url,title,w,h)
{
	this.objw =w+0;
	this.objh = h;
	this.embw=w+0;
	this.embh=h+0;
	this.winw=w+6;
	this.winh=h+72;
	this.url=url;
	this.title = title;
	this.start = startmovie;

	this.template="<OBJECT WIDTH=<<OBJECTWIDTH>> HEIGHT=<<OBJECTHEIGHT>> CLASSID='CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'>"+
		      "<PARAM NAME=SRC VALUE='<<FILEURL>>'><PARAM NAME=AUTOSTART VALUE=true><PARAM NAME=CONTROLS VALUE=ImageWindow><PARAM NAME=CONSOLE VALUE=c1>"+
		      "<EMBED TYPE='audio/x-pn-realaudio-plugin' SRC='<<FILEURL>>' WIDTH=<<EMBEDWIDTH>> HEIGHT=<<EMBEDHEIGHT>> AUTOSTART=true CONTROLS=ImageWindow CONSOLE=c1></EMBED></OBJECT><BR>"+
		      "<OBJECT WIDTH=<<OBJECTWIDTH>> HEIGHT=30 CLASSID='CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'>"+
		      "<PARAM NAME=CONTROLS VALUE=ControlPanel><PARAM NAME=AUTOSTART Value=true><PARAM NAME=CONSOLE VALUE=c1>"+
		      "<EMBED TYPE='audio/x-pn-realaudio-plugin' WIDTH=<<EMBEDWIDTH>> HEIGHT=30 CONTROLS=ControlPanel AUTOSTART=true CONSOLE=c1></EMBED></OBJECT>";
}

function shockwaveflash(url,title,w,h)
{
	this.objw =w+0;
	this.objh = h+0;
	this.embw=w+0;
	this.embh=h+0;
	this.winw=w+6;
	this.winh=h+42;
	this.url=url;
	this.title = title;
	this.start = startmovie;

	this.template="<OBJECT WIDTH=<<OBJECTWIDTH>> HEIGHT=<<OBJECTHEIGHT>> CLASSID='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#3,0,0,0'>"+
		      "<PARAM NAME=SRC VALUE='<<FILEURL>>'>"+
		      "<EMBED SRC=<<FILEURL>> WIDTH=<<EMBEDWIDTH>> HEIGHT=<<EMBEDHEIGHT>> PLUGINSPAGE='http://www.macromedia.com/shockwave/download/' TYPE='application/x-shockwave-flash'></EMBED></OBJECT>";
}

function shockwavedcr(url,title,w,h)
{
	this.objw =w+0;
	this.objh = h+0;
	this.embw=w+0;
	this.embh=h+0;
	this.winw=w+6;
	this.winh=h+42;
	this.url=url;
	this.title = title;
	this.start = startmovie;

	this.template="<OBJECT WIDTH=<<OBJECTWIDTH>> HEIGHT=<<OBJECTHEIGHT>> CLASSID='CLSID:166B1BCA-3F9C-11CF-8075-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,0,0' ID=2>"+
		      "<PARAM NAME=SRC VALUE='<<FILEURL>>'><PARAM NAME=swRemote VALUE=\"swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true'\"><PARAM NAME=swStretchStyle value=none><PARAM NAME=bgColor VALUE=#000000>"+
		      "<EMBED SRC='<<FILEURL>>' WIDTH=<<OBJECTWIDTH>> HEIGHT=<<OBJECTHEIGHT>> BGCOLOR=#000000 swRemote=\"swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true'\" swStretchStyle=none TYPE='application/x-director' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/'></embed></object>";
}

function playmovie(url,title,w,h){
var player,fname,ext,i;

	fname = url.slice(url.lastIndexOf("/")+1);
	
	i=fname.lastIndexOf(".");

	if(i==-1) return;

	ext = fname.slice(i+1).toLowerCase();

	switch(ext)
	{
		case "ra":
		case "ram":
		case "rm":
				player = new realplayer(url,title,w,h);	
				break;
		case "swf":
				player = new shockwaveflash(url,title,w,h);
				break;
		case "dcr":
				player = new shockwavedcr(url,title,w,h);
				break;
		default:
				player = new mediaplayer(url,title,w,h);
				break;
	}

	player.start();
}