//	-----------------------------------------------
//	ASDYS
//	version:  April 4th 2007
//	----------------------------------------------- */

	var detectableWithVB = false;
	var pluginFound = false;

function detectQuickTime() {
	pluginFound = detectPlugin('QuickTime');
	return pluginFound;
}

function detectWindowsMedia() {
	pluginFound = detectPlugin('Windows Media Player');
	if(!pluginFound) {
	pluginFound = detectableWithVB;
	}
	return pluginFound;
}

function detectPlugin() {
	var daPlugins = detectPlugin.arguments;
	var pluginFound = false;
	if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;

		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
		var numFound = 0;
			for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {

				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
				(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
				numFound++;
				}   
			}

			if(numFound == daPlugins.length) {
			pluginFound = true;
			break;
			}
		}
	}
	return pluginFound;
}

if((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
	document.writeln('<script language="VBscript">');
	document.writeln('detectableWithVB = False');

	document.writeln('If ScriptEngineMajorVersion >= 2 then');
	document.writeln('  detectableWithVB = True');
	document.writeln('End If');

	document.writeln('</scr' + 'ipt>');
}

function buildPlayerA(resourceId){

	if(detectWindowsMedia()){

		if(window.ActiveXObject){

		var axBrowser = "<object id=\"WMPaxPlayer\" classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\"\n";
		axBrowser += "height=\"300\" width=\"320\">\n";
		axBrowser += "<param name=\"UIMode\" value=\"full\">\n";
		axBrowser += "<param name=\"autoRewind\" value=\"false\">\n";
		axBrowser += "<param name=\"autostart\" value=\"true\">\n";
		axBrowser += "</object>\n";
		document.write(axBrowser);

		}else{

		var nonaxBrowser = "<object id=\"WMPPlayer\" type=\"application/x-mplayer2\"\n";
		nonaxBrowser += "height=\"300\" width=\"320\">\n";
		nonaxBrowser += "<param name=\"fileName\" value=\"http://www.nottingham.ac.uk/pesl/peslvideo/video/" + resourceId + ".wmv\">\n";
		nonaxBrowser += "<param name=\"UIMode\" value=\"mini\">\n";
		nonaxBrowser += "<param name=\"autoRewind\" value=\"false\">\n";
		nonaxBrowser += "<param name=\"autostart\" value=\"true\">\n";
		nonaxBrowser += "</object>\n";
		document.write(nonaxBrowser);

		}

	}else if(detectQuickTime()){

	var qtBrowser = "<object type=\"video/quicktime\" id=\"QTPlayer\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\"\n";
	qtBrowser += "codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" height=\"256\" width=\"320\">\n";
	qtBrowser += "<param name=\"src\" value=\"http://www.nottingham.ac.uk/pesl/peslvideo/video/" + resourceId + ".mov\">\n";
	qtBrowser += "<param name=\"autoplay\" value=\"true\">\n";
	qtBrowser += "<param name=\"controller\" value=\"true\">\n";
	qtBrowser += "<embed height=\"256\" width=\"320\" src=\"http://www.nottingham.ac.uk/pesl/peslvideo/video/" + resourceId + ".mov\"\n";
	qtBrowser += "pluginspage=\"http://www.apple.com/quicktime/download/\" type=\"video/quicktime\" controller=\"true\" autoplay=\"true\">\n";
	qtBrowser += "</embed></object>\n";
	document.write(qtBrowser);

	}else{

	var noMP = "<h2 class=\"tablebgcolthree pcenter\">Video still</h2>\n";
	noMP += "<img src=\"http://www.nottingham.ac.uk/pesl/peslvideo/video/" + resourceId + ".jpg\" height=\"240\" width=\"320\" alt=\"Video still\" vspace=\"5\">\n";
	noMP += "<p><strong>NB</strong> A still image from the video is displayed because we assume that a media player plugin is not available in your web browser.</p>\n";
	noMP += "<p>To watch the videos you will need either an <a href=\"http://www.apple.com/quicktime/download/\">Apple QuickTime media player</a> or a <a href=\"http://www.microsoft.com/windows/windowsmedia/mp10/\">Microsoft Windows Media Player</a>.</p>\n";
	noMP += "<p>Please visit the <a href=\"./video/view/\">about viewing videos</a> page for further information.</p>\n";
	document.write(noMP);

	}

}	// end buildPlayerA

function buildPlayerB(resourceId){

	if(detectWindowsMedia()){

		if(window.ActiveXObject){

		document.write("<div id=\"CapText\"></div>\n");
		document.WMPaxPlayer.closedCaption.CaptioningID = "CapText";
		document.WMPaxPlayer.URL = "http://www.nottingham.ac.uk/pesl/peslvideo/video/" + resourceId + ".asx";
		document.WMPaxPlayer.closedCaption.SAMIFileName = "" + resourceId + ".smi";
		document.WMPaxPlayer.controls.play();

		}else{

		iframeHeight = "300";

		var iframeContent = "<iframe title=\"Video Transcript\" name=\"transcript\" id=\"vt\"\n";
		iframeContent += "width=\"320\" height=\"" + iframeHeight + "\" frameborder=\"0\" scrolling=\"auto\" align=\"center\"\n";
		iframeContent += "src=\"http://www.nottingham.ac.uk/pesl/iframe/transcript/" + resourceId + "/asdys/\">\n";
		iframeContent += "<p>This resource requires an iframe compliant web browser.</p>\n";
		iframeContent += "</iframe>";
		document.write(iframeContent);

		}

	}else{

	var iframeHeight = "0";

		if(detectQuickTime()){
		iframeHeight = "256";
		}else{
		iframeHeight = "450";
		}

	var iframeContent = "<iframe title=\"Video Transcript\" name=\"transcript\" id=\"vt\"\n";
	iframeContent += "width=\"320\" height=\"" + iframeHeight + "\" frameborder=\"0\" scrolling=\"auto\" align=\"center\"\n";
	iframeContent += "src=\"http://www.nottingham.ac.uk/pesl/iframe/transcript/" + resourceId + "/asdys/\">\n";
	iframeContent += "<p>This resource requires an iframe compliant web browser.</p>\n";
	iframeContent += "</iframe>";
	document.write(iframeContent);

	}

}	// end buildPlayerB

