var QTversion=6.0;
var Flashversion=8;
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision){
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}
//WINDOWS MEDIA//
var windowsmedia=new Object();
// Set some base values
windowsmedia.installed=false;
windowsmedia.version='0.0'; // Internet Explorer-only

// Check for GeckoActiveXObject and co-inciding Plug-In
var gkoaxwma=false;
if (navigator.plugins && navigator.plugins.length) { for (x=0; x<navigator.plugins.length; x++) { if (navigator.plugins[x].name.indexOf('ActiveX') != -1 && window.GeckoActiveXObject) { gkoaxwma=true; break; } } }

// Create an ActiveX/GeckoActiveX constructor
function AXO(id)
{
	var error; var control = null;
	try {
		if (window.ActiveXObject && navigator.userAgent.indexOf('Win') != -1) control = new ActiveXObject(id);
		else if (gkoaxwma) control = new GeckoActiveXObject(id);
	}
	catch (error) {}
	return control;
}

if (window.ActiveXObject || gkoaxwma)
{
	try
	{
		oWMP=new AXO('WMPlayer.OCX.7');
		if (oWMP)
		{
			windowsmedia.installed=true;

			// A wierd bug in the Gecko ActiveX plug-in will return
			// undefined at the first call, but the correct value on the second.
			// This "fix" doesn't seem to hurt IE at all.
			parseFloat(oWMP.versionInfo);

			windowsmedia.version=parseFloat(oWMP.versionInfo);
			if (windowsmedia.version.toString().length == 1) windowsmedia.version+='.0';
		}
	}
	catch(e) {}
}
else if (navigator.plugins && navigator.plugins.length){
	for (x=0; x<navigator.plugins.length; x++)
	{
		if (navigator.plugins[x].name.indexOf('Windows Media') != -1)
		{
			windowsmedia.installed=true;
			break;
		}
	}
}
var fHasWMP = navigator.mimeTypes 
	  && navigator.mimeTypes["application/x-mplayer2"]
	  && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
// Internet Explorer or GeckoActiveXObject-compatible browsers only.
windowsmedia.ver7=(windowsmedia.installed && parseInt(windowsmedia.version) >= 7) ? true:false;
windowsmedia.ver8=(windowsmedia.installed && parseInt(windowsmedia.version) >= 8) ? true:false;
windowsmedia.ver9=(windowsmedia.installed && parseInt(windowsmedia.version) >= 9) ? true:false;

function hasQT() {
	var haveqt;
	for(var i=0; i<navigator.plugins.length; i++) {
		var name = navigator.plugins[i].name;
		if(name.indexOf("QuickTime") >= 0) {
			quickTimeVersion = parseFloat(name.substring(name.lastIndexOf(" "), name.length));
			hasQuickTime = (quickTimeVersion >= QTversion);
			if(hasQuickTime) {
				haveqt = true;
				break;
			}
		}
	}
	return haveqt;
}
function isFfPc(){
	if(!isIE && !is_mac){
		return true;
	}else{
		return false;
	}
}
function makeFlash(file, div, id, w, h, wmode) {
	if(isIE) {
		var temp = document.createElement('object');
		document.getElementById(div).appendChild(temp);
		temp.width = w;
		temp.height = h;
		temp.id = id;
		temp.classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
		temp.wmode = wmode;
		//temp.quality = "high";
		temp.allowScriptAccess = "always";
		temp.movie = file + query;
	} else {
			var tag= '<OBJECT' +
			'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"  align="middle" WIDTH="'+ w +'" HEIGHT="'+ h +'" ID="'+ id +'">' +
			'<PARAM NAME="allowScriptAccess" VALUE="always" />' +
			'<PARAM NAME="movie" VALUE="'+ file + query +'" />' +
			'<PARAM NAME="quality" VALUE="high" />' +
			'<EMBED SRC="'+ file + query +'" QUALITY="high" BGCOLOR="#FFFFFF" WIDTH="'+ w +'" HEIGHT="'+ h +'" NAME="'+ id +'" ALIGN="middle" allowScriptAccess="always" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />' +
			'</OBJECT>';
			document.getElementById(div).innerHTML = tag;
			/*
			var tag= '<EMBED SRC="'+ file + query +'" QUALITY="high" BGCOLOR="#FFFFFF" WIDTH="'+ w +'" HEIGHT="'+ h +'" NAME="'+ id +'" ALIGN="middle" allowScriptAccess="always" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
			document.getElementById(div).innerHTML = tag;
			*/
	}
	return(true);
}

