// JavaScript Written By Marc Castles MCWeb - version 1

//this function enables a popup for either flash,
//quicktime, real media or windows media, all you need to 
//supply is the file location and dimensions
function popupMedia(url,width,height) {
	media = url.substr((url.length-3));
	if(media == "mov") {
		height += 16;
	}
	if(media == "wmv") {
		height += 75;
	}
	if(media == ".rm") {
		height += 35;
	}
	//sloves most scroll bar problems by having
	//space around the player
	winheight = parseFloat(height) + 30;
	winwidth =  parseFloat(width) + 30;

	newWin=window.open('', 'popupwin','resizable=0,HEIGHT='+winheight+',WIDTH='+winwidth+', scrollbars=0', true);
	newWin.document.write('<html>\n');
	newWin.document.write('<head>\n');
	newWin.document.write('<title>'+media+' popup</title>');
	newWin.document.write('<script language="javascript" type="text/javascript">\n<!--\n');
	newWin.document.write('var arrTemp=self.location.href.split("?");\n');
	newWin.document.write('var picUrl = (arrTemp.length>1)?arrTemp[1]:"";\n');
	newWin.document.write('var NS = (navigator.appName=="Netscape")?true:false;\n');
	newWin.document.write('function fitMedia() {\n');
	newWin.document.write('	iWidth = (NS)?window.innerWidth:document.body.clientWidth;\n');
	newWin.document.write('	iHeight = (NS)?window.innerHeight:document.body.clientHeight;\n');
	newWin.document.write('	iWidth = '+winwidth+' - iWidth;\n');
	newWin.document.write('	iHeight = '+winheight+' - iHeight;\n');
	newWin.document.write('	window.resizeBy(iWidth, iHeight);\n');
	newWin.document.write('	var posLeft = (window.screen.width - '+winwidth+')/2;\n');
	newWin.document.write('	window.moveTo(posLeft,80);\n');
	newWin.document.write('};\n');
	newWin.document.write('-->\n</script>\n');

	newWin.document.write('<style>html,body{height:100%;padding:0px;}</style>\n');
	newWin.document.write('</head>\n');
	newWin.document.write('<body style="background-color:black; margin:0px; padding:0px;">\n');
	newWin.document.write('<table border=0 style="height:100%; width:100%; text-align:center;"><tr><td>\n');
	if(media == "jpg" || media == "gif") {
		newWin.document.write('<div><img src="'+url+'" width="'+width+'" height="'+height+'"></div>');
	} else if(media == "swf") {
		newWin.document.write('<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="flash" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,00,0" border="0" width="'+width+'" height="'+height+'">\n');
		newWin.document.write('<param name="movie" value="'+url+'">\n');
		newWin.document.write('<param name="quality" value="High">\n');
		newWin.document.write('<param name="menu" value="false">\n');
		newWin.document.write('<embed src="'+url+'" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj4" width="'+width+'" height="'+height+'" quality="AutoHigh" bgcolor="#364987">\n');
		newWin.document.write('</object>\n');
	} else if(media == "wmv") {
		newWin.document.write('<object id="MediaPlayer" width='+width+' height='+height+' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Microsoft® Windows® Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">\n');
		newWin.document.write('<PARAM NAME="filename" VALUE="'+url+'">\n');
		newWin.document.write('<PARAM NAME="autoStart" VALUE="true">\n<PARAM NAME="showControls" VALUE="true">\n');
		newWin.document.write('<param name="ShowStatusBar" value="true">\n<PARAM NAME="Autorewind" VALUE="true">\n');
		newWin.document.write('<PARAM NAME="ShowDisplay" VALUE="false">\n');
  		newWin.document.write('<EMBED SRC="'+url+'" WIDTH="'+width+'" HEIGHT="'+height+'" type="application/x-mplayer2" name="MediaPlayer" autostart=1 showcontrols=1 showstatusbar=1 autorewind=1 showdisplay=0></EMBED>\n');
		newWin.document.write('</OBJECT>\n');
	} else if(media == "mov") {
		newWin.document.write('<object id="quicktime" CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+width+'" height="'+height+'" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" >\n');
		newWin.document.write('<param name="movie" value="'+url+'">\n');
		newWin.document.write('<param name="kioskmode" value="false">\n');
		newWin.document.write('<param name="cache" value="false">\n');
		newWin.document.write('<param name="loop" value="false">\n');
		newWin.document.write('<param name="controller" value="true">\n');
		newWin.document.write('<param name="bgcolor" value="#000000">\n');
		newWin.document.write('<embed width="'+width+'" height="'+height+'" src="'+url+'" autoplay="TRUE" ');
		newWin.document.write('bgcolor="ffffff" cache="false" controller="true" kioskmode="false" pluginspage="http://www.apple.com/quicktime/download/" target="quicktimeplayer" type="video/quicktime">\n');
		newWin.document.write('</embed>\n');
		newWin.document.write('</object>\n');
	} else if(media == ".rm") {
		newWin.document.write('<OBJECT ID=Real CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH="'+width+'" HEIGHT="'+height+'">\n');
		newWin.document.write('<PARAM NAME="SRC" VALUE="'+url+'">\n');
		newWin.document.write('<PARAM NAME="CONTROLS" VALUE="all">\n');
		newWin.document.write('<PARAM NAME="CONSOLE" VALUE="one">\n');
		newWin.document.write('<PARAM NAME="AUTOSTART" VALUE="true">\n');
		newWin.document.write('<EMBED SRC="'+url+'" WIDTH="'+width+'" HEIGHT="'+height+'" NOJAVA=true CONTROLS=all CONSOLE=one AUTOSTART=true>\n');
		newWin.document.write('</OBJECT>\n');
	} else {
		newWin.document.write('no valid media found\n');
	}
	newWin.document.write('</td>\n</tr>\n</table>\n</body>\n<script language="javascript" type="text/javascript">\n<!--\n');
	newWin.document.write('fitMedia();\n');
	newWin.document.write('-->\n</script>\n');	
	newWin.document.write('</html>');
	newWin.document.close()
	newWin.focus();
}