function makeContainer() {
	if(isIE) {
	if(showcontrols){
		document.write('<OBJECT id="wmcontainer" width="480" height="360" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">');
		document.write('<PARAM NAME="URL" VALUE="mms://wm.microsoft.com/ms/windows/windowsmedia/demos/9series/avquality/wmvstdqualdemo/media/kelsy_500.wmv">');
		document.write('<PARAM NAME="AutoStart" VALUE="False">');
		document.write('<PARAM name="uiMode" value="full">');
		document.write('<PARAM name="PlayCount" value="1">');
		document.write('<PARAM name="stretchToFit" value="True">');
		document.write('<PARAM name="Volume" value="70">');
		document.write('<PARAM name="InvokeURLs" value="False">');
		document.write('<PARAM name="windowlessVideo" value="False">');
		document.write('<PARAM name="enableContextMenu" value="false">');
		document.write('</OBJECT>');
	} else {
		document.write('<OBJECT id="wmcontainer" width="480" height="360" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">');
		document.write('<PARAM NAME="URL" VALUE="">');
		document.write('<PARAM NAME="AutoStart" VALUE="False">');
		document.write('<PARAM name="uiMode" value="none">');
		document.write('<PARAM name="PlayCount" value="1">');
		document.write('<PARAM name="stretchToFit" value="True">');
		document.write('<PARAM name="Volume" value="70">');
		document.write('<PARAM name="InvokeURLs" value="False">');
		document.write('<PARAM name="windowlessVideo" value="False">');
		document.write('<PARAM name="enableContextMenu" value="false">');
		document.write('</OBJECT>');
	}
		/*
		var temp2 = document.createElement('object');
		document.getElementById("mediacontainer").appendChild(temp2);
		temp2.id 		= "wmcontainer";
		temp2.classid 	= "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
		temp2.width 	= "480px";
		temp2.height 	= "360px";
		temp2.autoStart = "0";
		temp2.enableContextMenu = "0";
		temp2.playCount 	= "1";
		temp2.stretchToFit 	= "1";
		temp2.uiMode 		= "none";
		temp2.volume 		= "70";
		temp2.invokeURLs 	= "false";
		temp2.windowlessVideo = "0";
		temp2.URL 			= "";
		*/
	}else{
		var qtTag= '<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'+
		'codebase="http://www.apple.com/qtactivex/qtplugin.cab"'+
		'width="480" height="360" id="qtcontainer">'+
		'<PARAM NAME="autoplay" VALUE="false">'+ 
		'<PARAM NAME="controller" VALUE="false">'+
		'<PARAM NAME="kioskmode" VALUE="true">'+
		'<PARAM NAME="scale" VALUE="tofit">'+  
		'<PARAM NAME="volume" VALUE="70">'+
		'<PARAM NAME="BGCOLOR" VALUE="#000000">'+ 
		'<PARAM NAME="SAVEEMBEDTAGS" VALUE="TRUE">'+
		'<PARAM NAME="src" value="ab.qtif">'+ 
		'<EMBED WIDTH="480" HEIGHT="360"'+
		'SRC="ab.qtif"'+
		'TYPE="video/quicktime"'+
		'PLUGINSPAGE="www.apple.com/quicktime/download"'+
		'CONTROLLER="false"'+
		'LOOP="false"'+
		'AUTOPLAY="false"'+
		'SCALE="tofit"'+
		'CACHE="false"'+
		'VOLUME="50"'+
		'BGCOLOR="#000000"'+
		'KIOSKMODE="true"'+
		'EnableJavaScript="true"'+
		'SAVEEMBEDTAGS="True"'+
		'NAME="qtcontainer"'+ 
		'/></OBJECT>';
		document.getElementById("mediacontainer").innerHTML = qtTag;
		
	}
}

if(isIE){
	function cleanup() {
		__flash_unloadHandler = function(){
			if (externalProbSet) {return};
			externalProbSet = true;
			for (var obj in getElementsByTagName("OBJECT")){
				var theObj = eval(obj);
				theObj.style.display = "none";
				for (var prop in theObj){
					if (typeof(theObj[prop]) == 'function'){
						theObj[prop]=null
					}
				}
			}
			if (__flash_savedUnloadHandler != null){
				__flash_savedUnloadHandler();
			}
		}
		if (window.onunload != __flash_unloadHandler){
			__flash_savedUnloadHandler = window.onunload;
			window.onunload = __flash_unloadHandler;
		}
	}
	window.onbeforeunload=cleanup;
}

